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