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.

transformation_ops.h 36 kB

5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. /**
  2. * Copyright 2019 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. /*!
  17. * \file transformation_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief This operation convert output dataType and shape
  26. *@par Inputs:
  27. *The input handle must have the resource type. Inputs include:
  28. *@li x:A list of Tensor objects. One or more tensors from which
  29. the enqueued tensors should be taken . \n
  30. *@par Outputs:
  31. *@li y:A list of Tensor objects. One or more tensors from which
  32. the enqueued tensors should be taken . \n
  33. *@par Attributes:
  34. *@li type: An optional ge::DataType. It refers to the target data type of outputs . \n
  35. *@par Third-party framework compatibility
  36. *Compatible with tensorflow QueueIsClosed operator.
  37. */
  38. REG_OP(Bitcast)
  39. .INPUT(x, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT32, DT_UINT8,
  40. DT_INT64, DT_UINT64, DT_INT16, DT_UINT16, DT_DOUBLE, DT_COMPLEX64,
  41. DT_COMPLEX128, DT_QINT8, DT_QUINT8, DT_QINT16, DT_QUINT16, DT_QINT32}))
  42. .OUTPUT(y, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT32, DT_UINT8,
  43. DT_INT64, DT_UINT64, DT_INT16, DT_UINT16, DT_DOUBLE, DT_COMPLEX64,
  44. DT_COMPLEX128, DT_QINT8, DT_QUINT8, DT_QINT16, DT_QUINT16, DT_QINT32}))
  45. .REQUIRED_ATTR(type, Type)
  46. .OP_END_FACTORY_REG(Bitcast)
  47. /**
  48. *@brief Convert tensor format from HWCN to C1HWNCoC0 . \n
  49. *@par Inputs:
  50. *x: A Tensor. Must be 4D Tensor of type float16, float32, int32, uint16, with format HWCN . \n
  51. *@par Outputs:
  52. *y: A 6D Tensor. Has the same type as "x", with format C1HWNCoC0.
  53. */
  54. REG_OP(DepthwiseWeight4DTo6D)
  55. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_UINT16}))
  56. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_UINT16}))
  57. .OP_END_FACTORY_REG(DepthwiseWeight4DTo6D)
  58. /**
  59. *@brief Convert tensor format from C1HWNCoC0 to HWCN . \n
  60. *@par Inputs:
  61. *x: A Tensor. Must be 6D Tensor of type float16, float32, int32, uint16, with format C1HWNCoC0 . \n
  62. *@par Attributes:
  63. *channel_size: An optional int, specifying the channel size of 4D Tensor with format HWCN . \n
  64. *@par Outputs:
  65. *y: A 4D Tensor. Has the same type as "x", with format HWCN.
  66. */
  67. REG_OP(DepthwiseWeight6DTo4D)
  68. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_UINT16}))
  69. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_UINT16}))
  70. .ATTR(channel_size, Int, 16)
  71. .OP_END_FACTORY_REG(DepthwiseWeight6DTo4D)
  72. /**
  73. *@brief Permutes the dimensions according to perm.
  74. The returned tensor's dimension i will correspond to the input dimension perm[i] . \n
  75. *@par Inputs:
  76. *x: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64 . \n
  77. *@par Attributes:
  78. *perm: A permutation of the dimensions of "x" . \n
  79. *@par Outputs:
  80. *y: A Tensor. Has the same type as "x".
  81. *@par Restrictions:
  82. *Warning: THIS FUNCTION IS DEPRECATED. Please use Transpose instead.
  83. */
  84. REG_OP(TransposeD)
  85. .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  86. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT16, DT_FLOAT}))
  87. .OUTPUT(y, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  88. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT16, DT_FLOAT}))
  89. .REQUIRED_ATTR(perm, ListInt)
  90. .OP_END_FACTORY_REG(TransposeD)
  91. /**
  92. *@brief Permutes the dimensions according to perm.
  93. The returned tensor's dimension i will correspond to the input dimension perm[i] . \n
  94. *@par Inputs:
  95. *Two inputs, including:
  96. *@li x: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64.
  97. *@li perm: A Tensor of type int32 or int64. A permutation of the dimensions of "x" . \n
  98. *@par Outputs:
  99. *y: A Tensor. Has the same type as "x" . \n
  100. *@par Third-party framework compatibility
  101. *Compatible with the TensorFlow operator Transpose.
  102. */
  103. REG_OP(Transpose)
  104. .INPUT(x, TensorType::BasicType())
  105. .INPUT(perm, TensorType::IndexNumberType())
  106. .OUTPUT(y, TensorType::BasicType())
  107. .OP_END_FACTORY_REG(Transpose)
  108. /**
  109. *@brief Do format transfer for various data format.
  110. * In general, the framework will insert it atomatically . \n
  111. *@par Inputs:
  112. *src: A Tensor. For all branches can be types: float16, float32, int32, int8, bool.
  113. * For branches without padding also can be types: int16, int64, uint8, uint16, uint32, uint64 . \n
  114. *@par Attributes:
  115. *@li src_format: A string source data format, can be "NHWC", "NCHW", "FRACTAL_Z" etc.
  116. *@li dst_format: A string target data format, can be "NC1HWC0", "NCHW", "FRACTAL_Z" etc.
  117. *@li group: A optional int32, default value is 1. \n
  118. *@par Outputs:
  119. *dst: A Tensor. Has the same type as "src".
  120. */
  121. REG_OP(TransData)
  122. .INPUT(src, TensorType::BasicType())
  123. .OUTPUT(dst, TensorType::BasicType())
  124. .REQUIRED_ATTR(src_format, String)
  125. .REQUIRED_ATTR(dst_format, String)
  126. .ATTR(groups, Int, 1)
  127. .OP_END_FACTORY_REG(TransData)
  128. /**
  129. *@brief Permutes the dimensions according to order.
  130. The returned tensor's dimension i will correspond to the input dimension order[i] . \n
  131. *@par Inputs:
  132. *x: A Tensor. Must be one of the following types: float16, float32 . \n
  133. *@par Attributes:
  134. *order: A permutation of the dimensions of "x".Type is int32.support any axis transformation.Defaults to "{0}"
  135. *@par Outputs:
  136. *y: A Tensor. Has the same type as "x".
  137. */
  138. REG_OP(Permute)
  139. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  140. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  141. .ATTR(order, ListInt, {0})
  142. .OP_END_FACTORY_REG(Permute)
  143. /**
  144. *@brief Flattens the inputs tensor into a 2D matrix. If input tensor has shape (d_0, d_1,..., d_n),
  145. * then the output will have shape (d_0 X d_1 ... d_(axis-1), d_axis X d_(axis + 1)...X d_n)\n
  146. *@par Inputs:
  147. * One input:
  148. * x: A multi-dimensional Tensor. Must be one of the following types:
  149. * int8, uint8, int16, uint16, int32, uint32, int64,uint64, float16, float32.
  150. *@par Outputs:
  151. * y: A 2D flattened Tensor with the contents of the input tensor, with input dimensions up to axis flattened
  152. * to the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.
  153. * Must be one of the following data types: int8, uint8, int16, uint16, int32, uint32, int64,uint64, float16, float32 .
  154. *@par Attributes:
  155. * axis: A optional int32, default value is 1. Indicate up to which input dimensions (exclusive) should be flattened
  156. * to the outer dimension of the output. The value for axis must be in the range [-r, r], where r is the rank of
  157. * the input tensor. Negative value means counting dimensions from the back. When axis = 0, the shape of
  158. * the output tensor is (1, (d_0 X d_1 ... d_n), where the shape of the input tensor is (d_0, d_1, ... d_n).
  159. *@par Third-party framework compatibility
  160. * Compatible with TensorFlow / ONNX operator Flatten.
  161. */
  162. REG_OP(Flatten)
  163. .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64,
  164. DT_UINT8, DT_UINT16, DT_UINT32, DT_UINT64,
  165. DT_FLOAT, DT_FLOAT16}))
  166. .OUTPUT(y, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64,
  167. DT_UINT8, DT_UINT16, DT_UINT32, DT_UINT64,
  168. DT_FLOAT, DT_FLOAT16}))
  169. .ATTR(axis, Int, 1)
  170. .OP_END_FACTORY_REG(Flatten)
  171. /**
  172. *@brief Permutes and crops the input tensor . \n
  173. *@par Inputs:
  174. * Three inputs, including:
  175. *@li x: A 5D Tensor of type float16 or int8 or uint8, with format NC1HWC0.
  176. *@li block_shape: A 1D list or tuple of int32 or int64.
  177. *@li crops: A 2D list or tuple of int32 or int64. Specifies the amount to
  178. *crop from start and end dimensions after permutation . \n
  179. *@par Outputs:
  180. *y: A Tensor with format NC1HWC0. Has the same type as input "x" . \n
  181. *@par Third-party framework compatibility
  182. * Compatible with the TensorFlow operator BatchToSpaceND.
  183. */
  184. REG_OP(BatchToSpaceND)
  185. .INPUT(x, TensorType::BasicType())
  186. .INPUT(block_shape, TensorType::IndexNumberType())
  187. .INPUT(crops, TensorType::IndexNumberType())
  188. .OUTPUT(y, TensorType::BasicType())
  189. .OP_END_FACTORY_REG(BatchToSpaceND)
  190. /**
  191. *@brief Permutes and crops the input tensor . \n
  192. *@par Inputs:
  193. * One input:
  194. *x: A 5D Tensor of type float16 or int8 or uint8, with format NC1HWC0 . \n
  195. *@par Attributes:
  196. *@li block_shape: A required 1D list or tuple of int32 or int64.
  197. *@li crops: A required 2D list or tuple of int32 or int64. Specifies the amount to crop
  198. * from the start and end dimensions after permutation . \n
  199. *@par Outputs:
  200. *y: A Tensor with format NC1HWC0. Has the same type as input "x".
  201. *@par Third-party framework compatibility
  202. * Compatible with the TensorFlow operator BatchToSpaceND.
  203. *
  204. * @par Restrictions:
  205. * Warning: THIS FUNCTION IS DEPRECATED. Please use BatchToSpaceND instead.
  206. */
  207. REG_OP(BatchToSpaceNDD)
  208. .INPUT(x, TensorType::BasicType())
  209. .OUTPUT(y, TensorType::BasicType())
  210. .REQUIRED_ATTR(block_shape, ListInt)
  211. .REQUIRED_ATTR(crops, ListInt)
  212. .OP_END_FACTORY_REG(BatchToSpaceNDD)
  213. /**
  214. *@brief Pads and permutes the input tensor . \n
  215. *@par Inputs:
  216. * Three inputs, including:
  217. *@li x: A 5D Tensor of type float16 or float32, with format NC1HWC0.
  218. *@li block_shape: A 1D list or tuple of int32 or int64.
  219. *@li paddings: A 2D list or tuple of int32 or int64. Specifies the padding for the start and end dimensions after permutation . \n
  220. *@par Outputs:
  221. *y: A Tensor with format NC1HWC0. Has the same type as input "x" . \n
  222. *@par Third-party framework compatibility
  223. * Compatible with the TensorFlow operator SpaceToBatchND.
  224. */
  225. REG_OP(SpaceToBatchND)
  226. .INPUT(x, TensorType::BasicType())
  227. .INPUT(block_shape, TensorType::IndexNumberType())
  228. .INPUT(paddings, TensorType::IndexNumberType())
  229. .OUTPUT(y, TensorType::BasicType())
  230. .OP_END_FACTORY_REG(SpaceToBatchND)
  231. /**
  232. *@brief Pads and permutes the input tensor . \n
  233. *@par Inputs:
  234. * One input:
  235. *x: A 5D Tensor of type float16 or float32, with format NC1HWC0 . \n
  236. *@par Attributes:
  237. *@li block_shape: A required 1D list or tuple of int32 or int64.
  238. *@li paddings: A required 2D list or tuple of int32 or int64. Specifies the padding for the start and end dimensions after permutation . \n
  239. *@par Outputs:
  240. *y: A Tensor with format NC1HWC0. Has the same type as input "x" . \n
  241. *@par Third-party framework compatibility
  242. * Compatible with the TensorFlow operator SpaceToBatchND.
  243. *
  244. * @par Restrictions:
  245. * Warning: THIS FUNCTION IS DEPRECATED. Please use SpaceToBatchND instead.
  246. */
  247. REG_OP(SpaceToBatchNDD)
  248. .INPUT(x, TensorType::BasicType())
  249. .OUTPUT(y, TensorType::BasicType())
  250. .REQUIRED_ATTR(block_shape, ListInt)
  251. .REQUIRED_ATTR(paddings, ListInt)
  252. .OP_END_FACTORY_REG(SpaceToBatchNDD)
  253. /**
  254. *@brief Outputs a copy of the input tensor where values from the "height" and
  255. * "width" dimensions are moved to the "depth" dimension . \n
  256. *@par Inputs:
  257. *x: An NHWC Tensor. Must be one of the following types:
  258. * float16, float32, double, int64, int32, uint8, uint16, uint32, uint64, int8,
  259. * int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32.
  260. *@par Attributes:
  261. *@li block_size: A required int, specifying the input block size.
  262. *@li data_format: An optional string, specifying the data format. Defaults to
  263. * "NHWC" . \n
  264. *@par Outputs:
  265. *y: A Tensor. Has the same type as input "x".
  266. *@par Third-party framework compatibility
  267. * Compatible with the TensorFlow operator SpaceToDepth.
  268. */
  269. REG_OP(SpaceToDepth)
  270. .INPUT(x, TensorType::BasicType())
  271. .OUTPUT(y, TensorType::BasicType())
  272. .REQUIRED_ATTR(block_size, Int)
  273. .ATTR(data_format, String, "NHWC")
  274. .OP_END_FACTORY_REG(SpaceToDepth)
  275. /**
  276. *@brief Rearranges data from depth into blocks of spatial data . \n
  277. *@par Inputs:
  278. *x: A Tensor. Must be one of the following types: float16, float32, double, int32, uint8,
  279. * int16, int8, complex64, int64, qint8, quint8, qint32, qint16, quint16, uint16,
  280. * complex128, uint32, uint64
  281. *@par Attributes:
  282. *Two attributes, including:
  283. * @li block_size: An int >= 2, specifying the size of the spatial block.
  284. * @li data_format: An optional string, specifying the data format. Defaults to "NHWC" . \n
  285. *@par Outputs:
  286. *y: A Tensor of the same type as "x" . \n
  287. *@par Third-party framework compatibility:
  288. * Compatible with TensorFlow operator DepthToSpace.
  289. */
  290. REG_OP(DepthToSpace)
  291. .INPUT(x, TensorType::BasicType())
  292. .OUTPUT(y, TensorType::BasicType())
  293. .REQUIRED_ATTR(block_size, Int)
  294. .ATTR(data_format, String, "NHWC")
  295. .OP_END_FACTORY_REG(DepthToSpace)
  296. /**
  297. *@brief Permutes data into spatial data blocks and then prunes them . \n
  298. *@par Inputs:
  299. *@li x: A 4D Tensor with format. Must set the format, supported format list ["NCHW, NHWC"]
  300. *@li crops: A 1D list or tuple of int32 or int64 . \n
  301. *Must be one of the following types: float16, float32
  302. *@par Attributes:
  303. *block_size: A required int8, int16, int32, or int64. No default value . \n
  304. *@par Outputs:
  305. *y: A 4D Tensor with format NHWC,
  306. * of type float16 or float32 . \n
  307. *@attention Constraints:
  308. *@li The size of the first dimension of input "x" must be divisible by (block_size * block_size).
  309. *@li "crops" is a 4Dshape [batch, height, width, depth], height = height_pad - crop_top - crop_bottom,
  310. *width = width_pad - crop_left - crop_right.
  311. *@li block_size > 2
  312. *@par Third-party framework compatibility
  313. * Compatible with the TensorFlow operator BatchToSpace.
  314. */
  315. REG_OP(BatchToSpace)
  316. .INPUT(x, TensorType::BasicType())
  317. .INPUT(crops, TensorType::IndexNumberType())
  318. .OUTPUT(y, TensorType::BasicType())
  319. .REQUIRED_ATTR(block_size, Int)
  320. .OP_END_FACTORY_REG(BatchToSpace)
  321. /**
  322. *@brief Rearrange the batch (permutes) data into spatial data blocks, and then crop them . \n
  323. *@par Inputs:
  324. * One input:
  325. *x: An Tensor of shape [batch*block_size*block_size, height_pad/block_size, width_pad/block_size, depth].
  326. *The batch size of the input tensor must be divisible by (block size * block size).
  327. *Must be one of the following types: float16, float32, double, int64, int32, uint8, uint16, uint32, uint64,
  328. *int8, int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32 . \n
  329. *@par Attributes:
  330. *@li block_size: Must be one of the following types: `int32`, `int64`.
  331. *@li crops: An Tensor. Must be one of the following types: int32, Int64.
  332. *2D tensor with non negative integer of shape [2, 2]. It specifies how many
  333. *elements are clipped from the intermediate result of spatial dimension . \n
  334. *@par Outputs:
  335. *y: A Tensor. Has the same type and format as input "x" . \n
  336. *@attention Constraints:
  337. *@li The size of the first dimension of input "x" must be divisible by (block_size * block_size).
  338. *@li "crops" is a 2D tensor of non-negative integers with shape (2, 2).
  339. *@li block_size > 2
  340. *@par Third-party framework compatibility
  341. * Compatible with the TensorFlow operator BatchToSpace.
  342. *
  343. * @par Restrictions:
  344. * Warning: THIS FUNCTION IS DEPRECATED. Please use BatchToSpace instead.
  345. */
  346. REG_OP(BatchToSpaceD)
  347. .INPUT(x, TensorType::BasicType())
  348. .OUTPUT(y, TensorType::BasicType())
  349. .REQUIRED_ATTR(block_size, Int)
  350. .REQUIRED_ATTR(crops, ListInt)
  351. .OP_END_FACTORY_REG(BatchToSpaceD)
  352. /**
  353. *@brief Outputs a copy of the input tensor where values from the "height" and
  354. * "width" dimensions are padded and rearranged to the "batch" dimension . \n
  355. *@par Inputs:
  356. * Two inputs, including:
  357. *@li x: An 4D Tensor. Must be one of the following types:
  358. * float16, float32, double, int64, int32, uint8, uint16, uint32, uint64, int8,
  359. * int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32.
  360. * Must set the format, supported format list ["NCHW, NHWC"]
  361. *@li paddings: A 2D tensor of type int, specifying the input . \n
  362. *@par Attributes:
  363. *block_size: A required int, specifying the input block size . \n
  364. *@par Outputs:
  365. *y: A Tensor. Has the same type as input "x".
  366. *@par Third-party framework compatibility
  367. * Compatible with the TensorFlow operator SpaceToBatch.
  368. */
  369. REG_OP(SpaceToBatch)
  370. .INPUT(x, TensorType::BasicType())
  371. .INPUT(paddings, TensorType::IndexNumberType())
  372. .OUTPUT(y, TensorType::BasicType())
  373. .REQUIRED_ATTR(block_size, Int)
  374. .OP_END_FACTORY_REG(SpaceToBatch)
  375. /**
  376. *@brief Outputs a copy of the input tensor where values from the "height" and "width" dimensions are padded and rearranged to the "batch" dimension . \n
  377. *@par Inputs:
  378. *x: An NHWC Tensor. Must be one of the following types: float16, float32, double, int64, int32, uint8, uint16, uint32, uint64, int8, int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32.
  379. *@par Attributes:
  380. *@li block_size: A required int, specifying the input block size.
  381. *@li paddings: A 2D tensor. All data types are supported . \n
  382. *@par Outputs:
  383. *y: A Tensor. Has the same type as input "x".
  384. *@par Third-party framework compatibility
  385. *@ Compatible with the TensorFlow operator SpaceToBatch.
  386. *
  387. * @par Restrictions:
  388. * Warning: THIS FUNCTION IS DEPRECATED. Please use SpaceToBatch instead.
  389. */
  390. REG_OP(SpaceToBatchD)
  391. .INPUT(x, TensorType::BasicType())
  392. .OUTPUT(y, TensorType::BasicType())
  393. .REQUIRED_ATTR(block_size, Int)
  394. .REQUIRED_ATTR(paddings, ListInt)
  395. .OP_END_FACTORY_REG(SpaceToBatchD)
  396. /**
  397. * @brief Unpacks the given dimension of a rank-R Tensor "x" into rank-(R-1)
  398. * tensors . \n
  399. * @par Inputs:
  400. * x: A rank-R tensor (R > 0) of type BasicType, with format ND or NC1HWC0 . \n
  401. * @par Attributes:
  402. * @li num: A required int, specifying the number of tensors to be unpacked to.
  403. * Defaults to "None".
  404. * @li axis: An optional int, specifying the axis to unpack along. The value range
  405. * is [-R, R) . \n
  406. * @par Outputs:
  407. * y: Dynamic output. The list of Tensor objects unpacked from "x", of type BasicType . \n
  408. * @attention Constraints:
  409. * @li If "num" is not specified, it is inferred from the shape of "x".
  410. * @li For the ND format, "axis" is in the range [-R, R); For the NC1HWC0 format,
  411. * "axis" must not be 2, 3, -2, or -3 . \n
  412. * @par Third-party framework compatibility
  413. * Compatible with the TensorFlow operator Unpack.
  414. */
  415. REG_OP(Unpack)
  416. .INPUT(x, TensorType::BasicType())
  417. .DYNAMIC_OUTPUT(y, TensorType::BasicType())
  418. .REQUIRED_ATTR(num, Int)
  419. .ATTR(axis, Int, 0)
  420. .OP_END_FACTORY_REG(Unpack)
  421. /**
  422. * @brief Extract "patches" from "images" and stacks them in the "depth"
  423. * dimension of the output . \n
  424. * @par Inputs:
  425. * x: A 4D Tensor with shape [batch, in_rows, in_cols, depth], Must be one of the
  426. * following types:float32, double, int32, uint8, int16, int8, int64, uint16,
  427. * float16, uint32, uint64. The inputs must have data_format with one of follows:
  428. * NHWC, NCHW.
  429. * @par Attributes:
  430. * @li ksizes: A required list or tuple. The size of the sliding window for each
  431. * dimension of images.
  432. * @li strides: A required list or tuple. How far the centers of two consecutive
  433. * patches are in the images. Must be: [1, stride_rows, stride_cols, 1].
  434. * @li rates: A required list or tuple. Must be: [1, rate_rows, rate_cols, 1].
  435. * This is the input stride, specifying how far two consecutive patch
  436. * samples are in the input. Equivalent to extracting patches
  437. * with patch_sizes_eff = patch_sizes + (patch_sizes - 1) *
  438. * (rates - 1), followed by subsampling them spatially by a factor of rates.
  439. * This is equivalent to rate in dilated (a.k.a. Atrous) convolutions.
  440. * @li padding: A required string. The type of padding algorithm to use,
  441. support "SAME" or "VALID". \n
  442. * @par Outputs:
  443. * y: A 4D Tensor with shape [batch, out_rows, out_cols, ksize_rows *
  444. * ksize_cols * depth] containing image patches with size ksize_rows x ksize_cols
  445. * x depth vectorized in the "depth" dimension. Note "out_rows" and "out_cols"
  446. * are the dimensions of the output patches . \n
  447. * @attention Constraints:
  448. * "ksizes", "strides" and "rates" are lists of integers . \n
  449. * @par Third-party framework compatibility
  450. * Compatible with the TensorFlow operator ExtractImagePatches.
  451. */
  452. REG_OP(ExtractImagePatches)
  453. .INPUT(x, TensorType::RealNumberType())
  454. .OUTPUT(y, TensorType::RealNumberType())
  455. .REQUIRED_ATTR(ksizes, ListInt)
  456. .REQUIRED_ATTR(strides, ListInt)
  457. .REQUIRED_ATTR(rates, ListInt)
  458. .REQUIRED_ATTR(padding, String)
  459. .OP_END_FACTORY_REG(ExtractImagePatches)
  460. /**
  461. * @brief Extract "patches" from "input" and put them in the "depth"
  462. * dimension of the output . \n
  463. * @par Inputs:
  464. * x: A 5D Tensor with shape [batch, in_planes, in_rows, in_cols, depth] . \n
  465. * The inputs must have data_format with one of follows: NDHWC, NCDHW. \n
  466. * @par Attributes:
  467. * @li ksizes: A required list or tuple. The size of the sliding window for each
  468. * dimension of "x".
  469. * @li strides: A required list or tuple. How far the centers of two consecutive
  470. * patches are in "x". Must be: [1, stride_planes, stride_rows, stride_cols, 1].
  471. * @li padding: A required string. The type of padding algorithm to use ,
  472. * support "SAME" or "VALID" . \n
  473. * @par Outputs:
  474. * Output: A 5D Tensor with shape [batch, out_planes, out_rows, out_cols, ksize_planes *
  475. * ksize_rows * ksize_cols * depth] containing patches with size (ksize_rows * ksize_cols
  476. * * depth) vectorized in the "depth" dimension. Note "out_planes", "out_rows" and "out_cols"
  477. * are the dimensions of the output patches . \n
  478. * @attention Constraints:
  479. * "ksizes" and "strides" are lists of integers.
  480. * @par Third-party framework compatibility
  481. * Compatible with the TensorFlow operator ExtractVolumePatches.
  482. */
  483. REG_OP(ExtractVolumePatches)
  484. .INPUT(x, TensorType::REALNUMBERTYPE())
  485. .OUTPUT(y, TensorType::REALNUMBERTYPE())
  486. .REQUIRED_ATTR(ksizes, ListInt)
  487. .REQUIRED_ATTR(strides, ListInt)
  488. .REQUIRED_ATTR(padding, String)
  489. .OP_END_FACTORY_REG(ExtractVolumePatches)
  490. /**
  491. *@brief Confuse reshape and transpose . \n
  492. *@par Inputs:
  493. *x: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64 . \n
  494. *@par Attributes:
  495. *@li perm: A permutation of the dimensions of "x".
  496. *@li shape: The shape of the input.
  497. *@li transpose_first: If True, the transpose is first, otherwise the reshape is first . \n
  498. *@par Outputs:
  499. *y: A Tensor. Has the same type as "x".
  500. *
  501. * @par Restrictions:
  502. * Warning: THIS FUNCTION IS DEPRECATED. Please use ConfusionTranspose instead.
  503. */
  504. REG_OP(ConfusionTransposeD)
  505. .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  506. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT16, DT_FLOAT}))
  507. .OUTPUT(y, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  508. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT16, DT_FLOAT}))
  509. .REQUIRED_ATTR(perm, ListInt)
  510. .REQUIRED_ATTR(shape, ListInt)
  511. .REQUIRED_ATTR(transpose_first, Bool)
  512. .OP_END_FACTORY_REG(ConfusionTransposeD)
  513. /**
  514. *@brief Confuse reshape and transpose . \n
  515. *@par Inputs:
  516. *@li x: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64.
  517. *@li shape: The shape of the input . \n
  518. *@par Attributes:
  519. *@li perm: A permutation of the dimensions of "x".
  520. *@li transpose_first: If True, the transpose is first, otherwise the reshape is first . \n
  521. *@par Outputs:
  522. *y: A Tensor. Has the same type as "x".
  523. *@par Restrictions:
  524. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  525. */
  526. REG_OP(ConfusionTranspose)
  527. .INPUT(x, TensorType::BasicType())
  528. .INPUT(shape, TensorType::IndexNumberType())
  529. .OUTPUT(y, TensorType::BasicType())
  530. .REQUIRED_ATTR(perm, ListInt)
  531. .REQUIRED_ATTR(transpose_first, Bool)
  532. .OP_END_FACTORY_REG(ConfusionTranspose)
  533. /**
  534. *@brief Flattens the input tensor to one-dimensional . \n
  535. *@par Inputs:
  536. *x: An ND tensor. All data types are supported . \n
  537. *@par Attributes:
  538. *@li axis: An optional int32, specifying the first axis to flatten. All preceding axes are retained in the output. Defaults to "1".
  539. *@li end_axis: An optional int32, specifying the last axis to flatten. All following axes are retained in the output. Defaults to "-1" . \n
  540. *@par Outputs:
  541. *y: The flattened ND tensor. All data types are supported . \n
  542. *@attention Constraints:
  543. * "axis" and "end_axis" must be within the dimension range of the input. This operator cannot be directly called by the acllopExecute API.
  544. *@par Third-party framework compatibility
  545. * Compatible with the Caffe operator Flatten.
  546. */
  547. REG_OP(FlattenV2)
  548. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  549. DT_INT32, DT_UINT32, DT_INT64, DT_UINT64}))
  550. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  551. DT_INT32, DT_UINT32, DT_INT64, DT_UINT64}))
  552. .ATTR(axis, Int, 1)
  553. .ATTR(end_axis, Int, -1)
  554. .OP_END_FACTORY_REG(FlattenV2)
  555. /**
  556. *@brief Compress large weight to small one. Usually inserted before Conv2d.
  557. *
  558. *@par Inputs:
  559. *weight: A tensor before compress. Must be one of the following types: DT_INT8, DT_FLOAT16
  560. *
  561. *@par Outputs:
  562. *@li weight_compress: A tensor after compress. Must be one of the following types: DT_INT8, DT_FLOAT16
  563. *@li compress_index: A tensor. Must be one of the following types: DT_INT8
  564. *
  565. *@par Attributes:
  566. *compress_parameters: A required int8, specifying the compressing block.
  567. *
  568. *@par Restrictions:
  569. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  570. */
  571. REG_OP(Compress)
  572. .INPUT(weight, TensorType({DT_INT8, DT_FLOAT16}))
  573. .OUTPUT(weight_compress, TensorType({DT_INT8, DT_FLOAT16}))
  574. .OUTPUT(compress_index, TensorType({DT_INT8}))
  575. .REQUIRED_ATTR(compress_parameters, ListInt)
  576. .OP_END_FACTORY_REG(Compress)
  577. /**
  578. *@brief Compress large weight to small one. Usually inserted before FullyConnection.
  579. *
  580. *@par Inputs:
  581. *weight: A tensor before compress. Must be one of the following types: DT_INT8, DT_FLOAT16
  582. *
  583. *@par Outputs:
  584. *@li weight_compress: A tensor after compress. Must be one of the following types: DT_INT8, DT_FLOAT16
  585. *@li compress_index: A tensor. Must be one of the following types: DT_INT8
  586. *
  587. *@par Attributes:
  588. *compress_parameters: A required int8, specifying the compressing block.
  589. *
  590. *@par Restrictions:
  591. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  592. */
  593. REG_OP(CompressFcOp)
  594. .INPUT(weight, TensorType({DT_INT8}))
  595. .OUTPUT(weight_compress, TensorType({DT_INT8}))
  596. .OUTPUT(compress_index, TensorType({DT_INT8}))
  597. .REQUIRED_ATTR(compress_parameters, ListInt)
  598. .OP_END_FACTORY_REG(CompressFcOp)
  599. /**
  600. *@brief Performs Col2im for each batch entry. \n
  601. *@par Inputs:
  602. *@li input_x: The Col Tensor. 5-D, shape: `(n, c1, kernel_h*kernel_w, ho*wo, c0)`.
  603. where ho/wo is do = (output_d + 2*padding_d - dilation_d*(kernel_d - 1) - 1)//stride_d + 1 \n
  604. *@par Outputs:
  605. *@li output_y: The img Tensor. 5-D, shape: `(n, c1, output_h, output_w, c0)`. \n
  606. *@par Attributes:
  607. *@li kernel_shape: ListInt, value: `(kernel_h, kernel_w)`, the shape of kernel in convolution.
  608. *@li dilation: ListInt, value: `(dilation_h, dilation_w)`, the dilation in convolution.
  609. *@li padding: ListInt, value: `(padding_h, padding_w)`, the dilation in convolution.
  610. *@li stride: ListInt, value: `(stride_h, stride_w)`, the dilation in convolution. \n
  611. *@par Third-party framework compatibility
  612. * Compatible with Pytorch col2im/im2col_backward operator.
  613. */
  614. REG_OP(Col2im)
  615. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  616. .INPUT(output_size, TensorType({DT_INT32, DT_INT32}))
  617. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  618. .REQUIRED_ATTR(kernel_size, ListInt)
  619. .REQUIRED_ATTR(dilation, ListInt)
  620. .REQUIRED_ATTR(padding, ListInt)
  621. .REQUIRED_ATTR(stride, ListInt)
  622. .OP_END_FACTORY_REG(Col2im)
  623. /**
  624. * @brief Performs Im2col for each batch entry. \n
  625. * @par Inputs:
  626. * x: A 4D Tensor with shape [batch, in_rows, in_cols, depth], Must be one of the
  627. * following types:float32, int8, float16. The inputs must have data_format with
  628. * one of follows:NHWC, NCHW.
  629. * @par Attributes:
  630. * @li ksizes: A required list or tuple. The size of the sliding window for each
  631. * dimension of images.
  632. * @li strides: A optional list or tuple. How far the centers of two consecutive
  633. * patches are in the images. Defaults to "{1}".
  634. * @li dilations: A optional list or tuple. Defaults to "{1}".
  635. * This is the input stride, specifying how far two consecutive patch
  636. * samples are in the input. Equivalent to extracting patches
  637. * with patch_sizes_eff = patch_sizes + (patch_sizes - 1) *
  638. * (dilations - 1), followed by subsampling them spatially by a factor of dilations.
  639. * This is equivalent to rate in dilated (a.k.a. Atrous) convolutions.
  640. * @li padding_mode: A optional String. The type of padding algorithm to use,
  641. * support "SAME", "VALID", "CALCULATED". Among the three modes, only the "CALCULATED"
  642. * means to use the pads below. Defaults to "CALCULATED".
  643. * @li pads: A optional list or tuple. The pad distance. Defaults to "{0}". \n
  644. * @par Outputs:
  645. * y: A 4D Tensor with shape [batch, out_rows, out_cols, ksize_rows *
  646. * ksize_cols * depth] containing image patches with size ksize_rows x ksize_cols
  647. * x depth vectorized in the "depth" dimension. Note "out_rows" and "out_cols"
  648. * are the dimensions of the output patches . \n
  649. * @attention Constraints:
  650. * "ksizes", "strides", "dilations" and "pads" are lists of integers . \n
  651. * @par Third-party framework compatibility
  652. * Compatible with Pytorch Im2col operator.
  653. */
  654. REG_OP(Im2col)
  655. .INPUT(x, TensorType::RealNumberType())
  656. .OUTPUT(y, TensorType::RealNumberType())
  657. .REQUIRED_ATTR(ksizes, ListInt)
  658. .ATTR(strides, ListInt, {1})
  659. .ATTR(dilations, ListInt, {1})
  660. .ATTR(padding_mode, String, "CALCULATED")
  661. .ATTR(pads, ListInt, {0})
  662. .OP_END_FACTORY_REG(Im2col)
  663. /**
  664. *@brief Generates a 2D or 3D flow field (sampling grid), given a batch of affine
  665. matrices theta. \n
  666. *@par Inputs:
  667. *Input theta must be float16 or float, output_size must be int32 type.Inputs
  668. include:
  669. *@li theta: input batch of affine matrices with shape (N,2,3) for 2D or (N,3,4)
  670. for 3D
  671. *@li output_size: the target output image size. (N×C×H×W for 2D or N×C×D×H×W for
  672. 3D) Example: torch.Size((32, 3, 24, 24)) . \n
  673. *@par Attributes:
  674. *align_corners: if True, consider -1 and 1 to refer to the centers of the corner
  675. pixels rather than the image corners.Refer to grid_sample() for a more complete
  676. description. A grid generated by affine_grid() should be passed to grid_sample()
  677. with the same setting for this option. Default: False \n
  678. *@par Outputs:
  679. *@li y: A 2-D integer tensor of shape [M] representing the
  680. selected indices from the boxes tensor, where M <= max_output_size. \n
  681. *@attention Constraints:
  682. *Input theta must be float16 or float, output_size must be int32 type . \n
  683. *@par Third-party framework compatibility
  684. *Compatible with Pytorch affine_grid operator.
  685. */
  686. REG_OP(AffineGrid)
  687. .INPUT(theta, TensorType({DT_FLOAT16, DT_FLOAT}))
  688. .INPUT(output_size, TensorType({DT_INT32}))
  689. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  690. .ATTR(align_corners, Bool, false)
  691. .OP_END_FACTORY_REG(AffineGrid)
  692. /**
  693. *@brief Make memory of a view be contiguous. \n
  694. *@par Inputs:
  695. *Four inputs, including:
  696. *@li x: The input tensor.
  697. *@li size: The shape of output tensor.
  698. *@li stride: The stride of output tensor.
  699. *@li storage_offset: The offset in the underlying storage of the output tensor. \n
  700. *@par Outputs:
  701. *y: A Tensor. Has the same type as "x" . \n
  702. *@par Third-party framework compatibility
  703. *Compatible with the pytorch operator as_strided.
  704. */
  705. REG_OP(AsStrided)
  706. .INPUT(x, TensorType::BasicType())
  707. .INPUT(size, TensorType::IndexNumberType())
  708. .INPUT(stride, TensorType::IndexNumberType())
  709. .INPUT(storage_offset, TensorType::IndexNumberType())
  710. .OUTPUT(y, TensorType::BasicType())
  711. .OP_END_FACTORY_REG(AsStrided)
  712. /**
  713. *@brief This transform extracts n-grams from the input sequence and save them as a
  714. vector. \n
  715. *@par Inputs:
  716. *@li input: can be either a 1-D or 2-D tensor for n-gram extraction, It is ether string UTF-8 or int32/int64 . \n
  717. *@par Attributes:
  718. *@li max_gram_length : int (required)
  719. *Maximum n-gram length. If this value is 3, 3-grams will be used to generate the output .
  720. *@li max_skip_count : int (required)
  721. *Maximum number of items (integers/strings) to be skipped when constructing an n-gram from X.
  722. If max_skip_count=1, min_gram_length=2, max_gram_length=3, this operator may generate 2-grams
  723. with skip_count=0 and skip_count=1, and 3-grams with skip_count=0 and skip_count=1.
  724. *@li min_gram_length : int (required)
  725. *Minimum n-gram length. If this value is 2 and max_gram_length is 3, output may contain counts of
  726. 2-grams and 3-grams.
  727. *@li mode : string (required)
  728. *The weighting criteria. It can be one of "TF" (term frequency), "IDF" (inverse document frequency),
  729. and "TFIDF" (the combination of TF and IDF).
  730. *@li ngram_counts : list of ints (required)
  731. *The starting indexes of 1-grams, 2-grams, and so on in pool. It is useful when determining the boundary
  732. between two consecutive collections of n-grams. For example, if ngram_counts is [0, 17, 36],
  733. the first index (zero-based) of 1-gram/2-gram/3-gram in pool are 0/17/36. This format is essentially identical
  734. to CSR (or CSC) sparse matrix format, and we choose to use this due to its popularity.
  735. *@li ngram_indexes : list of ints (required)
  736. *list of int64s (type: AttributeProto::INTS). This list is parallel to the specified 'pool_*' attribute. The i-th element
  737. in ngram_indexes indicate the coordinate of the i-th n-gram in the output tensor.
  738. *@li pool_int64s : list of ints
  739. *List of int64 n-grams learned from the training set. Either this or pool_strings attributes must be present but not both.
  740. It's an 1-D tensor starting with the collections of all 1-grams and ending with the collections of n-grams. The i-th element
  741. in pool stores the n-gram that should be mapped to coordinate ngram_indexes[i] in the output vector.
  742. *@li pool_strings : list of strings
  743. *List of strings n-grams learned from the training set. Either this or pool_int64s attributes must be present but not both.
  744. It's an 1-D tensor starting with the collections of all 1-grams and ending with the collections of n-grams. The i-th element
  745. in pool stores the n-gram that should be mapped to coordinate ngram_indexes[i] in the output vector.
  746. *@li weights : list of floats
  747. *list of floats. This attribute stores the weight of each n-gram in pool. The i-th element in weights is the weight of
  748. the i-th n-gram in pool. Its length equals to the size of ngram_indexes. By default, weights is an all-one tensor.This attribute
  749. is used when mode is "IDF" or "TFIDF" to scale the associated word counts. \n
  750. *@par Outputs:
  751. *@li output: tensor(float)
  752. *For 1-D input, output is the n-gram representation of that input. For 2-D input, the output is also a 2-D tensor
  753. whose i-th row is the n-gram representation of the i-th input row. More specifically, if input shape is [C], the corresponding
  754. output shape would be [max(ngram_indexes) + 1]. If input shape is [N, C], this operator produces a [N, max(ngram_indexes) + 1]-tensor. \n
  755. *@attention Constraints:
  756. *@li input can be either a 1-D or 2-D tensor, shape is [C] or [N, C].
  757. *@li max(ngram_indexes) + 1 == len(weights), len(y) == len(weights).
  758. *@li ngram_counts and pool(pool_int64s or pool_strings) must match.
  759. *@li either pool_strings or pool_int64s attributes must be present but not both.
  760. */
  761. REG_OP(TfidVectorizer)
  762. .INPUT(input, TensorType({DT_INT32, DT_INT64, DT_STRING}))
  763. .OUTPUT(output, TensorType({DT_FLOAT}))
  764. .REQUIRED_ATTR(max_gram_length, Int)
  765. .REQUIRED_ATTR(max_skip_count, Int)
  766. .REQUIRED_ATTR(min_gram_length, Int)
  767. .REQUIRED_ATTR(mode, String)
  768. .REQUIRED_ATTR(ngram_counts, ListInt)
  769. .REQUIRED_ATTR(ngram_indexes, ListInt)
  770. .ATTR(pool_int64s, ListInt, {})
  771. .ATTR(pool_strings, ListString, {})
  772. .ATTR(weights, ListFloat, {})
  773. .OP_END_FACTORY_REG(TfidVectorizer)
  774. } // namespace ge
  775. #endif // OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_

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