The whole file is one ModelProto, the top-level message of ONNX’s schema
onnx.proto (onnx 1.23, IR version 14, syntax = "proto2",
package onnx). This page lists every field of it and of the smaller
messages it holds directly. Tables are in the order of the schema, which is not
always the order of the numbers. For the bytes of tags, varints and lengths, see the
Protocol Buffers reference.
ModelProto
The model: its IR version, the operator sets it imports, the program that made it, and the graph.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | ir_version | int64 | VARINT | The IR version of the format the model follows: 1 to 14. Required. |
| 8 | opset_import | repeated OperatorSetIdProto | LEN, one per set | The operator sets the model uses, each a domain and a version. At least one, for the default domain, from IR 3. |
| 2 | producer_name | string | LEN | The tool that wrote the model, such as pytorch or tf2onnx. |
| 3 | producer_version | string | LEN | That tool’s version. |
| 4 | domain | string | LEN | A reverse domain name for the model, such as com.example. |
| 5 | model_version | int64 | VARINT | The model’s own version number. |
| 6 | doc_string | string | LEN | Documentation; Markdown is allowed. |
| 7 | graph | GraphProto | LEN | The graph that runs the model: nodes, inputs, outputs and weights. |
| 14 | metadata_props | repeated StringStringEntryProto | LEN, one per entry | Named metadata, key and value strings. |
| 20 | training_info | repeated TrainingInfoProto | LEN, one per entry | How to initialise and train the model (IR 7). |
| 25 | functions | repeated FunctionProto | LEN, one per function | Functions local to the model (IR 8). |
| 26 | configuration | repeated DeviceConfigurationProto | LEN, one per configuration | Multi-device configurations (IR 11). |
opset_import is field 8 but comes second in the schema. Writers usually
put fields in number order, so it is often the last field of the file, after the
graph.
08 08 12 07 70 79 74 6F 72 63 68 1A 05 32 2E 38 2E 30 3A E7 D5 D7 FD 03 …
pytorch, producer_version 2.8.0, then the graph, 1,068,886,759 bytesOperatorSetIdProto
One operator set: a domain and its version. An operator such as Conv
means what that version of its set says it means.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | domain | string | LEN | The operator set’s domain. Empty or absent is the default ONNX domain, ai.onnx; ai.onnx.ml is ONNX’s machine learning set; others belong to runtimes or models. |
| 2 | version | int64 | VARINT | The operator set’s version, such as 17. |
StringStringEntryProto
A key and a value, both strings: ONNX’s stand-in for a map. It is used for metadata on the model, graph, nodes and tensors, for external data, and for the bindings of training information.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The key. |
| 2 | value | string | LEN | The value. |
TrainingInfoProto
Training information (IR 7): an initialisation graph, an algorithm graph, and the bindings between their outputs and the model’s initialisers.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | initialization | GraphProto | LEN | A graph that computes initial values. |
| 2 | algorithm | GraphProto | LEN | One step of the training algorithm. |
| 3 | initialization_binding | repeated StringStringEntryProto | LEN, one per entry | Which initialiser each output of the initialisation sets. |
| 4 | update_binding | repeated StringStringEntryProto | LEN, one per entry | Which initialiser each output of the algorithm updates. |
FunctionProto
A function local to the model (IR 8): a named subgraph of nodes with its own inputs,
outputs and operator sets. A node calls it by giving its name as
op_type and its domain as domain.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | name | string | LEN | The function’s name, used as an op_type. |
| 4 | input | repeated string | LEN, one per name | Input names. |
| 5 | output | repeated string | LEN, one per name | Output names. |
| 6 | attribute | repeated string | LEN, one per name | Names of attributes without defaults. |
| 11 | attribute_proto | repeated AttributeProto | LEN, one per attribute | Attributes with default values (IR 9). |
| 7 | node | repeated NodeProto | LEN, one per node | The nodes of the function body. |
| 8 | doc_string | string | LEN | Documentation. |
| 9 | opset_import | repeated OperatorSetIdProto | LEN, one per set | The operator sets the body uses. |
| 10 | domain | string | LEN | The function’s domain. |
| 13 | overload | string | LEN | An overload identifier, so that several functions can share a name (IR 10). |
| 12 | value_info | repeated ValueInfoProto | LEN, one per value | Types of values inside the function. |
| 14 | metadata_props | repeated StringStringEntryProto | LEN, one per entry | Named metadata. |
Fields 2 and 3 are not used.
DeviceConfigurationProto
A multi-device configuration (IR 11): a name, a device count and the device names. Nodes refer to it by name in their device configurations.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | name | string | LEN | The configuration’s name. |
| 2 | num_devices | int32 | VARINT | How many devices. |
| 3 | device | repeated string | LEN, one per device | Device names. |