• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto3";
2
3package tensorflow;
4
5import "tensorflow/core/framework/tensor_shape.proto";
6import "tensorflow/core/framework/types.proto";
7import "tensorflow/core/framework/variable.proto";
8import "tensorflow/core/framework/versions.proto";
9import "tensorflow/core/protobuf/struct.proto";
10import "tensorflow/core/protobuf/trackable_object_graph.proto";
11
12option cc_enable_arenas = true;
13
14option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf";
15
16// A SavedObjectGraph is part of object-based SavedModels in TF 2.0. It
17// describes the directed graph of Python objects (or equivalent in other
18// languages) that make up a model, with nodes[0] at the root.
19
20// SavedObjectGraph shares some structure with TrackableObjectGraph, but
21// SavedObjectGraph belongs to the MetaGraph and contains pointers to functions
22// and type information, while TrackableObjectGraph lives in the checkpoint
23// and contains pointers only to variable values.
24
25message SavedObjectGraph {
26  // Flattened list of objects in the object graph.
27  //
28  // The position of the object in this list indicates its id.
29  // Nodes[0] is considered the root node.
30  repeated SavedObject nodes = 1;
31
32  // Information about captures and output structures in concrete functions.
33  // Referenced from SavedBareConcreteFunction and SavedFunction.
34  map<string, SavedConcreteFunction> concrete_functions = 2;
35}
36
37message SavedObject {
38  // Objects which this object depends on: named edges in the dependency
39  // graph.
40  //
41  // Note: currently only valid if kind == "user_object".
42  repeated TrackableObjectGraph.TrackableObject.ObjectReference children = 1;
43
44  // Removed when forking SavedObject from TrackableObjectGraph.
45  reserved "attributes";
46  reserved 2;
47
48  // Slot variables owned by this object. This describes the three-way
49  // (optimizer, variable, slot variable) relationship; none of the three
50  // depend on the others directly.
51  //
52  // Note: currently only valid if kind == "user_object".
53  repeated TrackableObjectGraph.TrackableObject.SlotVariableReference
54      slot_variables = 3;
55
56  oneof kind {
57    SavedUserObject user_object = 4;
58    SavedAsset asset = 5;
59    SavedFunction function = 6;
60    SavedVariable variable = 7;
61    SavedBareConcreteFunction bare_concrete_function = 8;
62    SavedConstant constant = 9;
63    SavedResource resource = 10;
64  }
65}
66
67// A SavedUserObject is an object (in the object-oriented language of the
68// TensorFlow program) of some user- or framework-defined class other than
69// those handled specifically by the other kinds of SavedObjects.
70//
71// This object cannot be evaluated as a tensor, and therefore cannot be bound
72// to an input of a function.
73message SavedUserObject {
74  // Corresponds to a registration of the type to use in the loading program.
75  string identifier = 1;
76  // Version information from the producer of this SavedUserObject.
77  VersionDef version = 2;
78  // Initialization-related metadata.
79  string metadata = 3;
80}
81
82// A SavedAsset points to an asset in the MetaGraph.
83//
84// When bound to a function this object evaluates to a tensor with the absolute
85// filename. Users should not depend on a particular part of the filename to
86// remain stable (e.g. basename could be changed).
87message SavedAsset {
88  // Index into `MetaGraphDef.asset_file_def[]` that describes the Asset.
89  //
90  // Only the field `AssetFileDef.filename` is used. Other fields, such as
91  // `AssetFileDef.tensor_info`, MUST be ignored.
92  int32 asset_file_def_index = 1;
93}
94
95// A function with multiple signatures, possibly with non-Tensor arguments.
96message SavedFunction {
97  repeated string concrete_functions = 1;
98  FunctionSpec function_spec = 2;
99}
100
101// Stores low-level information about a concrete function. Referenced in either
102// a SavedFunction or a SavedBareConcreteFunction.
103message SavedConcreteFunction {
104  // Bound inputs to the function. The SavedObjects identified by the node ids
105  // given here are appended as extra inputs to the caller-supplied inputs.
106  // The only types of SavedObjects valid here are SavedVariable, SavedResource
107  // and SavedAsset.
108  repeated int32 bound_inputs = 2;
109  // Input in canonicalized form that was received to create this concrete
110  // function.
111  StructuredValue canonicalized_input_signature = 3;
112  // Output that was the return value of this function after replacing all
113  // Tensors with TensorSpecs. This can be an arbitrary nested function and will
114  // be used to reconstruct the full structure from pure tensors.
115  StructuredValue output_signature = 4;
116}
117
118message SavedBareConcreteFunction {
119  // Identifies a SavedConcreteFunction.
120  string concrete_function_name = 1;
121
122  // A sequence of unique strings, one per Tensor argument.
123  repeated string argument_keywords = 2;
124  // The prefix of `argument_keywords` which may be identified by position.
125  int64 allowed_positional_arguments = 3;
126}
127
128message SavedConstant {
129  // An Operation name for a ConstantOp in this SavedObjectGraph's MetaGraph.
130  string operation = 1;
131}
132
133// Represents a Variable that is initialized by loading the contents from the
134// checkpoint.
135message SavedVariable {
136  DataType dtype = 1;
137  TensorShapeProto shape = 2;
138  bool trainable = 3;
139  VariableSynchronization synchronization = 4;
140  VariableAggregation aggregation = 5;
141  string name = 6;
142}
143
144// Represents `FunctionSpec` used in `Function`. This represents a
145// function that has been wrapped as a TensorFlow `Function`.
146message FunctionSpec {
147  // Full arg spec from inspect.getfullargspec().
148  StructuredValue fullargspec = 1;
149  // Whether this represents a class method.
150  bool is_method = 2;
151  // The input signature, if specified.
152  StructuredValue input_signature = 5;
153
154  reserved 3, 4;
155}
156
157// A SavedResource represents a TF object that holds state during its lifetime.
158// An object of this type can have a reference to a:
159// create_resource() and an initialize() function.
160message SavedResource {
161  // A device specification indicating a required placement for the resource
162  // creation function, e.g. "CPU". An empty string allows the user to select a
163  // device.
164  string device = 1;
165}
166