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"; 8 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 // Description of the graph-construction-time configuration of this 58 // Op. That is to say, this describes the attr fields that will 59 // be specified in the NodeDef. 60 message AttrDef { 61 // A descriptive name for the argument. May be used, e.g. by the 62 // Python client, as a keyword argument name, and so should match 63 // the regexp "[a-z][a-z0-9_]+". 64 string name = 1; 65 66 // One of the type names from attr_value.proto ("string", "list(string)", 67 // "int", etc.). 68 string type = 2; 69 70 // A reasonable default for this attribute if the user does not supply 71 // a value. If not specified, the user must supply a value. 72 AttrValue default_value = 3; 73 74 // Human-readable description. 75 string description = 4; 76 77 // TODO(josh11b): bool is_optional? 78 79 // --- Constraints --- 80 // These constraints are only in effect if specified. Default is no 81 // constraints. 82 83 // For type == "int", this is a minimum value. For "list(___)" 84 // types, this is the minimum length. 85 bool has_minimum = 5; 86 int64 minimum = 6; 87 88 // The set of allowed values. Has type that is the "list" version 89 // of the "type" field above (uses the "list" field of AttrValue). 90 // If type == "type" or "list(type)" above, then the "type" field 91 // of "allowed_values.list" has the set of allowed DataTypes. 92 // If type == "string" or "list(string)", then the "s" field of 93 // "allowed_values.list" has the set of allowed strings. 94 AttrValue allowed_values = 7; 95 } 96 repeated AttrDef attr = 4; 97 98 // Optional deprecation based on GraphDef versions. 99 OpDeprecation deprecation = 8; 100 101 // One-line human-readable description of what the Op does. 102 string summary = 5; 103 104 // Additional, longer human-readable description of what the Op does. 105 string description = 6; 106 107 // ------------------------------------------------------------------------- 108 // Which optimizations this operation can participate in. 109 110 // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) 111 bool is_commutative = 18; 112 113 // If is_aggregate is true, then this operation accepts N >= 2 114 // inputs and produces 1 output all of the same type. Should be 115 // associative and commutative, and produce output with the same 116 // shape as the input. The optimizer may replace an aggregate op 117 // taking input from multiple devices with a tree of aggregate ops 118 // that aggregate locally within each device (and possibly within 119 // groups of nearby devices) before communicating. 120 // TODO(josh11b): Implement that optimization. 121 bool is_aggregate = 16; // for things like add 122 123 // Other optimizations go here, like 124 // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. 125 126 // ------------------------------------------------------------------------- 127 // Optimization constraints. 128 129 // By default Ops may be moved between devices. Stateful ops should 130 // either not be moved, or should only be moved if that state can also 131 // be moved (e.g. via some sort of save / restore). 132 // Stateful ops are guaranteed to never be optimized away by Common 133 // Subexpression Elimination (CSE). 134 bool is_stateful = 17; // for things like variables, queue 135 136 // ------------------------------------------------------------------------- 137 // Non-standard options. 138 139 // By default, all inputs to an Op must be initialized Tensors. Ops 140 // that may initialize tensors for the first time should set this 141 // field to true, to allow the Op to take an uninitialized Tensor as 142 // input. 143 bool allows_uninitialized_input = 19; // for Assign, etc. 144}; 145// LINT.ThenChange( 146// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) 147 148// Information about version-dependent deprecation of an op 149message OpDeprecation { 150 // First GraphDef version at which the op is disallowed. 151 int32 version = 1; 152 153 // Explanation of why it was deprecated and what to use instead. 154 string explanation = 2; 155}; 156 157// A collection of OpDefs 158message OpList { 159 repeated OpDef op = 1; 160}; 161