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.

matrix_calculation_ops.h 35 kB

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
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
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
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. /**
  2. * Copyright 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. /*!
  17. * \file matrix_calculation_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Multiplies matrix "a" by matrix "b", producing "a * b" . \n
  26. *@par Inputs:
  27. *Three inputs, including:
  28. * @li x1: A matrix Tensor. 2D. Must be one of the following types: float16,
  29. * float32, int32. Has format [ND, NHWC, FRACTAL_NZ].
  30. * @li x2: A matrix Tensor. 2D. Must be one of the following types: float16,
  31. * float32, int32. Has format [ND, NHWC, FRACTAL_NZ].
  32. * @li bias: A optional 1D Tensor. Must be one of the following types: float16,
  33. * float32, int32. Has format [ND, NHWC] . \n
  34. *@par Attributes:
  35. *@li transpose_a: A bool. If True, changes the shape of "x1" from [M, K] to [K, M].
  36. *@li transpose_b: A bool. If True, changes the shape of "x2" from [M, K] to [K, M] . \n
  37. *@par Outputs:
  38. *y: The result matrix Tensor. 2D. Must be one of the following types: float16,
  39. * float32, int32. Has format [ND, NHWC, FRACTAL_NZ] . \n
  40. *@par Third-party framework compatibility
  41. * Compatible with the TensorFlow operator BatchMatmul.
  42. */
  43. REG_OP(MatMul)
  44. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  45. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  46. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  47. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  48. .ATTR(transpose_x1, Bool, false)
  49. .ATTR(transpose_x2, Bool, false)
  50. .OP_END_FACTORY_REG(MatMul)
  51. /**
  52. *@brief Multiplies matrix "a" by matrix "b", producing "a * b" . \n
  53. *@par Inputs:
  54. *Two inputs, including:
  55. * @li x1: A matrix Tensor. 2D. Must be one of the following types: float16,
  56. * float32, int32. Has format [ND, NHWC, FRACTAL_NZ].
  57. * @li x2: A matrix Tensor. 2D. Must be one of the following types: float16,
  58. * float32, int32. Has format [ND, NHWC, FRACTAL_NZ].
  59. * @li bias: A 1D Tensor. Must be one of the following types: float16,
  60. * float32, int32. Has format [ND, NHWC] . \n
  61. *@par Attributes:
  62. *@li transpose_a: A bool. If True, changes the shape of "x1" from [M, K] to [K, M].
  63. *@li transpose_b: A bool. If True, changes the shape of "x2" from [M, K] to [K, M] . \n
  64. *@par Outputs:
  65. *y: The result matrix Tensor. 2D. Must be one of the following types: float16,
  66. * float32, int32. Has format [ND, NHWC, FRACTAL_NZ] . \n
  67. *@par Third-party framework compatibility
  68. * Compatible with the TensorFlow operator BatchMatmul.
  69. */
  70. REG_OP(MatMulV2)
  71. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  72. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  73. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  74. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  75. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  76. .ATTR(transpose_x1, Bool, false)
  77. .ATTR(transpose_x2, Bool, false)
  78. .ATTR(offset_x, Int, 0)
  79. .OP_END_FACTORY_REG(MatMulV2)
  80. /**
  81. *@brief Performs Matrix-to-matrix Multiply, producing c=alpha[0]*a*b+beta[0]*c . \n
  82. *@attention Constraints:
  83. * For better performance, The k-axis must be aligned to 16 (input type
  84. * is float16) or 32 (input type is int8). \n
  85. *@par Inputs:
  86. *Five inputs, including:
  87. *@li a: A matrix Tensor. Must be one of the following types: float16, int8.
  88. * Has format [ND, FRACTAL_NZ]. 2D(ND) or 4D(FRACTAL_NZ).
  89. *@li b: A matrix Tensor. Must be one of the following types: float16, int8.
  90. * Has format [ND, FRACTAL_NZ, FRACTAL_Z]. 2D(ND) or 4D(FRACTAL_NZ, FRACTAL_Z).
  91. *@li c: A matrix Tensor. Must be one of the following types: float16, int32,
  92. * float32. has format [ND, FRACTAL_NZ]. 2D(ND) or 4D(FRACTAL_NZ).
  93. *@li alpha: A 1D Tensor. The shape of alpha is [1].Must be one of the following
  94. * types: float16, int32, float32. Has format [ND].
  95. *@li beta: A 1D Tensor. The shape of beta is [1]. Must be one of the following
  96. * types: float16, int32, float32. Has format [ND].
  97. * The format of a, b, c has restriction:\n
  98. * When type of a is int8 and type of c is int32, the format of a, b, c should
  99. * all be ND, or a is FRACTAL_NZ and b is FRACTAL_Z and c is ND.\n
  100. * When type of a is int8 and type of c is float32, the format of a, b, c should
  101. * all be ND or a is FRACTAL_NZ and b is FRACTAL_Z and c is FRACTAL_NZ.\n
  102. * When type of a is float16 and type of c is float16, the format of a, b, c
  103. * should all be ND or FRACTAL_NZ.\n
  104. * When type of a is float16 and type of c is float32, the format of a, b, c
  105. * should all be ND or FRACTAL_NZ . \n
  106. *@par Attributes:
  107. *Two attributes, including:
  108. *@li transpose_a: Optional. A bool. If True, changes the shape of "a" from
  109. * [M, K] to [K, M].
  110. *@li transpose_b: Optional. A bool. If True, changes the shape of "b" from
  111. * [K, N] to [N, K] . \n
  112. *@par Outputs:
  113. *y: The result matrix Tensor. Must be one of the following types: float16,
  114. * float32, int32. Has format [ND, FRACTAL_NZ], the format should be equal to a.
  115. * 2D(ND) or 4D(FRACTAL_NZ).
  116. */
  117. REG_OP(GEMM)
  118. .INPUT(a, TensorType({DT_FLOAT16, DT_INT8}))
  119. .INPUT(b, TensorType({DT_FLOAT16, DT_INT8}))
  120. .INPUT(c, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  121. .INPUT(alpha, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  122. .INPUT(beta, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  123. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  124. .ATTR(transpose_a, Bool, false)
  125. .ATTR(transpose_b, Bool, false)
  126. .OP_END_FACTORY_REG(GEMM)
  127. /**
  128. *@brief Multiplies matrix "a" by matrix "b", producing "a * b" . \n
  129. *@par Inputs:
  130. *Three inputs, including:
  131. * @li x1: A matrix Tensor. Must be one of the following types: float16,
  132. * float32, int32. 2D or higher. Has format [ND, NHWC, FRACTAL_NZ].
  133. * @li x2: A matrix Tensor. Must be one of the following types: float16,
  134. * float32, int32. 2D or higher. Has format [ND, NHWC, FRACTAL_NZ] . \n
  135. *@par Attributes:
  136. *@li adj_x: A bool. If True, changes the shape of "x1" from [B, M, K] to [B, K, M].
  137. *@li adj_y: A bool. If True, changes the shape of "x2" from [B, M, K] to [B, K, M] . \n
  138. *@par Outputs:
  139. *y: The result matrix Tensor. 2D or higher. Must be one of the following types: float16,
  140. * float32, int32. 2D or higher. Has format [ND, NHWC, FRACTAL_NZ]. Has the same shape length as "x1" and "x2" . \n
  141. *@par Third-party framework compatibility
  142. * Compatible with the TensorFlow operator BatchMatmul.
  143. */
  144. REG_OP(BatchMatMul)
  145. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  146. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  147. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  148. .ATTR(adj_x1, Bool, false)
  149. .ATTR(adj_x2, Bool, false)
  150. .OP_END_FACTORY_REG(BatchMatMul)
  151. /**
  152. *@brief Computes half the L2 norm of a tensor without the sqrt . \n
  153. *@par Inputs:
  154. * x: A Tensor.
  155. * TensorType::FloatingDataType() . \n
  156. *@par Outputs:
  157. *y: A Tensor. Has the same type as "x".
  158. *@par Third-party framework compatibility
  159. *Compatible with the TensorFlow operator L2Loss.
  160. */
  161. REG_OP(L2Loss)
  162. .INPUT(x, TensorType::FloatingDataType())
  163. .OUTPUT(y, TensorType::FloatingDataType())
  164. .OP_END_FACTORY_REG(L2Loss)
  165. /**
  166. *@brief: Returns a batched diagonal tensor with a given batched diagonal values . \n
  167. *@par Inputs:
  168. *x: A Tensor. Must be one of the following types:
  169. * float16, float32, double, int32, uint8, int16, int8, complex64, int64,
  170. * qint8, quint8, qint32, uint16, complex128, uint32, uint64 . \n
  171. *@par Outputs:
  172. *y: A Tensor. Has the same type as "x" . \n
  173. *@par Third-party framework compatibility
  174. * Compatible with the TensorFlow operator MatrixDiag.
  175. */
  176. REG_OP(MatrixDiag)
  177. .INPUT(x, TensorType::BasicType())
  178. .OUTPUT(y, TensorType::BasicType())
  179. .OP_END_FACTORY_REG(MatrixDiag)
  180. /**
  181. *@brief: Returns a batched diagonal tensor with a given batched diagonal values . \n
  182. *@par Inputs:
  183. * Two inputs, including:
  184. *@li x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
  185. *@li assist: A Tensor of the same type as "x" . \n
  186. *@par Outputs:
  187. *y: A Tensor. Has the same type as "x" . \n
  188. *@par Third-party framework compatibility
  189. * Compatible with the TensorFlow operator MatrixDiag.
  190. *
  191. * @par Restrictions:
  192. * Warning: THIS FUNCTION IS DEPRECATED. Please use MatrixDiag instead.
  193. */
  194. REG_OP(MatrixDiagD)
  195. .INPUT(x, TensorType::BasicType())
  196. .INPUT(assist, TensorType::BasicType())
  197. .OUTPUT(y, TensorType::BasicType())
  198. .OP_END_FACTORY_REG(MatrixDiagD)
  199. /**
  200. *@brief: Returns the batched diagonal part of a batched tensor . \n
  201. *@par Inputs:
  202. *x: A Tensor. Must be one of the following types:
  203. * float16, float32, double, int32, uint8, int16, int8, complex64, int64,
  204. * qint8, quint8, qint32, uint16, complex128, uint32, uint64 . \n
  205. *@par Outputs:
  206. *y: A Tensor. Has the same type as "x" . \n
  207. *@par Third-party framework compatibility
  208. * Compatible with the TensorFlow operator MatrixDiagPart.
  209. */
  210. REG_OP(MatrixDiagPart)
  211. .INPUT(x, TensorType::BasicType())
  212. .OUTPUT(y, TensorType::BasicType())
  213. .OP_END_FACTORY_REG(MatrixDiagPart)
  214. /**
  215. *@brief: Returns the batched diagonal part of a batched tensor . \n
  216. *@par Inputs:
  217. * Two inputs, including:
  218. *@li x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
  219. *@li assist: A Tensor of the same type as "x" . \n
  220. *@par Outputs:
  221. *y: A Tensor. Has the same type as "x" . \n
  222. *@par Third-party framework compatibility
  223. * Compatible with the TensorFlow operator MatrixDiagPart.
  224. *
  225. * @par Restrictions:
  226. * Warning: THIS FUNCTION IS DEPRECATED. Please use MatrixDiagPart instead.
  227. */
  228. REG_OP(MatrixDiagPartD)
  229. .INPUT(x, TensorType::BasicType())
  230. .INPUT(assist, TensorType::BasicType())
  231. .OUTPUT(y, TensorType::BasicType())
  232. .OP_END_FACTORY_REG(MatrixDiagPartD)
  233. /**
  234. *@brief: Returns a batched matrix tensor with new batched diagonal values . \n
  235. *@par Inputs:
  236. * Two inputs, including:
  237. *@li x: A Tensor. Must be one of the following types:
  238. * float16, float32, double, int32, uint8, int16, int8, complex64, int64,
  239. * qint8, quint8, qint32, uint16, complex128, uint32, uint64.
  240. *@li diagonal: A Tensor of the same type as "x" . \n
  241. *@par Outputs:
  242. *y: A Tensor. Has the same type as "x" . \n
  243. *@par Third-party framework compatibility
  244. * Compatible with the TensorFlow operator MatrixSetDiag.
  245. */
  246. REG_OP(MatrixSetDiag)
  247. .INPUT(x, TensorType::BasicType())
  248. .INPUT(diagonal, TensorType::BasicType())
  249. .OUTPUT(y, TensorType::BasicType())
  250. .OP_END_FACTORY_REG(MatrixSetDiag)
  251. /**
  252. *@brief: Returns a batched matrix tensor with new batched diagonal values . \n
  253. *@par Inputs:
  254. * Three inputs, including:
  255. *@li x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
  256. *@li diagonal: A Tensor of the same type as "x".
  257. *@li assist: A Tensor of the same type as "x" . \n
  258. *@par Outputs:
  259. *y: A Tensor. Has the same type as "x" . \n
  260. *@par Third-party framework compatibility
  261. * Compatible with the TensorFlow operator MatrixSetDiag.
  262. *
  263. * @par Restrictions:
  264. * Warning: THIS FUNCTION IS DEPRECATED. Please use MatrixSetDiag instead.
  265. */
  266. REG_OP(MatrixSetDiagD)
  267. .INPUT(x, TensorType::BasicType())
  268. .INPUT(diagonal, TensorType::BasicType())
  269. .INPUT(assist, TensorType::BasicType())
  270. .OUTPUT(y, TensorType::BasicType())
  271. .OP_END_FACTORY_REG(MatrixSetDiagD)
  272. /**
  273. *@brief Applies sparse "updates" to individual values or slices in a Variable . \n
  274. *@par Inputs:
  275. * Three inputs, including:
  276. *@li var: An ND Tensor.
  277. *Must be one of the following types: float16, float32, int8, uint8, double,
  278. * int64, complex64, qint8, quint8, qint32, uint16, complex128, half, uint32,
  279. * uint64
  280. *@li indices: An ND Tensor.
  281. *Must be one of the following types: int32, int64
  282. *@li updates: An ND Tensor.
  283. *Must be one of the following types: float16, float32, int8, uint8, double,
  284. * int64, complex64, qint8, quint8, qint32, uint16, complex128, half, uint32,
  285. * uint64
  286. *@par Attributes:
  287. *use_locking: An optional bool. Defaults to "False". If "True",
  288. * the operation will be protected by a lock . \n
  289. *@par Outputs:
  290. *var: A Tensor. Has the same type and format as input "var" . \n
  291. *@par Third-party framework compatibility
  292. * Compatible with the TensorFlow operator ScatterNdUpdate.
  293. */
  294. REG_OP(ScatterNdUpdate)
  295. .INPUT(var, TensorType::BasicType())
  296. .INPUT(indices, TensorType::IndexNumberType())
  297. .INPUT(updates, TensorType::BasicType())
  298. .OUTPUT(var, TensorType::BasicType())
  299. .ATTR(use_locking, Bool, false)
  300. .OP_END_FACTORY_REG(ScatterNdUpdate)
  301. /**
  302. *@brief Applies sparse addition to individual values or slices in a Variable . \n
  303. *@par Inputs:
  304. * Three inputs, including:
  305. *@li x: An ND Tensor. \n
  306. *Must be one of the following types: float16, float32, bool, int8, uint8
  307. *@li indices: An ND Tensor. \n
  308. *Must be one of the following types: int32
  309. *@li updates: An ND Tensor. \n
  310. *Must be one of the following types: float16, float32, bool, int8, uint8
  311. *@par Outputs:
  312. *y: A Tensor. Has the same type and format as input "x" . \n
  313. *@par Third-party framework compatibility
  314. * Compatible with the TensorFlow operator TensorScatterUpdate.
  315. */
  316. REG_OP(TensorScatterUpdate)
  317. .INPUT(x, TensorType::BasicType())
  318. .INPUT(indices, TensorType::IndexNumberType())
  319. .INPUT(updates, TensorType::BasicType())
  320. .OUTPUT(y, TensorType::BasicType())
  321. .OP_END_FACTORY_REG(TensorScatterUpdate)
  322. /**
  323. *@brief Adds sparse "updates" to a variable reference . \n
  324. *@par Inputs:
  325. * Three inputs, including:
  326. *@li var: An ND Tensor . \n
  327. *Must be one of the following types: float16, float32, int32, int8, uint8
  328. *@li indices: An ND Tensor of type int32 or int64.
  329. *@li updates: An Tensor. format:NCHW, NHWC . \n
  330. *Must be one of the following types: float16, float32, int32, int8, uint8
  331. *@par Attributes:
  332. * use_locking: An optional bool. Defaults to "False". If "True", the operation
  333. * will be protected by a lock . \n
  334. *@par Outputs:
  335. *var: A Tensor. Has the same type and format as input "var" . \n
  336. *@par Third-party framework compatibility
  337. * Compatible with the TensorFlow operator ScatterAdd.
  338. */
  339. REG_OP(ScatterAdd)
  340. .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  341. .INPUT(indices, TensorType::IndexNumberType())
  342. .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  343. .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  344. .ATTR(use_locking, Bool, false)
  345. .OP_END_FACTORY_REG(ScatterAdd)
  346. /**
  347. *@brief Divides a variable reference by sparse updates . \n
  348. *@par Inputs:
  349. * Three inputs, including:
  350. *@li var: An ND Tensor.
  351. *Must be one of the following types: float16, float, int32, int8, uint8
  352. *@li indices: An ND Tensor.
  353. *Must be one of the following types: int32
  354. *@li updates: An ND Tensor.
  355. *Must be one of the following types: float16, float, int32, int8, uint8
  356. *@par Attributes:
  357. *@li use_locking: An optional bool. Defaults to "False". If "True",
  358. * the operation will be protected by a lock . \n
  359. *@par Outputs:
  360. *var: A Tensor. Has the same type and format as input "var" . \n
  361. *@par Third-party framework compatibility
  362. * Compatible with the TensorFlow operator ScatterDiv.
  363. */
  364. REG_OP(ScatterDiv)
  365. .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  366. .INPUT(indices, TensorType({DT_INT32}))
  367. .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  368. .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  369. .ATTR(use_locking, Bool, false)
  370. .OP_END_FACTORY_REG(ScatterDiv)
  371. /**
  372. *@brief Applies sparse addition to individual values or slices in a Variable . \n
  373. *@par Inputs:
  374. * Three inputs, including:
  375. *@li var: An ND Tensor.
  376. *Must be one of the following types: float16, float, int32, int8, uint8
  377. *@li indices: An ND Tensor.
  378. *Must be one of the following types: int32
  379. *@li updates: An ND Tensor.
  380. *Must be one of the following types: float16, float, int32, int8, uint8
  381. *@par Attributes:
  382. *use_locking: An optional bool. Defaults to "False". If "True",
  383. * the operation will be protected by a lock . \n
  384. *@par Outputs:
  385. *var: A Tensor. Has the same type and format as input "var" . \n
  386. *@par Third-party framework compatibility
  387. * Compatible with the TensorFlow operator ScatterNdAdd.
  388. */
  389. REG_OP(ScatterNdAdd)
  390. .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  391. .INPUT(indices, TensorType::IndexNumberType())
  392. .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  393. .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  394. .ATTR(use_locking, Bool, false)
  395. .OP_END_FACTORY_REG(ScatterNdAdd)
  396. /**
  397. *@brief Applies sparse addition to individual values or slices in a Variable . \n
  398. *@par Inputs:
  399. * Three inputs, including:
  400. *@li x: An ND Tensor. \n
  401. *Must be one of the following types: float16, float32, int32, int8, uint8
  402. *@li indices: An ND Tensor. \n
  403. *Must be one of the following types: int32
  404. *@li updates: An ND Tensor. \n
  405. * Must be one of the following types: float16, float32, int32, int8, uint8
  406. *@par Outputs:
  407. *y: A Tensor. Has the same type and format as input "x" . \n
  408. *@par Third-party framework compatibility
  409. * Compatible with the TensorFlow operator TensorScatterAdd.
  410. */
  411. REG_OP(TensorScatterAdd)
  412. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  413. .INPUT(indices, TensorType::IndexNumberType())
  414. .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  415. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  416. .OP_END_FACTORY_REG(TensorScatterAdd)
  417. /**
  418. *@brief Applies sparse subtraction to individual values or slices in a Variable . \n
  419. *@par Inputs:
  420. * Three inputs, including:
  421. *@li var: An ND Tensor.
  422. *Must be one of the following types: float16, float, int32, int8, uint8
  423. *@li indices: An ND Tensor.
  424. *Must be one of the following types: int32, int64
  425. *@li updates: An ND Tensor.
  426. *Must be one of the following types: float16, float, int32, int8, uint8
  427. *@par Attributes:
  428. *use_locking: An optional bool. Defaults to "False". If "True",
  429. * the operation will be protected by a lock . \n
  430. *@par Outputs:
  431. * var: A Tensor. Has the same type and format as input "var" . \n
  432. *@par Third-party framework compatibility
  433. * Compatible with the TensorFlow operator ScatterNdSub.
  434. */
  435. REG_OP(ScatterNdSub)
  436. .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  437. .INPUT(indices, TensorType::IndexNumberType())
  438. .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  439. .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  440. .ATTR(use_locking, Bool, false)
  441. .OP_END_FACTORY_REG(ScatterNdSub)
  442. /**
  443. *@brief Applies sparse addition to individual values or slices in a Variable . \n
  444. *@par Inputs:
  445. * Three inputs, including:
  446. *@li x: An ND Tensor. \n
  447. *Must be one of the following types: float16, float32, int32, int8, uint8
  448. *@li indices: An ND Tensor. \n
  449. *Must be one of the following types: int32
  450. *@li updates: An ND Tensor. \n
  451. *Must be one of the following types: float16, float32, int32, int8, uint8
  452. *@par Outputs:
  453. * y: A Tensor. Has the same type and format as input "x" . \n
  454. *@par Third-party framework compatibility
  455. * Compatible with the TensorFlow operator TensorScatterSub.
  456. */
  457. REG_OP(TensorScatterSub)
  458. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  459. .INPUT(indices, TensorType::IndexNumberType())
  460. .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  461. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  462. .OP_END_FACTORY_REG(TensorScatterSub)
  463. /**
  464. *@brief Subtracts sparse updates to a variable reference . \n
  465. *@par Inputs:
  466. * Three inputs, including:
  467. *@li var: An ND Tensor.
  468. *Must be one of the following types: float16, float, int32, int8, uint8
  469. *@li indices: An ND Tensor.
  470. *Must be one of the following types: int32, int64
  471. *@li updates: An ND Tensor.
  472. *Must be one of the following types: float16, float, int32, int8, uint8
  473. *@par Attributes:
  474. *use_locking: An optional bool. Defaults to "False". If "True",
  475. * the operation will be protected by a lock . \n
  476. *@par Outputs:
  477. * var: A Tensor. Has the same type and format as input "var" . \n
  478. *@par Third-party framework compatibility
  479. * Compatible with the TensorFlow operator ScatterSub.
  480. */
  481. REG_OP(ScatterSub)
  482. .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  483. .INPUT(indices, TensorType::IndexNumberType())
  484. .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  485. .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  486. .ATTR(use_locking, Bool, false)
  487. .OP_END_FACTORY_REG(ScatterSub)
  488. /**
  489. *@brief: Returns the batched diagonal part of a batched tensor with "assist" . \n
  490. *@par Inputs:
  491. * Two inputs, including:
  492. * @li x: A Tensor of type float16, float32, or int32.
  493. * @li assist: A Tensor of the same type as "x" . \n
  494. *@par Outputs:
  495. *y: A Tensor. Has the same type as "x" . \n
  496. *@par Third-party framework compatibility
  497. * Compatible with the TensorFlow operator DiagPart.
  498. *
  499. * @par Restrictions:
  500. * Warning: THIS FUNCTION IS DEPRECATED. Please use DiagPart instead.
  501. */
  502. REG_OP(DiagPartD)
  503. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  504. .INPUT(assist, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  505. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  506. .OP_END_FACTORY_REG(DiagPartD)
  507. /**
  508. *@brief: Returns the batched diagonal part of a batched tensor . \n
  509. *@par Inputs:
  510. *x: A Tensor. Must be one of the following types:
  511. * float16, float32, int32, int64, double, complex64, complex128 . \n
  512. *@par Outputs:
  513. *y: A Tensor. Has the same type as "x" . \n
  514. *@par Third-party framework compatibility
  515. * Compatible with the TensorFlow operator DiagPart.
  516. */
  517. REG_OP(DiagPart)
  518. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT64, DT_DOUBLE,
  519. DT_COMPLEX64, DT_COMPLEX128}))
  520. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT64, DT_DOUBLE,
  521. DT_COMPLEX64, DT_COMPLEX128}))
  522. .OP_END_FACTORY_REG(DiagPart)
  523. /**
  524. *@brief Also known as a "fully-connected" layer, computes an inner product with a set of learned weights, and (optionally) adds biases . \n
  525. *@par Inputs:
  526. * Four inputs, including:
  527. *@li x: A Tensor of type float16, int8.
  528. *@li w: A weight matrix of type float16, int8.
  529. *@li b: A Tensor of type float16, int32, float32.
  530. *@li offset_w: A Tensor of type int8 . \n
  531. *@par Attributes:
  532. *@li num_output: Reserved.
  533. *@li transpose: A bool, specifying weight whether to transpose, either "true" or "false". Defaults to "false".
  534. *@li axis: Optional. A int, 1 or 2, specifying which dimension the input "K" starts from. Defaults to 1.
  535. * The product of the subsequent dimensions starting form first dimension or the second dimension is "K".
  536. *@li offset_x: Reserved . \n
  537. *@par Outputs:
  538. *y: The result tensor of type float16, int32, float32 . \n
  539. *@par Third-party framework compatibility
  540. * Compatible with the Caffe operator InnerProduct . \n
  541. *@par Quantization supported or not
  542. * Yes
  543. */
  544. REG_OP(FullyConnection)
  545. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  546. .INPUT(w, TensorType({DT_FLOAT16, DT_INT8}))
  547. .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_INT32,DT_FLOAT32}))
  548. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  549. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32,DT_FLOAT32}))
  550. .REQUIRED_ATTR(num_output, Int)
  551. .ATTR(transpose, Bool, false)
  552. .ATTR(axis, Int, 1)
  553. .ATTR(offset_x, Int, 0)
  554. .OP_END_FACTORY_REG(FullyConnection)
  555. /**
  556. *@brief Also known as a "fully-connected-compress" layer, computes an inner product with a set of learned weights, and (optionally) adds biases . \n
  557. *@par Inputs:
  558. * Four inputs, including:
  559. *@li x: A Tensor of type uint8, int8.
  560. *@li w: A weight matrix of type int8, int8.
  561. *@li w: A compress index matrix of type int8, int8.
  562. *@li b: A Tensor of type float16, int32, int32.
  563. *@li offset_w: A Tensor of type int8.i
  564. *@par Attributes:
  565. *@li num_output: Reserved.
  566. *@li transpose: A bool, specifying whether to transpose, either "true" or "false". Defaults to "false".
  567. *@li axis: Reserved.
  568. *@li offset_x: Reserved . \n
  569. *@par Outputs:
  570. *y: The result tensor of type int32 . \n
  571. *@par Third-party framework compatibility
  572. * Compatible with the Caffe operator InnerProduct . \n
  573. *@par Quantization supported or not
  574. * Yes
  575. */
  576. REG_OP(FullyConnectionCompress)
  577. .INPUT(x, TensorType({DT_UINT8, DT_INT8}))
  578. .INPUT(w, TensorType({DT_INT8}))
  579. .INPUT(comress_index, TensorType({DT_INT8}))
  580. .OPTIONAL_INPUT(b, TensorType({DT_INT32}))
  581. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  582. .OUTPUT(y, TensorType({DT_INT32}))
  583. .REQUIRED_ATTR(num_output, Int)
  584. .ATTR(transpose, Bool, false)
  585. .ATTR(axis, Int, 1)
  586. .ATTR(offset_x, Int, 0)
  587. .OP_END_FACTORY_REG(FullyConnectionCompress)
  588. /**
  589. *@brief Computes the confusion matrix from predictions and labels . \n
  590. *@par Inputs:
  591. * Three inputs, including:
  592. *@li labels: A Tensor. Must be one of the following types: float16, float32,
  593. * int32, int8, uint8.
  594. *@li predictions: A Tensor. Must be one of the following types: float16,
  595. * float32, int32, int8, uint8.
  596. *@li weights: A Tensor. Must be one of the following types: float16, float32,
  597. * int32, int8, uint8 . \n
  598. *@par Attributes:
  599. *@li num_classes: An integer for the shape of the output matrix.
  600. * No default value.
  601. *@li dtype: Data type of the confusion matrix. No default value . \n
  602. *@par Outputs:
  603. *y: A Tensor. Has the same type and format as input "labels"
  604. *@attention Constraints:
  605. *@li "weights", "labels", and "predictions" are 1D tensors.
  606. *@li The output is with shape (num_classes, num_classes),
  607. * where, 1 <= num_classes <= 4096 . \n
  608. *@see Region()
  609. *@par Third-party framework compatibility
  610. * Compatible with the TensorFlow operator ConfusionMatrix.
  611. */
  612. REG_OP(ConfusionMatrix)
  613. .INPUT(labels, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
  614. .INPUT(predictions, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
  615. .OPTIONAL_INPUT(weights, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
  616. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
  617. .REQUIRED_ATTR(num_classes, Int)
  618. .REQUIRED_ATTR(dtype, String)
  619. .OP_END_FACTORY_REG(ConfusionMatrix)
  620. /**
  621. *@brief Multiplies sparse updates into a variable reference . \n
  622. *@par Inputs:
  623. * Three inputs, including:
  624. *@li var: An ND Tensor.
  625. *Must be one of the following types: float16, float, int32, int8, uint8
  626. *@li indices: An ND Tensor.
  627. *Must be one of the following types: int32
  628. *@li updates: An ND Tensor . \n
  629. *Must be one of the following types: float16, float, int32, int8, uint8
  630. *@par Attributes:
  631. *use_locking: An optional bool. Defaults to "False". If "True", the operation
  632. * will be protected by a lock . \n
  633. *@par Outputs:
  634. *var: A Tensor. Has the same type and format as input "var" . \n
  635. *@par Third-party framework compatibility
  636. * Compatible with the TensorFlow operator ScatterMul.
  637. */
  638. REG_OP(ScatterMul)
  639. .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  640. .INPUT(indices, TensorType({DT_INT32}))
  641. .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  642. .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  643. .ATTR(use_locking, Bool, false)
  644. .OP_END_FACTORY_REG(ScatterMul)
  645. /**
  646. *@brief Reduces sparse updates into a variable reference using
  647. * the "min" operation . \n
  648. *@par Inputs:
  649. * Three inputs, including:
  650. *@li var: An ND Tensor.
  651. *Must be one of the following types: float16, float, int32
  652. *@li indices: An ND Tensor.
  653. *Must be one of the following types: int32
  654. *@li updates: An ND Tensor.
  655. *Must be one of the following types: float16, float, int32
  656. *@par Attributes:
  657. *use_locking: An optional bool. Defaults to "False". If "True", the operation
  658. * will be protected by a lock . \n
  659. *@par Outputs:
  660. *var: A Tensor. Has the same type and format as input "var" . \n
  661. *@par Third-party framework compatibility
  662. * Compatible with the TensorFlow operator ScatterMin.
  663. */
  664. REG_OP(ScatterMin)
  665. .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  666. .INPUT(indices, TensorType({DT_INT32}))
  667. .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  668. .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  669. .ATTR(use_locking, Bool, false)
  670. .OP_END_FACTORY_REG(ScatterMin)
  671. /**
  672. *@brief Reduces sparse updates into a variable reference using the "max" operation . \n
  673. *@par Inputs:
  674. * Three inputs, including:
  675. *@li var: An ND Tensor . \n
  676. *Must be one of the following types: float16, float, int32
  677. *@li indices: An NCHW, NHWC, or ND Tensor . \n
  678. *Must be one of the following types: int32
  679. *@li updates: An NCHW, NHWC, or ND Tensor . \n
  680. *Must be one of the following types: float16, float, int32
  681. *@par Attributes:
  682. *use_locking: An optional bool. Defaults to "False".
  683. * If "True", the operation will be protected by a lock . \n
  684. *@par Outputs:
  685. *var: A Tensor. Has the same type and format as input "var" . \n
  686. *@par Third-party framework compatibility
  687. * Compatible with the TensorFlow operator ScatterMax.
  688. */
  689. REG_OP(ScatterMax)
  690. .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  691. .INPUT(indices, TensorType({DT_INT32}))
  692. .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  693. .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  694. .ATTR(use_locking, Bool, false)
  695. .OP_END_FACTORY_REG(ScatterMax)
  696. /**
  697. *@brief Applies sparse updates to a variable reference . \n
  698. *@par Inputs:
  699. * Three inputs, including:
  700. *@li var: An ND Tensor . \n
  701. *Must be one of the following types: float16, float, int32, int8, uint8
  702. *@li indices: An ND Tensor . \n
  703. *Must be one of the following types: int32
  704. *@li updates: An ND Tensor . \n
  705. *Must be one of the following types: float16, float, int32, int8, uint8
  706. *@par Attributes:
  707. *use_locking: An optional bool. Defaults to "False". If "True",
  708. * the operation will be protected by a lock . \n
  709. *@par Outputs:
  710. *var: A Tensor. Has the same type and format as input "var" . \n
  711. *@par Third-party framework compatibility
  712. * Compatible with the TensorFlow operator ScatterUpdate.
  713. */
  714. REG_OP(ScatterUpdate)
  715. .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8}))
  716. .INPUT(indices, TensorType({DT_INT32}))
  717. .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8}))
  718. .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8}))
  719. .ATTR(use_locking, Bool, false)
  720. .OP_END_FACTORY_REG(ScatterUpdate)
  721. /**
  722. *@brief Returns a tensor with the `k[0]`-th to `k[1]`-th diagonals of the batched `input` . \n
  723. *@par Inputs:
  724. * Three inputs, including:
  725. *@li input: Rank `r` tensor where `r >= 2`. \n
  726. *@li k: \n
  727. *Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main \n
  728. *diagonal, and negative value means subdiagonals. `k` can be a single integer \n
  729. *(for a single diagonal) or a pair of integers specifying the low and high ends \n
  730. *of a matrix band. `k[0]` must not be larger than `k[1]`. \n
  731. *@li padding_value: The value to fill the area outside the specified diagonal band with. \n
  732. *@par Outputs:
  733. *diagonal: The extracted diagonal(s) . \n
  734. *@par Third-party framework compatibility
  735. * Compatible with the TensorFlow operator ScatterUpdate.
  736. */
  737. REG_OP(MatrixDiagPartV2)
  738. .INPUT(input, TensorType::BasicType())
  739. .INPUT(k, TensorType({DT_INT32}))
  740. .INPUT(padding_value, TensorType::BasicType())
  741. .OUTPUT(diagonal, TensorType::BasicType())
  742. .OP_END_FACTORY_REG(MatrixDiagPartV2)
  743. /**
  744. *@brief Returns a batched matrix tensor with new batched diagonal values . \n
  745. *@par Inputs:
  746. * Three inputs, including:
  747. *@li input: "Rank `r+1`, where `r >= 1`. \n
  748. *@li diagonal: Rank `r` when `k` is an integer or `k[0] == k[1]`. Otherwise, it has rank `r+1`. \n
  749. *@li k:
  750. *Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main \n
  751. *diagonal, and negative value means subdiagonals. `k` can be a single integer \n
  752. *(for a single diagonal) or a pair of integers specifying the low and high ends \n
  753. *of a matrix band. `k[0]` must not be larger than `k[1]`. \n
  754. *@par Outputs:
  755. *output: Rank `r+1`, with `output.shape = input.shape` . \n
  756. *@par Third-party framework compatibility
  757. * Compatible with the TensorFlow operator ScatterUpdate.
  758. */
  759. REG_OP(MatrixSetDiagV2)
  760. .INPUT(input, TensorType::BasicType())
  761. .INPUT(diagonal, TensorType::BasicType())
  762. .INPUT(k, TensorType({DT_INT32}))
  763. .OUTPUT(output, TensorType::BasicType())
  764. .OP_END_FACTORY_REG(MatrixSetDiagV2)
  765. /**
  766. *@brief Returns a batched diagonal tensor with given batched diagonal values . \n
  767. *@par Inputs:
  768. * Five inputs, including:
  769. *@li diagonal: Rank `r`, where `r >= 1` \n
  770. *@li k:
  771. *Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main \n
  772. *diagonal, and negative value means subdiagonals. `k` can be a single integer \n
  773. *(for a single diagonal) or a pair of integers specifying the low and high ends \n
  774. *of a matrix band. `k[0]` must not be larger than `k[1]`. \n
  775. *@li num_rows:
  776. *The number of rows of the output matrix. If it is not provided, the op assumes \n
  777. *the output matrix is a square matrix and infers the matrix size from k and the \n
  778. *innermost dimension of `diagonal`. \n
  779. *@li num_cols: An NCHW, NHWC, or ND Tensor.
  780. *The number of columns of the output matrix. If it is not provided, the op \n
  781. *assumes the output matrix is a square matrix and infers the matrix size from \n
  782. *k and the innermost dimension of `diagonal`. \n
  783. *@li padding_value: The number to fill the area outside the specified diagonal band with. \n
  784. *@par Outputs:
  785. *output: Has rank `r+1` when `k` is an integer or `k[0] == k[1]`, rank `r` otherwise . \n
  786. *@par Third-party framework compatibility
  787. * Compatible with the TensorFlow operator ScatterUpdate.
  788. */
  789. REG_OP(MatrixDiagV2)
  790. .INPUT(diagonal, TensorType::BasicType())
  791. .INPUT(k, TensorType({DT_INT32}))
  792. .INPUT(num_rows, TensorType({DT_INT32}))
  793. .INPUT(num_cols, TensorType({DT_INT32}))
  794. .INPUT(padding_value, TensorType::BasicType())
  795. .OUTPUT(output, TensorType::BasicType())
  796. .OP_END_FACTORY_REG(MatrixDiagV2)
  797. } // namespace ge
  798. #endif // OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_

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