The whole file is one GraphDef. These messages are from TensorFlow’s
graph.proto, versions.proto, function.proto and
op_def.proto (syntax = "proto3", package
tensorflow, as on TensorFlow’s master branch in November 2026). A frozen
graph holds its computation, weights included, as nodes; the function library holds
any functions those nodes call. For the bytes of tags and lengths, see the
Protocol Buffers reference.
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. The explorer does not include this message and shows it by number. |
A complete 56-byte frozen graph, built for this page: one Const node
named w holding the two floats 1.0 and 2.0.
0A 36 0A 01 77 12 05 43 6F 6E 73 74 2A 0B 0A 05 64 74 79 70 65 12 02 30 01
2A 1D 0A 05 76 61 6C 75 65 12 14 42 12 08 01 12 04 12 02 08 02 22 08 00 00 80 3F 00 00 00 40
node, 54 bytes: a NodeDef with name, op and two attributesThe node is decoded field by field on NodeDef
and attributes. A real frozen graph has many such nodes, with their inputs, and
usually a versions field.
VersionDef
Versions of the GraphDef format, which rise with TensorFlow releases. Which release gives which number was not researched for this page.
| 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
GraphDef it appears as the signature of each function.
| 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; shown by number. |
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. A GraphDef does not hold one itself; it is part of the schema the parser reads, used where TensorFlow lists the ops a graph needs.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | op | repeated OpDef | LEN, one per op | The ops. |