A model’s computation is a GraphProto, held in field 7 of the
ModelProto. Graphs also appear inside
attributes, as the branches of If and the bodies of Loop and
Scan, and in training information. Values flow between nodes by name:
each node lists the names of its inputs and outputs, and a name is a graph input, an
initialiser or the output of exactly one node.
GraphProto
A graph: nodes in topological order, the weights (initialisers), and the graph’s inputs and outputs.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | node | repeated NodeProto | LEN, one per node | The nodes, sorted so that each comes after the nodes whose outputs it uses. |
| 2 | name | string | LEN | The graph’s name. |
| 5 | initializer | repeated TensorProto | LEN, one per tensor | Named constant tensors: usually the weights. Each tensor’s name is the value name that nodes use. From IR 4 an initialiser need not also be listed as an input. |
| 15 | sparse_initializer | repeated SparseTensorProto | LEN, one per tensor | Initialisers stored sparse (IR 6). |
| 10 | doc_string | string | LEN | Documentation. |
| 11 | input | repeated ValueInfoProto | LEN, one per input | The graph’s inputs, with their types and shapes. |
| 12 | output | repeated ValueInfoProto | LEN, one per output | The graph’s outputs. |
| 13 | value_info | repeated ValueInfoProto | LEN, one per value | Types and shapes of values inside the graph, when known. |
| 14 | quantization_annotation | repeated TensorAnnotation | LEN, one per entry | Which tensors hold each tensor’s quantisation scale and zero point (IR 5). |
| 16 | metadata_props | repeated StringStringEntryProto | LEN, one per entry | Named metadata (IR 10). |
Fields 3, 4 and 6 to 9 are reserved, and so are the names ir_version,
producer_version, producer_tag and domain, so
they cannot be reused.
In a large model nearly all of the graph’s bytes are initialisers. The 1 GB model examined for this site has 1,723 nodes and 486 initialisers. The explorer lists both, with each initialiser’s name, type, shape, storage and size.
TensorAnnotation
Names the tensors that hold another tensor’s quantisation parameters (IR 5).
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | tensor_name | string | LEN | The tensor annotated. |
| 2 | quant_parameter_tensor_names | repeated StringStringEntryProto | LEN, one per entry | Keys such as SCALE_TENSOR and ZERO_POINT_TENSOR, each with the name of the tensor holding that parameter. |