• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto3";
2
3package tensorflow;
4
5import "tensorflow/core/framework/attr_value.proto";
6import "tensorflow/core/framework/full_type.proto";
7import "tensorflow/core/framework/resource_handle.proto";
8import "tensorflow/core/framework/types.proto";
9
10option cc_enable_arenas = true;
11option java_outer_classname = "OpDefProtos";
12option java_multiple_files = true;
13option java_package = "org.tensorflow.framework";
14option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/op_def_go_proto";
15
16// Defines an operation. A NodeDef in a GraphDef specifies an Op by
17// using the "op" field which should match the name of a OpDef.
18// LINT.IfChange
19message OpDef {
20  // Op names starting with an underscore are reserved for internal use.
21  // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9>_]*".
22  string name = 1;
23
24  // For describing inputs and outputs.
25  message ArgDef {
26    // Name for the input/output.  Should match the regexp "[a-z][a-z0-9_]*".
27    string name = 1;
28
29    // Human readable description.
30    string description = 2;
31
32    // Describes the type of one or more tensors that are accepted/produced
33    // by this input/output arg.  The only legal combinations are:
34    // * For a single tensor: either the "type" field is set or the
35    //   "type_attr" field is set to the name of an attr with type "type".
36    // * For a sequence of tensors with the same type: the "number_attr"
37    //   field will be set to the name of an attr with type "int", and
38    //   either the "type" or "type_attr" field will be set as for
39    //   single tensors.
40    // * For a sequence of tensors, the "type_list_attr" field will be set
41    //   to the name of an attr with type "list(type)".
42    DataType type = 3;
43    string type_attr = 4;    // if specified, attr must have type "type"
44    string number_attr = 5;  // if specified, attr must have type "int"
45    // If specified, attr must have type "list(type)", and none of
46    // type, type_attr, and number_attr may be specified.
47    string type_list_attr = 6;
48
49    // The handle data for resource inputs.
50    repeated ResourceHandleProto.DtypeAndShape handle_data = 7;
51
52    // For inputs: if true, the inputs are required to be refs.
53    //   By default, inputs can be either refs or non-refs.
54    // For outputs: if true, outputs are refs, otherwise they are not.
55    bool is_ref = 16;
56
57    // Experimental. Full type declaration for this argument.
58    // The full type specification combines type, type_attr, type_list_attr,
59    // etc. into a unified representation.
60    // This declaration may contain non-concrete types (for example,
61    // Tensor<TypeVar<'T'>> is a valid type declaration.
62    //
63    // Note: this is a transient field. The long-term aim is to represent the
64    // entire OpDef as a single type: a callable. In that context, this field is
65    // just the type of a single argument.
66    FullTypeDef experimental_full_type = 17;
67  }
68
69  // Description of the input(s).
70  repeated ArgDef input_arg = 2;
71
72  // Description of the output(s).
73  repeated ArgDef output_arg = 3;
74
75  // Named control outputs for this operation. Useful only for composite
76  // operations (i.e. functions) which want to name different control outputs.
77  repeated string control_output = 20;
78
79  // Description of the graph-construction-time configuration of this
80  // Op.  That is to say, this describes the attr fields that will
81  // be specified in the NodeDef.
82  message AttrDef {
83    // A descriptive name for the argument.  May be used, e.g. by the
84    // Python client, as a keyword argument name, and so should match
85    // the regexp "[a-z][a-z0-9_]+".
86    string name = 1;
87
88    // One of the type names from attr_value.proto ("string", "list(string)",
89    // "int", etc.).
90    string type = 2;
91
92    // A reasonable default for this attribute if the user does not supply
93    // a value.  If not specified, the user must supply a value.
94    AttrValue default_value = 3;
95
96    // Human-readable description.
97    string description = 4;
98
99    // TODO(josh11b): bool is_optional?
100
101    // --- Constraints ---
102    // These constraints are only in effect if specified.  Default is no
103    // constraints.
104
105    // For type == "int", this is a minimum value.  For "list(___)"
106    // types, this is the minimum length.
107    bool has_minimum = 5;
108    int64 minimum = 6;
109
110    // The set of allowed values.  Has type that is the "list" version
111    // of the "type" field above (uses the "list" field of AttrValue).
112    // If type == "type" or "list(type)" above, then the "type" field
113    // of "allowed_values.list" has the set of allowed DataTypes.
114    // If type == "string" or "list(string)", then the "s" field of
115    // "allowed_values.list" has the set of allowed strings.
116    AttrValue allowed_values = 7;
117  }
118  repeated AttrDef attr = 4;
119
120  // Optional deprecation based on GraphDef versions.
121  OpDeprecation deprecation = 8;
122
123  // One-line human-readable description of what the Op does.
124  string summary = 5;
125
126  // Additional, longer human-readable description of what the Op does.
127  string description = 6;
128
129  // -------------------------------------------------------------------------
130  // Which optimizations this operation can participate in.
131
132  // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs)
133  bool is_commutative = 18;
134
135  // If is_aggregate is true, then this operation accepts N >= 2
136  // inputs and produces 1 output all of the same type.  Should be
137  // associative and commutative, and produce output with the same
138  // shape as the input.  The optimizer may replace an aggregate op
139  // taking input from multiple devices with a tree of aggregate ops
140  // that aggregate locally within each device (and possibly within
141  // groups of nearby devices) before communicating.
142  // TODO(josh11b): Implement that optimization.
143  bool is_aggregate = 16;  // for things like add
144
145  // Other optimizations go here, like
146  //   can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc.
147
148  // -------------------------------------------------------------------------
149  // Optimization constraints.
150
151  // Ops are marked as stateful if their behavior depends on some state beyond
152  // their input tensors (e.g. variable reading op) or if they have
153  // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops
154  // must always produce the same output for the same input and have
155  // no side-effects.
156  //
157  // By default Ops may be moved between devices.  Stateful ops should
158  // either not be moved, or should only be moved if that state can also
159  // be moved (e.g. via some sort of save / restore).
160  // Stateful ops are guaranteed to never be optimized away by Common
161  // Subexpression Elimination (CSE).
162  bool is_stateful = 17;  // for things like variables, queue
163
164  // -------------------------------------------------------------------------
165  // Non-standard options.
166
167  // By default, all inputs to an Op must be initialized Tensors.  Ops
168  // that may initialize tensors for the first time should set this
169  // field to true, to allow the Op to take an uninitialized Tensor as
170  // input.
171  bool allows_uninitialized_input = 19;  // for Assign, etc.
172
173  // Indicates whether the op implementation uses distributed communication.
174  // If True, the op is allowed to return errors for network disconnection and
175  // trigger TF network failure handling logics.
176  bool is_distributed_communication = 21;
177}
178// LINT.ThenChange(
179//     https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc)
180
181// Information about version-dependent deprecation of an op
182message OpDeprecation {
183  // First GraphDef version at which the op is disallowed.
184  int32 version = 1;
185
186  // Explanation of why it was deprecated and what to use instead.
187  string explanation = 2;
188}
189
190// A collection of OpDefs
191message OpList {
192  repeated OpDef op = 1;
193}
194