You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

op_def.proto 6.1 kB

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