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.

ge_ir.proto 6.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. syntax = "proto3";
  17. package ge.proto;
  18. enum DataType
  19. {
  20. DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set.
  21. DT_FLOAT = 1; // float type
  22. DT_FLOAT16 = 2; // fp16 type
  23. DT_INT8 = 3; // int8 type
  24. DT_UINT8 = 4; // uint8 type
  25. DT_INT16 = 5; // int16 type
  26. DT_UINT16 = 6; // uint16 type
  27. DT_INT32 = 7; //
  28. DT_INT64 = 8; // int64 type
  29. DT_UINT32 = 9; // unsigned int32
  30. DT_UINT64 = 10; // unsigned int64
  31. DT_BOOL = 11; // bool type
  32. DT_DOUBLE = 12; // double type
  33. DT_STRING = 13; // string type
  34. DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */
  35. DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */
  36. DT_COMPLEX64 = 16; // complex64 type
  37. DT_COMPLEX128 = 17; // complex128 type
  38. DT_QINT8 = 18; // qint8 type
  39. DT_QINT16 = 19; // qint16 type
  40. DT_QINT32 = 20; // qint32 type
  41. DT_QUINT8 = 21; // quint8 type
  42. DT_QUINT16 = 22; // quint16 type
  43. DT_RESOURCE = 23; // resource type
  44. DT_STRING_REF = 24; // string_ref type
  45. DT_DUAL = 25; /**< dual output type */
  46. }
  47. message AttrDef
  48. {
  49. message ListValue
  50. {
  51. enum ListValueType{
  52. VT_LIST_NONE = 0;
  53. VT_LIST_STRING = 1;
  54. VT_LIST_INT = 2;
  55. VT_LIST_FLOAT = 3;
  56. VT_LIST_BOOL = 4;
  57. VT_LIST_BYTES = 5;
  58. VT_LIST_TENSOR_DESC = 6;
  59. VT_LIST_TENSOR = 7;
  60. VT_LIST_GRAPH = 8;
  61. VT_LIST_NAMED_ATTRS = 9;
  62. VT_LIST_DATA_TYPE = 10;
  63. }
  64. repeated bytes s = 2; // "list(string)"
  65. repeated int64 i = 3; // "list(int)"
  66. repeated float f = 4; // "list(float)"
  67. repeated bool b = 5; // "list(bool)"
  68. repeated bytes bt = 7;
  69. repeated TensorDescriptor td = 8;
  70. repeated TensorDef t = 9;
  71. repeated GraphDef g = 10;
  72. repeated NamedAttrs na = 11;
  73. repeated int64 dt = 12; // list ge::DataType
  74. ListValueType val_type = 20;
  75. }
  76. message ListListInt{
  77. message ListInt{
  78. repeated int64 list_i = 1; // list int
  79. }
  80. repeated ListInt list_list_i = 1; // list list int
  81. }
  82. oneof value
  83. {
  84. bytes s = 2; // "string"
  85. int64 i = 3; // "int"
  86. float f = 4; // "float"
  87. bool b = 5; // "bool"
  88. bytes bt = 7;
  89. ListValue list = 1; // any "list(...)"
  90. NamedAttrs func = 10; // Used to support attr nesting
  91. TensorDescriptor td = 11; // GeTensorDesc type
  92. TensorDef t = 12; // GeTensor type
  93. GraphDef g = 13; // Graph type
  94. ListListInt list_list_int = 14; // List List Int type
  95. int64 dt = 15; // ge::DataType
  96. }
  97. }
  98. // A list of attr names and their values. The whole list is attached
  99. // with a string name. E.g., MatMul[T=float].
  100. message NamedAttrs
  101. {
  102. string name = 1;
  103. map<string, AttrDef> attr = 2;
  104. }
  105. // Shape / dimension description, using row-major order
  106. message ShapeDef
  107. {
  108. repeated int64 dim = 1; // Size of each dimension
  109. }
  110. // Multidimensional data description
  111. message TensorDescriptor
  112. {
  113. string name = 1; // Optional parameter, tensor name
  114. DataType dtype = 2; // tensor datatype
  115. ShapeDef shape = 3; // Shape / dimension
  116. string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND"
  117. bool has_out_attr = 9;
  118. int64 size = 10;
  119. int64 weight_size = 11;
  120. bool reuse_input = 12;
  121. bool output_tensor = 13;
  122. string device_type = 14;
  123. bool input_tensor =15;
  124. int64 real_dim_cnt = 16;
  125. int64 reuse_input_index = 17;
  126. int64 data_offset = 18;
  127. int64 cmps_size = 19;
  128. string cmps_tab = 20;
  129. int64 cmps_tab_offset = 21;
  130. map<string, AttrDef> attr = 5; // Set of extra parameter fields
  131. }
  132. // GeTensor definition
  133. message TensorDef
  134. {
  135. TensorDescriptor desc = 1; // Tensor description
  136. bytes data = 2; // Tensor data
  137. }
  138. // Operator description
  139. message OpDef
  140. {
  141. string name = 1; // name
  142. string type = 2; // type
  143. repeated string input = 5; // input original op name + outgoing index. op_name:index
  144. map<string, AttrDef> attr = 10; // Set of operator parameter fields
  145. bool has_out_attr = 20;
  146. int64 id = 21;
  147. int64 stream_id =22;
  148. repeated string input_name = 23;
  149. repeated string src_name = 24;
  150. repeated int64 src_index = 25;
  151. repeated string dst_name = 26;
  152. repeated int64 dst_index = 27;
  153. repeated int64 input_i = 28;
  154. repeated int64 output_i = 29;
  155. repeated int64 workspace = 30;
  156. repeated int64 workspace_bytes = 31;
  157. repeated bool is_input_const = 32;
  158. repeated TensorDescriptor input_desc = 33;
  159. repeated TensorDescriptor output_desc = 34;
  160. repeated string subgraph_name = 35;
  161. }
  162. // Graph definition
  163. message GraphDef
  164. {
  165. string name = 1; // name
  166. repeated string input = 4; // Graph input
  167. repeated string output = 5; // Graph output
  168. repeated OpDef op = 6; // List of operators
  169. map<string, AttrDef> attr = 11; // Extended field
  170. }
  171. // model definition
  172. message ModelDef
  173. {
  174. string name = 1; // name
  175. uint32 version = 2; // IR Proto verion
  176. string custom_version = 3; // User model version number, passed in by user
  177. repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef
  178. map<string, AttrDef> attr = 11; // Extended field
  179. }

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