Each MetaGraphDef of a
SavedModel holds one GraphDef in its field 2. These messages are from
TensorFlow’s graph.proto, versions.proto,
function.proto and op_def.proto (proto3, package
tensorflow). In a model saved by TensorFlow 2, most of the computation is
in the graph’s library of functions, and the top-level graph holds few nodes; that is
an inference from how TensorFlow 2 traces functions, since no real SavedModel was
examined for this site.
GraphDef
A graph of operations: the nodes, the graph’s versions and a library of functions.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | node | repeated NodeDef | LEN, one per node | The nodes, in any order; inputs are by name. |
| 4 | versions | VersionDef | LEN | The GraphDef version of the program that wrote it, and the oldest that can read it. |
| 3 | version | int32 | VARINT | Deprecated and ignored; use versions. |
| 2 | library | FunctionDefLibrary | LEN | Functions the graph calls. |
| 5 | debug_info | GraphDebugInfo | LEN | Stack traces for the nodes: see GraphDebugInfo. |
VersionDef
Versions of the GraphDef format, which rise with TensorFlow releases. Producer 0 was
graphs from before versioning; version 1 dates from December 2015. Versions up to 29
each marked a change of op or format, such as version 7 removing TopK
for TopKV2; from version 30 (May 2019) the number has gone up by one
each day. TensorFlow’s version.h lists each number’s change, and the
current number (2474 in January 2026) is the date-based value. A
program must refuse a graph that lists its version in bad_consumers,
or whose min_consumer is above its own version.
| Version | Change |
|---|---|
| 0 | Graphs from before versioning. |
| 1 | The first real version (2 Dec 2015). |
| 2 | adjust_contrast takes floats only and no longer clamps. |
| 3 | TileGrad removed. |
| 4 | Stricter AttrValue parsing for empty lists planned. |
| 5 | Graphs fully validated in Session::Create. |
| 6 | Scalar strictness within Google. |
| 7 | TopK removed for TopKV2. |
| 8 | RandomCrop moved to Python. |
| 9 | batch_norm_with_global_normalization deprecated. |
| 10 | conv3d_backprop_filter and _input deprecated. |
| 11 | batch_self_adjoint_eig deprecated. |
| 12 | Consumers understand FunctionDef.node_def. |
| 13 | Several batch linear algebra ops deprecated. |
| 14 | batch_matrix ops deprecated. |
| 15 | batch_fft ops deprecated. |
| 16 | TensorArray v1 ops deprecated. |
| 17 | inv deprecated and reverse_v2 exposed. |
| 18 | VariableV2 added. |
| 19 | SkipGram and NegTrain moved out of core. |
| 20 | SplitV, ReverseV2, ConcatV2, flooring division and TensorArrayV3 for the Python API. |
| 21 | FunctionDef.Node dropped for node_def. |
| 22 | Placeholder shapes enforced. |
| 23 | NonMaxSuppression removed for NonMaxSuppressionV2. |
| 24 | Lookup v1 ops deprecated. |
| 25 | Stack v1 and RandomPoisson v1 ops deprecated. |
| 26 | stripped_default_attrs added to MetaInfoDef. |
| 27 | TensorArray v2 and io v1 ops deprecated. |
| 28 | MatrixExponential deprecated. |
| 29 | StatefulStandardNormal deprecated. |
| 30 and up | Daily: version 30 is 9 May 2019 and each day adds one, so 2474 is 16 January 2026. |
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | producer | int32 | VARINT | The GraphDef version of the program that wrote it. |
| 2 | min_consumer | int32 | VARINT | The oldest GraphDef version that can read it. |
| 3 | bad_consumers | repeated int32, packed | LEN | Versions that must not read it. |
FunctionDefLibrary
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | function | repeated FunctionDef | LEN, one per function | The functions. |
| 2 | gradient | repeated GradientDef | LEN, one per entry | Which function is the gradient of which. |
| 3 | registered_gradients | repeated RegisteredGradient | LEN, one per entry | Gradients registered for op types. |
FunctionDef
A function: its signature, its body of nodes, and where its outputs come from. A
node calls it by giving the function’s name as its op.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | signature | OpDef | LEN | The function’s name, arguments and attributes. |
| 5 | attr | map<string, AttrValue> | LEN, one per entry | Attributes of the function itself. |
| 7 | arg_attr | map<uint32, ArgAttrs> | LEN, one per entry | Attributes of each argument, by index. |
| 8 | resource_arg_unique_id | map<uint32, uint32> | LEN, one per entry | Which resource arguments refer to the same resource. |
| 3 | node_def | repeated NodeDef | LEN, one per node | The body. Inside a function, inputs may name a node’s output by its output argument, as node:arg:0. |
| 4 | ret | map<string, string> | LEN, one per entry | Which node output each output of the function is. |
| 6 | control_ret | map<string, string> | LEN, one per entry | Control outputs: which node each names. |
Field 2 is reserved.
FunctionDef.AttrEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The attribute’s name. |
| 2 | value | AttrValue | LEN | Its value. |
FunctionDef.ArgAttrEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | uint32 | VARINT | The argument’s index. |
| 2 | value | ArgAttrs | LEN | Its attributes. |
FunctionDef.ArgAttrs
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | attr | map<string, AttrValue> | LEN, one per entry | The attributes of one argument. |
FunctionDef.ArgAttrs.AttrEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The attribute’s name. |
| 2 | value | AttrValue | LEN | Its value. |
FunctionDef.ResourceArgUniqueIdEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | uint32 | VARINT | An argument’s index. |
| 2 | value | uint32 | VARINT | Its resource’s ID. |
FunctionDef.RetEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | An output argument’s name. |
| 2 | value | string | LEN | The node output it comes from. |
FunctionDef.ControlRetEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | A control output’s name. |
| 2 | value | string | LEN | The node it names. |
GradientDef
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | function_name | string | LEN | A function in the library. |
| 2 | gradient_func | string | LEN | The function that computes its gradient. |
RegisteredGradient
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | gradient_func | string | LEN | The gradient function. |
| 2 | registered_op_type | string | LEN | The op type it is registered for. |
OpDef
An op’s or a function’s signature: its name, arguments, attributes and flags. In a
graph it appears as a function’s signature and in the
stripped_op_list of a meta graph.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | name | string | LEN | The name. |
| 2 | input_arg | repeated ArgDef | LEN, one per argument | Inputs. |
| 3 | output_arg | repeated ArgDef | LEN, one per argument | Outputs. |
| 20 | control_output | repeated string | LEN, one per name | Control outputs. |
| 4 | attr | repeated AttrDef | LEN, one per attribute | Attributes it takes. |
| 8 | deprecation | OpDeprecation | LEN | When it was deprecated. |
| 5 | summary | string | LEN | A one-line summary. |
| 6 | description | string | LEN | A description. |
| 18 | is_commutative | bool | VARINT | Whether the inputs can be swapped. |
| 16 | is_aggregate | bool | VARINT | Whether it adds up its inputs. |
| 17 | is_stateful | bool | VARINT | Whether it has state. |
| 19 | allows_uninitialized_input | bool | VARINT | Whether inputs may be uninitialised. |
| 21 | is_distributed_communication | bool | VARINT | Whether it communicates between devices. |
OpDef.ArgDef
One argument. Its type is fixed by type, or named by one of the
*_attr fields.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | name | string | LEN | The name. |
| 2 | description | string | LEN | A description. |
| 3 | type | DataType | VARINT | A fixed data type. |
| 4 | type_attr | string | LEN | The attribute that holds its type. |
| 5 | number_attr | string | LEN | The attribute that holds how many there are. |
| 6 | type_list_attr | string | LEN | The attribute that holds a list of types. |
| 7 | handle_data | repeated DtypeAndShape | LEN, one per entry | For resources: what they hold. |
| 16 | is_ref | bool | VARINT | Whether it is a reference. |
| 17 | experimental_full_type | FullTypeDef | LEN | Its full type: see FullTypeDef. |
OpDef.AttrDef
One attribute an op takes.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | name | string | LEN | The name. |
| 2 | type | string | LEN | Its type as text, such as int, type or list(type). |
| 3 | default_value | AttrValue | LEN | Its default. |
| 4 | description | string | LEN | A description. |
| 5 | has_minimum | bool | VARINT | Whether it has a minimum. |
| 6 | minimum | int64 | VARINT | The minimum. |
| 7 | allowed_values | AttrValue | LEN | The values allowed, as a list. |
OpDeprecation
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | version | int32 | VARINT | The GraphDef version from which the op is deprecated. |
| 2 | explanation | string | LEN | Why, and what to use instead. |
OpList
A list of op definitions: the stripped_op_list of a meta graph names
the ops its graph uses.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | op | repeated OpDef | LEN, one per op | The ops. |