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