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.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. syntax = "proto3";
  2. package domi.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. // LINT.IfChange
  12. message OpDef {
  13. // Op names starting with an underscore are reserved for internal use.
  14. // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9_]*".
  15. string name = 1;
  16. // For describing inputs and outputs.
  17. message ArgDef {
  18. // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*".
  19. string name = 1;
  20. // Human readable description.
  21. string description = 2;
  22. // Describes the type of one or more tensors that are accepted/produced
  23. // by this input/output arg. The only legal combinations are:
  24. // * For a single tensor: either the "type" field is set or the
  25. // "type_attr" field is set to the name of an attr with type "type".
  26. // * For a sequence of tensors with the same type: the "number_attr"
  27. // field will be set to the name of an attr with type "int", and
  28. // either the "type" or "type_attr" field will be set as for
  29. // single tensors.
  30. // * For a sequence of tensors, the "type_list_attr" field will be set
  31. // to the name of an attr with type "list(type)".
  32. DataType type = 3;
  33. string type_attr = 4; // if specified, attr must have type "type"
  34. string number_attr = 5; // if specified, attr must have type "int"
  35. // If specified, attr must have type "list(type)", and none of
  36. // type, type_attr, and number_attr may be specified.
  37. string type_list_attr = 6;
  38. // For inputs: if true, the inputs are required to be refs.
  39. // By default, inputs can be either refs or non-refs.
  40. // For outputs: if true, outputs are refs, otherwise they are not.
  41. bool is_ref = 16;
  42. };
  43. // Description of the input(s).
  44. repeated ArgDef input_arg = 2;
  45. // Description of the output(s).
  46. repeated ArgDef output_arg = 3;
  47. // Description of the graph-construction-time configuration of this
  48. // Op. That is to say, this describes the attr fields that will
  49. // be specified in the NodeDef.
  50. message AttrDef {
  51. // A descriptive name for the argument. May be used, e.g. by the
  52. // Python client, as a keyword argument name, and so should match
  53. // the regexp "[a-z][a-z0-9_]+".
  54. string name = 1;
  55. // One of the type names from attr_value.proto ("string", "list(string)",
  56. // "int", etc.).
  57. string type = 2;
  58. // A reasonable default for this attribute if the user does not supply
  59. // a value. If not specified, the user must supply a value.
  60. AttrValue default_value = 3;
  61. // Human-readable description.
  62. string description = 4;
  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. bool is_aggregate = 16; // for things like add
  97. // Other optimizations go here, like
  98. // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc.
  99. // -------------------------------------------------------------------------
  100. // Optimization constraints.
  101. // Ops are marked as stateful if their behavior depends on some state beyond
  102. // their input tensors (e.g. variable reading op) or if they have
  103. // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops
  104. // must always produce the same output for the same input and have
  105. // no side-effects.
  106. //
  107. // By default Ops may be moved between devices. Stateful ops should
  108. // either not be moved, or should only be moved if that state can also
  109. // be moved (e.g. via some sort of save / restore).
  110. // Stateful ops are guaranteed to never be optimized away by Common
  111. // Subexpression Elimination (CSE).
  112. bool is_stateful = 17; // for things like variables, queue
  113. // -------------------------------------------------------------------------
  114. // Non-standard options.
  115. // By default, all inputs to an Op must be initialized Tensors. Ops
  116. // that may initialize tensors for the first time should set this
  117. // field to true, to allow the Op to take an uninitialized Tensor as
  118. // input.
  119. bool allows_uninitialized_input = 19; // for Assign, etc.
  120. };
  121. // LINT.ThenChange(
  122. // https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc)
  123. // Information about version-dependent deprecation of an op
  124. message OpDeprecation {
  125. // First GraphDef version at which the op is disallowed.
  126. int32 version = 1;
  127. // Explanation of why it was deprecated and what to use instead.
  128. string explanation = 2;
  129. };
  130. // A collection of OpDefs
  131. message OpList {
  132. repeated OpDef op = 1;
  133. };

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示