Principle:Onnx Onnx Namespace Prefixing
| Knowledge Sources | |
|---|---|
| Domains | Model_Composition, Name_Management |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
A name disambiguation mechanism that adds prefixes to all named elements in an ONNX model to prevent name collisions when merging multiple models.
Description
When composing multiple ONNX models into a single model, there is a high risk of name collisions: two independent models may use the same names for nodes, edges, inputs, outputs, or initializers. Namespace prefixing solves this by prepending a unique prefix string to all names in a model, ensuring that names from different source models remain distinct after merging.
The prefixing operation can selectively target different categories of names (nodes, edges, inputs, outputs, initializers, value infos, and local functions), giving fine-grained control over which names are modified. This is essential for maintaining correct graph connectivity during model composition.
Usage
Use this principle as a preparation step before merging two or more ONNX models. Apply distinct prefixes to each source model to guarantee name uniqueness. Alternatively, merge_models can apply prefixes automatically via its prefix1 and prefix2 parameters.
Theoretical Basis
Namespace prefixing is a renaming transformation:
The transformation must be applied consistently across all references: if a node output name is prefixed, all nodes that reference that output as an input must also use the prefixed name.