Each operation in a graph is a
NodeProto: an operator such as Conv or MatMul,
the names of the values it reads and writes, and its attributes. The operator’s meaning
comes from its operator set, named by domain and given a version in the
model’s opset_import.
NodeProto
One node: an operator, its inputs and outputs by name, and its attributes.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | input | repeated string | LEN, one per name | Input value names, in the operator’s order. An empty name stands for an optional input that is left out. |
| 2 | output | repeated string | LEN, one per name | Output value names. |
| 3 | name | string | LEN | The node’s name; optional. |
| 4 | op_type | string | LEN | The operator, such as Conv, or the name of a model-local function. The explorer requires it. |
| 7 | domain | string | LEN | The operator set’s domain; empty for ONNX’s own operators. |
| 8 | overload | string | LEN | Which overload of a model-local function (IR 10). |
| 5 | attribute | repeated AttributeProto | LEN, one per attribute | Named attributes, such as a convolution’s kernel_shape. |
| 6 | doc_string | string | LEN | Documentation. |
| 9 | metadata_props | repeated StringStringEntryProto | LEN, one per entry | Named metadata (IR 10). |
| 10 | device_configurations | repeated NodeDeviceConfigurationProto | LEN, one per entry | How the node is spread over devices (IR 11). |
AttributeProto
A named attribute of a node: one value of one type, which type names.
Exactly one value field is set.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | name | string | LEN | The attribute’s name. |
| 21 | ref_attr_name | string | LEN | Inside a function: the name of the caller’s attribute that this one takes its value from. |
| 13 | doc_string | string | LEN | Documentation. |
| 20 | type | AttributeType | VARINT | Which value field is used, from the table below (IR 2). |
| 2 | f | float | I32 | A float. |
| 3 | i | int64 | VARINT | An integer. |
| 4 | s | bytes | LEN | A string, UTF-8. |
| 5 | t | TensorProto | LEN | A tensor, such as a Constant node’s value. |
| 6 | g | GraphProto | LEN | A graph, such as a branch of If. |
| 22 | sparse_tensor | SparseTensorProto | LEN | A sparse tensor. |
| 14 | tp | TypeProto | LEN | A type. |
| 7 | floats | repeated float | I32 per value, or packed LEN | A list of floats. |
| 8 | ints | repeated int64 | VARINT per value, or packed LEN | A list of integers, such as kernel_shape or pads. |
| 9 | strings | repeated bytes | LEN, one per string | A list of strings. |
| 10 | tensors | repeated TensorProto | LEN, one per tensor | A list of tensors. |
| 11 | graphs | repeated GraphProto | LEN, one per graph | A list of graphs. |
| 23 | sparse_tensors | repeated SparseTensorProto | LEN, one per tensor | A list of sparse tensors. |
| 15 | type_protos | repeated TypeProto | LEN, one per type | A list of types. |
Fields 12 and 16 to 19 are reserved, and so is the name v.
AttributeType
| Value | Name | Field | Value | Name | Field |
|---|---|---|---|---|---|
| 0 | UNDEFINED | – | 8 | STRINGS | strings |
| 1 | FLOAT | f | 9 | TENSORS | tensors |
| 2 | INT | i | 10 | GRAPHS | graphs |
| 3 | STRING | s | 11 | SPARSE_TENSOR | sparse_tensor |
| 4 | TENSOR | t | 12 | SPARSE_TENSORS | sparse_tensors |
| 5 | GRAPH | g | 13 | TYPE_PROTO | tp |
| 6 | FLOATS | floats | 14 | TYPE_PROTOS | type_protos |
| 7 | INTS | ints |
NodeDeviceConfigurationProto
How a node is spread over devices, under one of the model’s device configurations (IR 11).
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | configuration_id | string | LEN | The name of the DeviceConfigurationProto this belongs to. |
| 2 | sharding_spec | repeated ShardingSpecProto | LEN, one per tensor | How each input or output is sharded. |
| 3 | pipeline_stage | int32 | VARINT | The node’s pipeline stage. |
SimpleShardedDimProto
A dimension of N blocks divided into M shards.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | dim_value | int64 | VARINT | The dimension as a number (oneof dim). |
| 2 | dim_param | string | LEN | The dimension as a name (oneof dim). |
| 3 | num_shards | int64 | VARINT | How many shards. |
IntIntListEntryProto
A key and a list of integers.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | int64 | VARINT | The key. |
| 2 | value | repeated int64 | VARINT per value, or packed LEN | The values. |