In a TensorFlow 2 SavedModel, a
MetaGraphDef’s
object_graph_def holds a SavedObjectGraph: the Python
objects of the program, flattened to a list, so that the model can be loaded with its
structure and not only its graph. The first entry in the list, nodes[0], is
the root object. The schema is saved_object_graph.proto, and the explorer
decodes every field below.
SavedObjectGraph
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | nodes | repeated SavedObject | The objects. An object’s position in this list is its ID. |
| 2 | concrete_functions | map<string, SavedConcreteFunction> | Details of each concrete function, by name. |
SavedObject
One object: named edges to others, what kind it is, and how it is saved. Number 2
and the name attributes are reserved.
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | children | repeated ObjectReference | Named edges to objects. Every kind may have children except constant and captured_tensor. |
| 15 | dependencies | repeated ObjectReference | Objects that must load before this one. |
| 3 | slot_variables | repeated SlotVariableReference | Slot variables this object owns; only for user_object. |
| 4 | user_object | SavedUserObject | Kind (oneof): an object of a class the loader handles by name. |
| 5 | asset | SavedAsset | Kind: a reference to an asset file. |
| 6 | function | SavedFunction | Kind: a tf.function. |
| 7 | variable | SavedVariable | Kind: a variable. |
| 8 | bare_concrete_function | SavedBareConcreteFunction | Kind: a concrete function with argument names. |
| 9 | constant | SavedConstant | Kind: a constant. |
| 10 | resource | SavedResource | Kind: a stateful resource. |
| 12 | captured_tensor | CapturedTensor | Kind: a tensor a concrete function captures. |
| 11 | saveable_objects | map<string, SaveableObject> | Functions that save and restore this object. |
| 13 | registered_name | string | The registered class, package.class_name, used to find the class when loading. |
| 14 | serialized_user_proto | Any | Metadata passed to the class’s _deserialize_from_proto. |
| 16 | registered_saver | string | The registered saver’s name. At most one of this and saveable_objects is set. |
ObjectReference and SlotVariableReference
Both come from trackable_object_graph.proto.
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | node_id | int32 | The object referred to, an index into nodes. |
| 2 | local_name | string | The name of this edge. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | original_variable_node_id | int32 | The variable this slot belongs to. |
| 2 | slot_name | string | The slot’s name, such as m or v. |
| 3 | slot_variable_node_id | int32 | The object holding the slot’s value. |
The kinds of object
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | identifier | string | The registered type identifier the loader uses. |
| 2 | version | VersionDef | The producer’s version. |
| 3 | metadata | string | Deprecated: used only by Keras. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | asset_file_def_index | int32 | Index into MetaGraphDef.asset_file_def; only the filename is used. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | concrete_functions | repeated string | The concrete functions, by name. |
| 2 | function_spec | FunctionSpec | The function’s specification. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | name | string | The captured tensor’s name. |
| 2 | concrete_function | string | The concrete function whose graph computes it. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 2 | bound_inputs | repeated int32 | The objects the function captures, by ID. |
| 3 | canonicalized_input_signature | StructuredValue | The input signature used to create it. |
| 4 | output_signature | StructuredValue | The return structure, with tensors replaced by TensorSpecs. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | concrete_function_name | string | The concrete function. |
| 2 | argument_keywords | repeated string | Unique argument names, one per tensor. |
| 3 | allowed_positional_arguments | int64 | How many keywords may be given by position. |
| 4 | function_spec | FunctionSpec | The original function spec, if any. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | operation | string | The Const op’s name in the meta graph. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | dtype | DataType | The data type. |
| 2 | shape | TensorShapeProto | The shape. |
| 3 | trainable | bool | Whether it is trained. |
| 4 | synchronization | VariableSynchronization | When a distributed variable is synchronised. |
| 5 | aggregation | VariableAggregation | How it is aggregated across replicas. |
| 6 | name | string | The variable’s name. |
| 7 | device | string | Where it is placed. |
| 8 | experimental_distributed_variable_components | repeated SavedVariable | Components; non-empty means a distributed variable. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | device | string | Where it must be created; empty lets the user choose. |
| Field | Name | Type | Meaning |
|---|---|---|---|
| 2 | save_function | int32 | The save function’s node. |
| 3 | restore_function | int32 | The restore function’s node. |
FunctionSpec
The specification of a function wrapped as a TensorFlow Function. Numbers 3 and 4 are reserved.
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | fullargspec | StructuredValue | Arguments, from Python’s inspect.getfullargspec. |
| 2 | is_method | bool | Whether it is a class method. |
| 5 | input_signature | StructuredValue | The input signature, if given. |
| 6 | jit_compile | JitCompile | Whether XLA compiles it: DEFAULT 0, ON 1, OFF 2. |
VariableSynchronization and VariableAggregation
From variable.proto.
| Value | VariableSynchronization | Meaning |
|---|---|---|
| 0 | VARIABLE_SYNCHRONIZATION_AUTO | The distribution strategy decides. |
| 1 | VARIABLE_SYNCHRONIZATION_NONE | Only one copy; no syncing. |
| 2 | VARIABLE_SYNCHRONIZATION_ON_WRITE | Copies update on every write. |
| 3 | VARIABLE_SYNCHRONIZATION_ON_READ | Copies are aggregated on read. |
| Value | VariableAggregation | Meaning |
|---|---|---|
| 0 | VARIABLE_AGGREGATION_NONE | Default: an error if updated across replicas. |
| 1 | VARIABLE_AGGREGATION_SUM | Sums the replicas’ updates. |
| 2 | VARIABLE_AGGREGATION_MEAN | Averages them. |
| 3 | VARIABLE_AGGREGATION_ONLY_FIRST_REPLICA | Every replica runs the update, but only the first applies it. |