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.

reduce_ops.h 53 kB

5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 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
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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
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
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
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
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
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  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 reduce_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Performs reduced batch normalization . \n
  26. *@par Inputs:
  27. *x: A tensor of type float16 or float32. \n
  28. *@par Outputs:
  29. *@li sum: A 1D Tensor of type float32 for SUM reduced "x".
  30. *@li square_sum: A 1D Tensor of type float32 for SUMSQ reduced "x" . \n
  31. *@attention Constraints:
  32. * This operator is a BatchNorm fusion operator for updating the moving
  33. * averages for training.
  34. * This operator is used in conjunction with BNTrainingReduce.
  35. */
  36. REG_OP(BNTrainingReduce)
  37. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  38. .OUTPUT(sum, TensorType({DT_FLOAT}))
  39. .OUTPUT(square_sum, TensorType({DT_FLOAT}))
  40. .OP_END_FACTORY_REG(BNTrainingReduce)
  41. /**
  42. *@brief Performs reduced batch normalization . \n
  43. *@par Inputs:
  44. *x: A tensor of type float16 or float32. \n
  45. *@par Outputs:
  46. *@li sum: A tensor of type float32 for SUM reduced "x".
  47. *@li square_sum: A tensor of type float32 for SUMSQ reduced "x" . \n
  48. *@attention Constraints:
  49. * This operator is a BatchNorm fusion operator for updating the moving
  50. * averages for training.
  51. * This operator is used in conjunction with BN3DTrainingReduce.
  52. */
  53. REG_OP(BN3DTrainingReduce)
  54. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  55. .OUTPUT(sum, TensorType({DT_FLOAT}))
  56. .OUTPUT(square_sum, TensorType({DT_FLOAT}))
  57. .OP_END_FACTORY_REG(BN3DTrainingReduce)
  58. /**
  59. *@brief Performs the backpropagation of BatchNorm . \n
  60. *@par Inputs:
  61. * Seven inputs, including:
  62. *@li grads: A tensor of type float16 or float32, for
  63. * the gradient.
  64. *@li x: A tensor of type float16 or float32.
  65. *@li diff_scale: A tensor of type float32,
  66. * for the mean of "x".
  67. *@li diff_offset: A tensor of type float32,
  68. * for the variance of "x".
  69. *@li scale: A tensor of type float32.
  70. *@li batch_mean: A tensor of type float32,
  71. * for the mean of "x".
  72. *@li batch_variance: A tensor of type float32,
  73. * for the variance of "x" . \n
  74. *@par Attributes:
  75. *epsilon: An optional float32. Defaults to "0.0001". A small float number
  76. * added to the variance of "x" . \n
  77. *@par Outputs:
  78. *y: A Tensor of type float16 or float32, for the offset
  79. * of "x" . \n
  80. *@attention Constraints:
  81. * The preceding layer of this operator must be BNTrainingUpdateGrad . \n
  82. *@see BNTrainingUpdateGrad
  83. */
  84. REG_OP(BNTrainingReduceGrad)
  85. .INPUT(grads, TensorType({DT_FLOAT16,DT_FLOAT}))
  86. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  87. .INPUT(diff_scale, TensorType({DT_FLOAT}))
  88. .INPUT(diff_offset, TensorType({DT_FLOAT}))
  89. .INPUT(scale, TensorType({DT_FLOAT}))
  90. .INPUT(batch_mean, TensorType({DT_FLOAT}))
  91. .INPUT(batch_variance, TensorType({DT_FLOAT}))
  92. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  93. .ATTR(epsilon, Float, 0.0001)
  94. .OP_END_FACTORY_REG(BNTrainingReduceGrad)
  95. /**
  96. *@brief Performs the backpropagation of BatchNorm . \n
  97. *@par Inputs:
  98. * Seven inputs, including:
  99. *@li grads: A tensor of type float16 or float32, for
  100. * the gradient.
  101. *@li x: A tensor of type float16 or float32.
  102. *@li diff_scale: A tensor of type float32,
  103. * for the mean of "x".
  104. *@li diff_offset: A tensor of type float32,
  105. * for the variance of "x".
  106. *@li scale: A tensor of type float32.
  107. *@li batch_mean: A tensor of type float32,
  108. * for the mean of "x".
  109. *@li batch_variance: A tensor of type float32,
  110. * for the variance of "x" . \n
  111. *@par Attributes:
  112. *epsilon: An optional float32. Defaults to "0.0001". A small float number
  113. * added to the variance of "x" . \n
  114. *@par Outputs:
  115. *y: A Tensor of type float16 or float32, for the offset
  116. * of "x" . \n
  117. *@attention Constraints:
  118. * The preceding layer of this operator must be BN3DTrainingReduceGrad . \n
  119. *@see BN3DTrainingReduceGrad
  120. */
  121. REG_OP(BN3DTrainingReduceGrad)
  122. .INPUT(grads, TensorType({DT_FLOAT16,DT_FLOAT}))
  123. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  124. .INPUT(diff_scale, TensorType({DT_FLOAT}))
  125. .INPUT(diff_offset, TensorType({DT_FLOAT}))
  126. .INPUT(scale, TensorType({DT_FLOAT}))
  127. .INPUT(batch_mean, TensorType({DT_FLOAT}))
  128. .INPUT(batch_variance, TensorType({DT_FLOAT}))
  129. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  130. .ATTR(epsilon, Float, 0.0001)
  131. .OP_END_FACTORY_REG(BN3DTrainingReduceGrad)
  132. /**
  133. *@brief Performs reduced batch normalization . \n
  134. *@par Inputs:
  135. * Seven inputs, including:
  136. *@li x: A tensor of type float16 or float32.
  137. *@li sum: A 1D Tensor of type float32 for the output of operator
  138. * BNTrainingReduce.
  139. *@li square_sum: A 1D Tensor of type float32 for the output of operator
  140. * BNTrainingReduce.
  141. *@li scale: A 1D Tensor of type float32, for the scaling factor.
  142. *@li offset: A 1D Tensor of type float32, for the scaling offset.
  143. *@li mean: A 1D Tensor of type float32, for the updated mean.
  144. *@li variance: A 1D Tensor of type float32, for the updated variance . \n
  145. *@par Attributes:
  146. *@li epsilon: A required float32, specifying the small value added to variance
  147. * to avoid dividing by zero.
  148. *@li factor: A required float32, specifying the weight for updating the mean
  149. * and variance . \n
  150. *@par Outputs:
  151. * Five outputs, including:
  152. *@li y: A tensor of type float16 or float32, for normalized "x".
  153. *@li mean: A tensor of type float32, for the updated mean.
  154. *@li variance: A tensor of type float32, for the updated variance.
  155. *@li batch_mean: A 1D Tensor of type float32, for the mean of "x".
  156. *@li batch_variance: A 1D Tensor of type float32, for the variance of "x" . \n
  157. *@attention Constraints:
  158. *@li This operator is a BatchNorm fusion operator for updating the moving
  159. averages for training.
  160. *This operator is used in conjunction with BNTrainingUpdate.
  161. *@li For Ascend 310, the result accuracy fails to reach 1/1000 due to the square
  162. * root instruction.
  163. */
  164. REG_OP(BNTrainingUpdate)
  165. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  166. .INPUT(sum, TensorType({DT_FLOAT}))
  167. .INPUT(square_sum, TensorType({DT_FLOAT}))
  168. .INPUT(scale, TensorType({DT_FLOAT}))
  169. .INPUT(offset, TensorType({DT_FLOAT}))
  170. .INPUT(mean, TensorType({DT_FLOAT}))
  171. .INPUT(variance, TensorType({DT_FLOAT}))
  172. .REQUIRED_ATTR(factor, Float)
  173. .REQUIRED_ATTR(epsilon, Float)
  174. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  175. .OUTPUT(mean, TensorType({DT_FLOAT}))
  176. .OUTPUT(variance, TensorType({DT_FLOAT}))
  177. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  178. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  179. .OP_END_FACTORY_REG(BNTrainingUpdate)
  180. /**
  181. *@brief Performs reduced batch normalization . \n
  182. *@par Inputs:
  183. * Seven inputs, including:
  184. *@li x: A tensor of type float16 or float32.
  185. *@li sum: A tensor of type float32 for the output of operator
  186. * BN3DTrainingUpdate.
  187. *@li square_sum: A tensor of type float32 for the output of operator
  188. * BN3DTrainingUpdate.
  189. *@li scale: A tensor of type float32, for the scaling factor.
  190. *@li offset: A tensor of type float32, for the scaling offset.
  191. *@li mean: A tensor of type float32, for the updated mean.
  192. *@li variance: A tensor of type float32, for the updated variance . \n
  193. *@par Attributes:
  194. *@li epsilon: A required float32, specifying the small value added to variance
  195. * to avoid dividing by zero.
  196. *@li factor: A required float32, specifying the weight for updating the mean
  197. * and variance . \n
  198. *@par Outputs:
  199. * Five outputs, including:
  200. *@li y: A tensor of type float16 or float32, for normalized "x".
  201. *@li mean: A tensor of type float32, for the updated mean.
  202. *@li variance: A tensor of type float32, for the updated variance.
  203. *@li batch_mean: A tensor of type float32, for the mean of "x".
  204. *@li batch_variance: A tensor of type float32, for the variance of "x" . \n
  205. *@attention Constraints:
  206. *@li This operator is a BatchNorm fusion operator for updating the moving
  207. averages for training.
  208. *This operator is used in conjunction with BN3DTrainingUpdate.
  209. *@li For Ascend 310, the result accuracy fails to reach 1/1000 due to the square
  210. * root instruction.
  211. */
  212. REG_OP(BN3DTrainingUpdate)
  213. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  214. .INPUT(sum, TensorType({DT_FLOAT}))
  215. .INPUT(square_sum, TensorType({DT_FLOAT}))
  216. .INPUT(scale, TensorType({DT_FLOAT}))
  217. .INPUT(offset, TensorType({DT_FLOAT}))
  218. .INPUT(mean, TensorType({DT_FLOAT}))
  219. .INPUT(variance, TensorType({DT_FLOAT}))
  220. .REQUIRED_ATTR(factor, Float)
  221. .REQUIRED_ATTR(epsilon, Float)
  222. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  223. .OUTPUT(mean, TensorType({DT_FLOAT}))
  224. .OUTPUT(variance, TensorType({DT_FLOAT}))
  225. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  226. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  227. .OP_END_FACTORY_REG(BN3DTrainingUpdate)
  228. /**
  229. *@brief Performs batch normalization for inference . \n
  230. *@par Inputs:
  231. * Five inputs, including:
  232. *@li x: A tensor of type float16 or float32.
  233. *@li scale: A tensor of type float32, for the scaling factor.
  234. *@li offset: A tensor of type float32, for the scaling offset.
  235. *@li mean: A tensor of type float32, for the mean.
  236. *@li variance: A tensor of type float32, for the variance . \n
  237. *@par Attributes:
  238. *epsilon: An optional float32, specifying the small value added to variance to
  239. * avoid dividing by zero. Defaults to "0.0001" . \n
  240. *@par Outputs:
  241. *y: A tensor of type float16 or float32 for the normalized "x" . \n
  242. *@attention Constraints:
  243. *For Ascend 310, the result accuracy fails to reach 1/1000 due to the square root
  244. * instruction.
  245. */
  246. REG_OP(BNInfer)
  247. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  248. .INPUT(scale, TensorType({DT_FLOAT}))
  249. .INPUT(offset, TensorType({DT_FLOAT}))
  250. .INPUT(mean, TensorType({DT_FLOAT}))
  251. .INPUT(variance, TensorType({DT_FLOAT}))
  252. .REQUIRED_ATTR(epsilon, Float)
  253. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  254. .OP_END_FACTORY_REG(BNInfer)
  255. /**
  256. *@brief Performs reduced batch normalization. For some scene which don't contain
  257. assignmoving average . \n
  258. *@par Inputs:
  259. *Five inputs, including:
  260. *@li x: A tensor of type float16 or float32.
  261. *@li sum: A tensor of type float32 for the output of operator BNTrainingReduce.
  262. *@li square_sum: A tensor of type float32 for the output of operator BNTrainingReduce.
  263. *@li scale: A tensor of type float32, for the scaling factor.
  264. *@li offset: A tensor of type float32, for the scaling offset . \n
  265. *@par Attributes:
  266. *epsilon: A required float32, specifying the small value added to variance to avoid dividing by zero . \n
  267. *@par Outputs:
  268. *Three outputs, including:
  269. *@li y: A tensor of type float16 or float32, for normalized "x".
  270. *@li batch_mean: A tensor of type float32, for the mean of "x".
  271. *@li batch_variance: A tensor of type float32, for the variance of "x" . \n
  272. *@attention Constraints:
  273. *This operator is used in conjunction with BNTrainingReduce.
  274. For Ascend 310, the result accuracy fails to reach 1/1000 due to the square root instruction.
  275. */
  276. REG_OP(BNTrainingUpdateV2)
  277. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  278. .INPUT(sum, TensorType({DT_FLOAT}))
  279. .INPUT(square_sum, TensorType({DT_FLOAT}))
  280. .INPUT(scale, TensorType({DT_FLOAT}))
  281. .INPUT(offset, TensorType({DT_FLOAT}))
  282. .REQUIRED_ATTR(epsilon, Float)
  283. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  284. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  285. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  286. .OP_END_FACTORY_REG(BNTrainingUpdateV2)
  287. /**
  288. *@brief Performs reduced batch normalization v3. For some scene which don't contain
  289. assign moving average . \n
  290. *@par Inputs:
  291. * Five inputs, including:
  292. *@li x: A tensor of type float16 or float32.
  293. *@li sum: A tensor of type float32 for the output of operator BNTrainingReduce.
  294. *@li square_sum: A tensor of type float32 for the output of operator BNTrainingReduce.
  295. *@li scale: A tensor of type float32, for the scaling factor.
  296. *@li offset: A tensor of type float32, for the scaling offset . \n
  297. *@par Attributes:
  298. *epsilon: A required float32, specifying the small value added to variance to avoid dividing by zero . \n
  299. *@par Outputs:
  300. *@li y: A tensor of type float16 or float32, for normalized "x".
  301. *@li batch_mean: A tensor of type float32, for the mean of "x".
  302. *@li batch_variance: A tensor of type float32, for the variance of "x".
  303. *@li reserve_1: A tensor of type float32, for the mean of batch "x". Has the same type as batch_mean.
  304. *@li reserve_2: A tensor of type float32, for the variance of batch "x". Has the same type as batch_mean . \n
  305. *@attention Constraints:
  306. *@li This operator is used in conjunction with BNTrainingReduce.
  307. *@li For Ascend 310, the result accuracy fails to reach 1/1000 due to the square root instruction.
  308. */
  309. REG_OP(BNTrainingUpdateV3)
  310. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  311. .INPUT(sum, TensorType({DT_FLOAT}))
  312. .INPUT(square_sum, TensorType({DT_FLOAT}))
  313. .INPUT(scale, TensorType({DT_FLOAT}))
  314. .INPUT(offset, TensorType({DT_FLOAT}))
  315. .REQUIRED_ATTR(epsilon, Float)
  316. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  317. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  318. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  319. .OUTPUT(reserve_1, TensorType({DT_FLOAT}))
  320. .OUTPUT(reserve_2, TensorType({DT_FLOAT}))
  321. .OP_END_FACTORY_REG(BNTrainingUpdateV3)
  322. /**
  323. *@brief Performs the backpropagation of BatchNorm . \n
  324. *@par Inputs:
  325. * Four inputs, including:
  326. *@li grads: A tensor of type float16 or float32,
  327. * for the gradient.
  328. *@li x: A tensor of type float16 or float32.
  329. *@li batch_mean: A tensor of type float32,
  330. * for the mean of "x".
  331. *@li batch_variance: A tensor of type float32,
  332. * for the variance of "x" . \n
  333. *@par Attributes:
  334. *epsilon: An optional float32. Defaults to "0.0001". A small float number
  335. * added to the variance of "x" . \n
  336. *@par Outputs:
  337. *@li diff_scale: A Tensor of type float32,
  338. * for the offset of "scale".
  339. *@li diff_offset: A Tensor of type float32,
  340. * for the offset of "offset" . \n
  341. */
  342. REG_OP(BNTrainingUpdateGrad)
  343. .INPUT(grads, TensorType({DT_FLOAT16,DT_FLOAT}))
  344. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  345. .INPUT(batch_mean, TensorType({DT_FLOAT}))
  346. .INPUT(batch_variance, TensorType({DT_FLOAT}))
  347. .ATTR(epsilon, Float, 0.0001)
  348. .OUTPUT(diff_scale, TensorType({DT_FLOAT}))
  349. .OUTPUT(diff_offset, TensorType({DT_FLOAT}))
  350. .OP_END_FACTORY_REG(BNTrainingUpdateGrad)
  351. /**
  352. *@brief Performs the backpropagation of BatchNorm . \n
  353. *@par Inputs:
  354. * Four inputs, including:
  355. *@li grads: A tensor of type float16 or float32,
  356. * for the gradient.
  357. *@li x: A tensor of type float16 or float32.
  358. *@li batch_mean: A tensor of type float32,
  359. * for the mean of "x".
  360. *@li batch_variance: A tensor of type float32,
  361. * for the variance of "x" . \n
  362. *@par Attributes:
  363. *epsilon: An optional float32. Defaults to "0.0001". A small float number
  364. * added to the variance of "x" . \n
  365. *@par Outputs:
  366. *@li diff_scale: A Tensor of type float32,
  367. * for the offset of "scale".
  368. *@li diff_offset: A Tensor of type float32,
  369. * for the offset of "offset" . \n
  370. */
  371. REG_OP(BN3DTrainingUpdateGrad)
  372. .INPUT(grads, TensorType({DT_FLOAT16,DT_FLOAT}))
  373. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  374. .INPUT(batch_mean, TensorType({DT_FLOAT}))
  375. .INPUT(batch_variance, TensorType({DT_FLOAT}))
  376. .ATTR(epsilon, Float, 0.0001)
  377. .OUTPUT(diff_scale, TensorType({DT_FLOAT}))
  378. .OUTPUT(diff_offset, TensorType({DT_FLOAT}))
  379. .OP_END_FACTORY_REG(BN3DTrainingUpdateGrad)
  380. /**
  381. *@brief Performs the backpropagation of BatchNorm for inference . \n
  382. *@par Inputs:
  383. * Three inputs, including:
  384. *@li grads: A tensor of type loat16 or float32, for the gradient.
  385. *@li scale: A tensor of type float32.
  386. *@li batch_variance: A tensor of type float32. It is an output of BatchNorm . \n
  387. *@par Attributes:
  388. *epsilon: An optional float32. Defaults to "0.0001". A small float number added to the variance of "x" . \n
  389. *@par Outputs:
  390. *x_backprop: A Tensor of type float16 or float32, for the offset of "x" . \n
  391. *@attention Constraints:
  392. * The preceding layer of this operator must be operator BatchNorm.
  393. */
  394. REG_OP(BNInferGrad)
  395. .INPUT(grads, TensorType({DT_FLOAT16,DT_FLOAT}))
  396. .INPUT(scale, TensorType({DT_FLOAT}))
  397. .INPUT(batch_variance, TensorType({DT_FLOAT}))
  398. .OUTPUT(x_backprop, TensorType({DT_FLOAT16,DT_FLOAT}))
  399. .ATTR(epsilon, Float, 0.0001)
  400. .OP_END_FACTORY_REG(BNInferGrad)
  401. /**
  402. *@brief Computes the sum of elements across dimensions of a tensor . \n
  403. *@par Inputs:
  404. * Two inputs, including:
  405. *@li x: A Tensor. Must be one of the following types:
  406. * float32, float64, int32, uint8, int16, int8,
  407. * complex64, int64, qint8, quint8, qint32, uint16,
  408. * complex128, float16, uint32, uint64, complex64, complex128.
  409. *@li axes: A 1D list or tuple of int32 or int64. Specifies the dimensions to reduce . \n
  410. *@par Attributes:
  411. *keep_dims: An optional bool. If "true", retains reduced dimensions with length 1. Defaults to "false" . \n
  412. *@par Outputs:
  413. *y: The reduced tensor. Has the same type and format as input "x" . \n
  414. *@par Third-party framework compatibility
  415. * Compatible with the TensorFlow operator Sum.
  416. */
  417. REG_OP(ReduceSum)
  418. .INPUT(x, TensorType::NumberType())
  419. .INPUT(axes, TensorType::IndexNumberType())
  420. .OUTPUT(y, TensorType::NumberType())
  421. .ATTR(keep_dims, Bool, false)
  422. .OP_END_FACTORY_REG(ReduceSum)
  423. /**
  424. *@brief Computes the sum of elements across dimensions of a tensor . \n
  425. *@par Inputs:
  426. * One input:
  427. *x: A Tensor. Up to 8D. Must be one of the following types: float16, float32. \n
  428. *@par Attributes:
  429. *@li axes: A required 1D list or tuple of int32 or int64. Specifies the dimensions to reduce.
  430. *@li keep_dims: An optional bool. If "true", retains reduced dimensions with length 1. Defaults to "false" . \n
  431. *@par Outputs:
  432. *y: The reduced tensor. Has the same type and format as input "x" . \n
  433. *@par Third-party framework compatibility
  434. * Compatible with the TensorFlow operator Sum.
  435. *
  436. * @par Restrictions:
  437. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceSum instead.
  438. */
  439. REG_OP(ReduceSumD)
  440. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  441. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  442. .REQUIRED_ATTR(axes, ListInt)
  443. .ATTR(keep_dims, Bool, false)
  444. .OP_END_FACTORY_REG(ReduceSumD)
  445. /**
  446. *@brief Calculate the total mean based on the mean of each device . \n
  447. *@par Inputs:
  448. * Three inputs, including:
  449. *@li x: A Tensor. Must be one of the following types: float16, float32 .
  450. *@li count: A Tensor. Must be one of the following types: float16, float32 .
  451. *@li count_sum: A Tensor. Must be one of the following types: float16, float32 . \n
  452. *@par Attributes:
  453. *@li axes: A required 1D list or tuple of int32 or int64. Specifies the dimensions to reduce.
  454. *@li keepdims: An optional bool. If "true", retains reduced dimensions with length 1. Defaults to "false" . \n
  455. *@par Outputs:
  456. *y: The reduced tensor. Has the same type and format as input "x" . \n
  457. *@par Third-party framework compatibility
  458. * Compatible with the TensorFlow operator Sum.
  459. */
  460. REG_OP(ReduceMeanWithCount)
  461. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  462. .INPUT(count, TensorType({DT_FLOAT, DT_FLOAT16}))
  463. .INPUT(count_sum, TensorType({DT_FLOAT, DT_FLOAT16}))
  464. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  465. .REQUIRED_ATTR(axes, ListInt)
  466. .ATTR(keep_dims, Bool, false)
  467. .OP_END_FACTORY_REG(ReduceMeanWithCount)
  468. /**
  469. *@brief Calculates the "logical sum" of elements of a tensor in a dimension . \n
  470. *@par Inputs:
  471. *One input:
  472. *x: The boolean tensor to reduce . \n
  473. *@par Attributes:
  474. *@li keep_dims: A bool. If true, retains reduced dimensions with length 1.
  475. *@li axis: The dimensions to reduce. If None, reduces all dimensions.
  476. *Must be in the range [- rank (input_sensor), rank (input_sensor)) . \n
  477. *@par Outputs:
  478. *y: The reduced tensor . \n
  479. *@par Third-party framework compatibility
  480. * Compatible with the TensorFlow operator ReduceAll.
  481. *
  482. * @par Restrictions:
  483. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceAll instead.
  484. */
  485. REG_OP(ReduceAllD)
  486. .INPUT(x, TensorType({DT_BOOL}))
  487. .OUTPUT(y, TensorType({DT_BOOL}))
  488. .REQUIRED_ATTR(axes, ListInt)
  489. .ATTR(keep_dims, Bool, false)
  490. .OP_END_FACTORY_REG(ReduceAllD)
  491. /**
  492. *@brief Calculates the "logical sum" of elements of a tensor in a dimension . \n
  493. *@par Inputs:
  494. *Two inputs, including:
  495. *@li x: The boolean tensor to reduce.
  496. *@li axis: A mutable Tensor. The dimensions to reduce. If None, reduces all dimensions. Must be in the range [- rank (input_sensor), rank (input_sensor)) . \n
  497. *@par Attributes:
  498. *keep_dims: A bool. If true, retains reduced dimensions with length 1 . \n
  499. *@par Outputs:
  500. *y: The reduced tensor . \n
  501. *@par Third-party framework compatibility
  502. * Compatible with the TensorFlow operator ReduceAll.
  503. */
  504. REG_OP(ReduceAll)
  505. .INPUT(x, TensorType({DT_BOOL}))
  506. .INPUT(axes, TensorType::IndexNumberType())
  507. .OUTPUT(y, TensorType({DT_BOOL}))
  508. .ATTR(keep_dims, Bool, false)
  509. .OP_END_FACTORY_REG(ReduceAll)
  510. /**
  511. *@brief Reduce a tensor on a certain axis based on product. . \n
  512. *@par Inputs:
  513. *Two inputs, including:
  514. *@li x: A mutable Tensor. Must be the type of NumberType.
  515. *@li axis: A mutable Tensor. The dimensions to reduce . \n
  516. *@par Attributes:
  517. *keep_dims: A bool. If true, retains reduced dimensions with length 1. Defaults to "False" . \n
  518. *@par Outputs:
  519. *y: A Tensor. Has the same type and format as input "x" . \n
  520. *@par Third-party framework compatibility
  521. * Compatible with the TensorFlow operator ReduceProd.
  522. */
  523. REG_OP(ReduceProd)
  524. .INPUT(x,TensorType::NumberType())
  525. .INPUT(axes, TensorType::IndexNumberType())
  526. .OUTPUT(y,TensorType::NumberType())
  527. .ATTR(keep_dims, Bool, false)
  528. .OP_END_FACTORY_REG(ReduceProd)
  529. /**
  530. *@brief Computes the product of elements across dimensions of a tensor . \n
  531. *@par Inputs:
  532. * One input:
  533. *x: A Tensor. Must be one of the following types: float16, float, int8, uint8 . \n
  534. *@par Attributes:
  535. *@li axes: A required int8, int16, int32, or int64. Specifies the dimensions to reduce. No default value.
  536. *@li keep_dims: An optional bool. If "True", retains reduced dimensions with length 1. Defaults to "False" . \n
  537. *@par Outputs:
  538. *y: A Tensor. Has the same type and format as input "x" . \n
  539. *@attention Constraints:
  540. * "keep_dims" is in the range [-rank(input_tensor), rank(input_tensor)] . \n
  541. *@par Third-party framework compatibility
  542. * Compatible with the TensorFlow operator ReduceProd.
  543. *
  544. * @par Restrictions:
  545. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceProd instead.
  546. */
  547. REG_OP(ReduceProdD)
  548. .INPUT(x,TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16}))
  549. .OUTPUT(y,TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16}))
  550. .REQUIRED_ATTR(axes, ListInt)
  551. .ATTR(keep_dims, Bool, false)
  552. .OP_END_FACTORY_REG(ReduceProdD)
  553. /**
  554. *@brief Reduces "x" along the dimensions according to "axis" . \n
  555. *@par Inputs:
  556. *Two inputs, including:
  557. * @li x: A Tensor. Must be one of the following types: float16, float32, int8, uint8.
  558. * @li axes: The dimensions to reduce. Must be one of the following types: int, list, tuple, NoneType.
  559. * - If None (the default), reduces all dimensions.
  560. * - Must be in the range [-rank(x), rank(x)) . \n
  561. *@par Attributes:
  562. *keep_dims: A bool or NoneType.
  563. * - If true, retains reduced dimensions with length 1.
  564. * - If false, the rank of the tensor is reduced by 1 for each entry in axis.
  565. *noop_with_empty_axes: A bool.
  566. * - If true, when axes = [], not reduce.
  567. * - If false, when axes = [], reduce all.
  568. *@par Outputs:
  569. *y: A Tensor. Has the same type as "x" . \n
  570. *@par Third-party framework compatibility:
  571. * Compatible with the TensorFlow operator ReduceMean.
  572. */
  573. REG_OP(ReduceMean)
  574. .INPUT(x, TensorType::NumberType())
  575. .INPUT(axes, TensorType::IndexNumberType())
  576. .OUTPUT(y, TensorType::NumberType())
  577. .ATTR(keep_dims, Bool, false)
  578. .ATTR(noop_with_empty_axes, Bool, true)
  579. .OP_END_FACTORY_REG(ReduceMean)
  580. /**
  581. *@brief Reduces "x" along the dimensions according to "axis" . \n
  582. *@par Inputs:
  583. *One input:
  584. * @li x: A Tensor. Must be one of the following types: float16, float32 . \n
  585. *@par Attributes:
  586. *@li axes: The dimensions to reduce. Must be one of the following types: int, list, tuple, NoneType.
  587. * If None (the default), reduces all dimensions.
  588. * Must be in the range [-rank(x), rank(x)).
  589. *@li keep_dims: A bool or NoneType.
  590. * - If true, retains reduced dimensions with length 1.
  591. * - If false, the rank of the tensor is reduced by 1 for each entry in axis.
  592. *@li noop_with_empty_axes: A bool default False.
  593. * - If true, same as tf.
  594. * - If false, when x's shape is [], reduce all dims, for onnx.
  595. *@par Outputs:
  596. *y: A Tensor. Has the same type as "x" . \n
  597. *@par Third-party framework compatibility:
  598. * Compatible with the TensorFlow operator ReduceMean.
  599. *
  600. * @par Restrictions:
  601. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMean instead.
  602. */
  603. REG_OP(ReduceMeanD)
  604. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  605. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  606. .REQUIRED_ATTR(axes, ListInt)
  607. .ATTR(keep_dims, Bool, false)
  608. .ATTR(noop_with_empty_axes, Bool, false)
  609. .OP_END_FACTORY_REG(ReduceMeanD)
  610. /**
  611. *@brief Returns the maximum of elements across dimensions of a Tensor . \n
  612. *@par Inputs:
  613. * Two inputs, including:
  614. *@li x: A multi-dimensional Tensor of type float16, float32, or int16.
  615. *@li axes: A Scalar of type int32, specifying the axes information of the index with the maximum value . \n
  616. *@par Attributes:
  617. *keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false" . \n
  618. *@par Outputs:
  619. *y: A multi-dimensional Tensor, specifying the maximum value of the corresponding axis in the tensor. Has the same type as "x". (If "keep_dims" is set to "false", the output dimensions are reduced by "dimension" compared with that of "x". Otherwise, the output has one fewer dimension than "x".)
  620. *@attention Constraints:
  621. * The value range of "axes" is [-dims, dims - 1]. "dims" indicates the dimension length of "x" . \n
  622. *@par Third-party framework compatibility
  623. * Compatible with TensorFlow operator Max.
  624. */
  625. REG_OP(ReduceMax)
  626. .INPUT(x, TensorType::NumberType())
  627. .INPUT(axes, TensorType::IndexNumberType())
  628. .OUTPUT(y, TensorType::NumberType())
  629. .ATTR(keep_dims, Bool, false)
  630. .OP_END_FACTORY_REG(ReduceMax)
  631. /**
  632. *@brief Returns the maximum of elements across dimensions of a Tensor . \n
  633. *@par Inputs:
  634. *x: A multi-dimensional Tensor of type float16, float32, or int16 . \n
  635. *@par Attributes:
  636. * Two attributes, including:
  637. *@li axes: A required listint, specifying the axes information of the index with the maximum value.
  638. *@li keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false" . \n
  639. *@par Outputs:
  640. *y: A multi-dimensional Tensor, specifying the maximum value of the corresponding axis in the tensor. Has the same type as "x". (If "keep_dims" is set to "false", the output dimensions are reduced by "dimension" compared with that of "x". Otherwise, the output has one fewer dimension than "x".)
  641. *@attention Constraints:
  642. * The value range of "axis" is [-dims, dims - 1]. "dims" indicates the dimension length of "x" . \n
  643. *@par Third-party framework compatibility
  644. * Compatible with TensorFlow operator Max.
  645. *
  646. * @par Restrictions:
  647. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMax instead.
  648. */
  649. REG_OP(ReduceMaxD)
  650. .INPUT(x, TensorType({DT_FLOAT, DT_UINT8, DT_INT8,
  651. DT_FLOAT16, DT_INT32}))
  652. .OUTPUT(y, TensorType({DT_FLOAT, DT_UINT8, DT_INT8,
  653. DT_FLOAT16, DT_INT32}))
  654. .REQUIRED_ATTR(axes, ListInt)
  655. .ATTR(keep_dims, Bool, false)
  656. .OP_END_FACTORY_REG(ReduceMaxD)
  657. /**
  658. *@brief Computes the minimum of elements across dimensions of a tensor . \n
  659. *@par Inputs:
  660. *@li input_tensor: A Tensor. Must be one of the following types: float16, float32, int8, uint8.
  661. *@li axes: A Tensor of type int8 or int32. Specifies the dimensions to reduce. Defaults to "None".
  662. *@par Attributes:
  663. *keep_dims: An optional bool. If "True", reduced dimensions will be retained. Defaults to "False".
  664. *@par Outputs:
  665. *output_tensor: A Tensor. Must be one of the following types: float16, float32, int8, uint8 . \n
  666. *@attention Constraints:
  667. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  668. *@par Third-party framework compatibility
  669. * Compatible with the TensorFlow operator reduce_min.
  670. */
  671. REG_OP(ReduceMin)
  672. .INPUT(x, TensorType::NumberType())
  673. .INPUT(axes, TensorType::IndexNumberType())
  674. .OUTPUT(y, TensorType::NumberType())
  675. .ATTR(keep_dims, Bool, false)
  676. .OP_END_FACTORY_REG(ReduceMin)
  677. /**
  678. *@brief Computes the minimum of elements across dimensions of a tensor . \n
  679. *@par Inputs:
  680. *input_min: A Tensor. Must be one of the following types: float16, float32, int8, uint8 . \n
  681. *@par Attributes:
  682. *@li axes: An optional int32, list, tuple, or NoneType value. Specifies the dimensions to reduce. Defaults to "None".
  683. *@li keep_dims: An optional bool or NoneType value. If "True", reduced dimensions will be retained. Defaults to "None" (equivalent to "False").
  684. *@par Outputs:
  685. *output_min: A Tensor. Must be one of the following types: float16, float32, int8, uint8 . \n
  686. *@attention Constraints:
  687. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  688. *@par Third-party framework compatibility
  689. * Compatible with the TensorFlow operator reduce_min.
  690. *
  691. * @par Restrictions:
  692. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMin instead.
  693. */
  694. REG_OP(ReduceMinD)
  695. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8,DT_INT32}))
  696. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8,DT_INT32}))
  697. .REQUIRED_ATTR(axes, ListInt)
  698. .ATTR(keep_dims, Bool, false)
  699. .OP_END_FACTORY_REG(ReduceMinD)
  700. /**
  701. *@brief Computes the "logical or" of elements across dimensions of a tensor.
  702. * Reduces "x" along the dimensions given in "axes".
  703. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  704. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  705. * are retained with length 1.
  706. *
  707. * If "axes" is None, all dimensions are reduced, and a
  708. * tensor with a single element is returned.
  709. *
  710. *@attention Constraints:
  711. * Only support bool
  712. *
  713. *@par Inputs:
  714. *@li x : The boolean tensor to reduce.
  715. *@li axes: The dimensions to reduce. If "None" (default), reduces all
  716. * dimensions. Must be in the range "[-rank(x), rank(x))".
  717. *
  718. *@par Attributes:
  719. * keep_dims: If true, retains reduced dimensions with length 1.
  720. *
  721. *@par Outputs:
  722. * y: The reduced tensor
  723. *
  724. *@par Third-party framework compatibility
  725. *Compatible with the TensorFlow operator reduce_any.
  726. *
  727. */
  728. REG_OP(ReduceAny)
  729. .INPUT(x, TensorType({DT_BOOL}))
  730. .INPUT(axes, TensorType::IndexNumberType())
  731. .OUTPUT(y, TensorType({DT_BOOL}))
  732. .ATTR(keep_dims, Bool, false)
  733. .OP_END_FACTORY_REG(ReduceAny)
  734. /**
  735. *@brief Computes the "logical or" of elements across dimensions of a tensor.
  736. * Reduces "x" along the dimensions given in "axes".
  737. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  738. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  739. * are retained with length 1.
  740. *
  741. * If "axis" is None, all dimensions are reduced, and a
  742. * tensor with a single element is returned.
  743. *
  744. *@attention Constraints:
  745. * Only support bool
  746. *
  747. *@par Inputs:
  748. * x: The boolean tensor to reduce.
  749. *
  750. *@par Attributes:
  751. *@li axes: The dimensions to reduce. Must be in the range "[-rank(x), rank(x))".
  752. *@li keep_dims: If true, retains reduced dimensions with length 1.
  753. *
  754. *@par Outputs:
  755. * y: The reduced tensor
  756. *
  757. *@par Third-party framework compatibility
  758. *Compatible with the TensorFlow operator reduce_any.
  759. *
  760. * @par Restrictions:
  761. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceAny instead.
  762. */
  763. REG_OP(ReduceAnyD)
  764. .INPUT(x, TensorType({DT_BOOL}))
  765. .OUTPUT(y, TensorType({DT_BOOL}))
  766. .REQUIRED_ATTR(axes, ListInt)
  767. .ATTR(keep_dims, Bool, false)
  768. .OP_END_FACTORY_REG(ReduceAnyD)
  769. /**
  770. *@brief Compute reduction on dimensions specified by "axis".
  771. *Four reduction operations are provided:
  772. *SUM Computes the sum of elements across specified dimensions of a tensor.
  773. *ASUM Computes the sum of absolute values of elements across specified dimensions of a tensor.
  774. *SUMSQ Computes the sum of squares of elements across specified dimensions of a tensor.
  775. *SUMSQ Computes the mean values of elements across specified dimensions of a tensor . \n
  776. *@par Inputs:
  777. *x: A Tensor of type float16 or float32
  778. *@par Attributes:
  779. *@li operation: An optional int32 from 1(SUM), 2(ASUM), 3(SUMSQ), and 4(MEAN),
  780. *specifying the reduction algorithm. Defaults to "1".
  781. *@li axis: An optional int32, specifying the first axis to reduce. Defaults to "0".
  782. *The value range is [-N, N-1], where N is the input tensor rank.
  783. *@li coeff: An optional float32, specifying the scale coefficient. Defaults to "1.0" . \n
  784. *@par Outputs:
  785. *y: A Tensor. Has the same type as "x" . \n
  786. *@attention Constraints: The Reduction operator supports type float16 only on the device chip.
  787. *@par Third-party framework compatibility
  788. * Compatible with the Caffe operator Reduction.
  789. */
  790. REG_OP(Reduction)
  791. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  792. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  793. .ATTR(operation, Int, 1)
  794. .ATTR(axis, Int, 0)
  795. .ATTR(coeff, Float, 1.0)
  796. .OP_END_FACTORY_REG(Reduction);
  797. /**
  798. *@brief Computes the euclidean norm of elements across dimensions of a tensor . \n
  799. *@par Inputs:
  800. *@li x: A Tensor. Must be one of the following types: float16, float32, int32.
  801. *@li axes: A Tensor of type int8 or int32. Specifies the dimensions to reduce. Defaults to "None" . \n
  802. *@par Attributes:
  803. *keep_dims: An optional bool. If "True", reduced dimensions will be retained. Defaults to "False" . \n
  804. *@par Outputs:
  805. *y: A Tensor. Must be one of the following types: float16, float32, int32 . \n
  806. *@attention Constraints:
  807. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  808. *@par Third-party framework compatibility
  809. * Compatible with the TensorFlow operator EuclideanNorm.
  810. */
  811. REG_OP(EuclideanNorm)
  812. .INPUT(x, TensorType::NumberType())
  813. .INPUT(axes, TensorType::IndexNumberType())
  814. .OUTPUT(y, TensorType::NumberType())
  815. .ATTR(keep_dims, Bool, false)
  816. .OP_END_FACTORY_REG(EuclideanNorm)
  817. /**
  818. *@brief Computes the euclidean norm of elements across dimensions of a tensor . \n
  819. *@par Inputs:
  820. *input_min: A Tensor. Must be one of the following types: float16, float32, int32 . \n
  821. *@par Attributes:
  822. *@li axes: An optional int32, list, tuple, or NoneType value. Specifies the dimensions to reduce. Defaults to "None".
  823. *@li keep_dims: An optional bool or NoneType value. If "True", reduced dimensions will be retained. Defaults to "None" (equivalent to "False") . \n
  824. *@par Outputs:
  825. *output_min: A Tensor. Must be one of the following types: float16, float32, int32 . \n
  826. *@attention Constraints:
  827. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  828. *@par Third-party framework compatibility
  829. * Compatible with the TensorFlow operator EuclideanNorm.
  830. *
  831. * @par Restrictions:
  832. * Warning: THIS FUNCTION IS DEPRECATED. Please use EuclideanNorm instead.
  833. */
  834. REG_OP(EuclideanNormD)
  835. .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16}))
  836. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16}))
  837. .ATTR(axes, ListInt, {})
  838. .ATTR(keep_dims, Bool, false)
  839. .OP_END_FACTORY_REG(EuclideanNormD)
  840. /**
  841. *@brief Performs instance normalization for inference . \n
  842. *@par Inputs:
  843. * Five inputs, including:
  844. *@li x: A Tensor of type float16 or float32.
  845. *@li gamma: A [N, C1, 1, 1, C0] Tensor of type float32, for the scaling gamma.
  846. *@li beta: A [N, C1, 1, 1, C0] Tensor of type float32, for the scaling beta.
  847. *@li mean: A [N, C1, 1, 1, C0] ensor of type float32, for the mean.
  848. *@li variance: A [N, C1, 1, 1, C0] Tensor of type float32, for the variance . \n
  849. *@par Attributes:
  850. *epsilon: An optional float32, specifying the small value added to variance to avoid dividing by zero.
  851. Defaults to "0.00001" . \n
  852. *@par Outputs:
  853. *@li y: A Tensor of type float16 or float32 for the normalized "x".
  854. *@li batch_mean: A Tensor of type float32 for the result mean.
  855. *@li batch_ variance: A Tensor of type float32 for the result variance . \n
  856. *@attention Constraints:
  857. *For Ascend 310, the result accuracy fails to reach 0.001 due to the square root instruction.
  858. */
  859. REG_OP(INInferV2)
  860. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  861. .OPTIONAL_INPUT(gamma, TensorType({DT_FLOAT}))
  862. .OPTIONAL_INPUT(beta, TensorType({DT_FLOAT}))
  863. .OPTIONAL_INPUT(mean, TensorType({DT_FLOAT}))
  864. .OPTIONAL_INPUT(variance, TensorType({DT_FLOAT}))
  865. .ATTR(epsilon, Float, 0.00001)
  866. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  867. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  868. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  869. .OP_END_FACTORY_REG(INInferV2)
  870. /**
  871. *@brief Performs reduce instance normalization. \n
  872. *@par Inputs:
  873. *x: A Tensor of type float16 or float32. \n
  874. *@par Outputs:
  875. *@li sum: A Tensor of type float32 for SUM reduced "x".
  876. *@li square_sum: A Tensor of type float32 for SUMSQ reduced "x" . \n
  877. *@attention Constraints:
  878. * This operator is a InstanceNorm fusion operator for updating the moving averages for training.
  879. * This operator is used in conjunction with INTrainingUpdateV2.
  880. */
  881. REG_OP(INTrainingReduceV2)
  882. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  883. .OUTPUT(sum, TensorType({DT_FLOAT}))
  884. .OUTPUT(square_sum, TensorType({DT_FLOAT}))
  885. .OP_END_FACTORY_REG(INTrainingReduceV2)
  886. /**
  887. *@brief Performs update instance normalization. \n
  888. *@par Inputs:
  889. * Seven inputs, including:
  890. *@li x: A Tensor of type float16 or float32.
  891. *@li sum: A Tensor of type float32 for the output of operator INTrainingReduceV2.
  892. *@li square_sum: A Tensor of type float32 for the output of operator INTrainingReduceV2.
  893. *@li gamma: A Tensor of type float32, for the scaling gamma.
  894. *@li beta: A Tensor of type float32, for the scaling beta.
  895. *@li mean: A Tensor of type float32, for the updated mean.
  896. *@li variance: A Tensor of type float32, for the updated variance. \n
  897. *@par Attributes:
  898. *@li momentum: A required float32, specifying the momentum to update mean and var.
  899. *@li epsilon: A required float32, specifying the small value added to variance to avoid dividing by zero. \n
  900. *@par Outputs:
  901. * Three outputs
  902. *@li y: A Tensor of type float16 or float32, for normalized "x".
  903. *@li batch_mean: A Tensor of type float32, for the updated mean.
  904. *@li batch_variance: A Tensor of type float32, for the updated variance. \n
  905. *@attention Constraints:
  906. * This operator is a InstanceNorm fusion operator for updating the moving averages for training.
  907. * This operator is used in conjunction with INTrainingReduceV2.
  908. */
  909. REG_OP(INTrainingUpdateV2)
  910. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  911. .INPUT(sum, TensorType({DT_FLOAT}))
  912. .INPUT(square_sum, TensorType({DT_FLOAT}))
  913. .OPTIONAL_INPUT(gamma, TensorType({DT_FLOAT}))
  914. .OPTIONAL_INPUT(beta, TensorType({DT_FLOAT}))
  915. .OPTIONAL_INPUT(mean, TensorType({DT_FLOAT}))
  916. .OPTIONAL_INPUT(variance, TensorType({DT_FLOAT}))
  917. .ATTR(momentum, Float, 0.1)
  918. .ATTR(epsilon, Float, 0.00001)
  919. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  920. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  921. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  922. .OP_END_FACTORY_REG(INTrainingUpdateV2)
  923. /**
  924. *@brief Performs the backpropagation of InstanceNorm. \n
  925. *@par Inputs:
  926. * Seven inputs, including:
  927. *@li dy: A Tensor of type float16 or float32.
  928. *@li x: A Tensor of type float16 or float32.
  929. *@li variance: A Tensor of type float32, for the variance of "x".
  930. *@li mean: A Tensor of type float32, for the mean of "x".
  931. *@li res_gamma: A Tensor of type float32.
  932. *@li res_beta: A Tensor of type float32.
  933. *@li gamma: A Tensor of type float32. \n
  934. *@par Outputs:
  935. *pd_x: A Tensor of type float16 or float32, for the offset of "x". \n
  936. *@attention Constraints:
  937. * The preceding layer of this operator must be INTrainingUpdateGrad. \n
  938. */
  939. REG_OP(INTrainingReduceGrad)
  940. .INPUT(dy, TensorType({DT_FLOAT16,DT_FLOAT}))
  941. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  942. .INPUT(variance, TensorType({DT_FLOAT}))
  943. .INPUT(mean, TensorType({DT_FLOAT}))
  944. .INPUT(res_gamma, TensorType({DT_FLOAT}))
  945. .INPUT(res_beta, TensorType({DT_FLOAT}))
  946. .INPUT(gamma, TensorType({DT_FLOAT}))
  947. .OUTPUT(pd_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  948. .OP_END_FACTORY_REG(INTrainingReduceGrad)
  949. /**
  950. *@brief Performs the backpropagation of InstanceNorm. \n
  951. *@par Inputs:
  952. * Four inputs, including:
  953. *@li dy: A Tensor of type float16 or float32, for the gradient.
  954. *@li x: A Tensor of type float16 or float32.
  955. *@li variance: A Tensor of type float32, for the variance of "x".
  956. *@li mean: A Tensor of type float32, for the mean of "x". \n
  957. *@par Outputs:
  958. *@li res_gamma: A Tensor of type float32.
  959. *@li res_beta: A Tensor of type float32. \n
  960. */
  961. REG_OP(INTrainingUpdateGrad)
  962. .INPUT(dy, TensorType({DT_FLOAT16,DT_FLOAT}))
  963. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  964. .INPUT(variance, TensorType({DT_FLOAT}))
  965. .INPUT(mean, TensorType({DT_FLOAT}))
  966. .OUTPUT(res_gamma, TensorType({DT_FLOAT}))
  967. .OUTPUT(res_beta, TensorType({DT_FLOAT}))
  968. .OP_END_FACTORY_REG(INTrainingUpdateGrad)
  969. /**
  970. *@brief Performs the backpropagation of InstanceNorm. \n
  971. *@par Inputs:
  972. * Two inputs, including:
  973. *@li res_gamma: A Tensor of type float32.
  974. *@li res_beta: A Tensor of type float32. \n
  975. *@par Outputs:
  976. *@li pd_gamma: A Tensor of type float32.
  977. *@li pd_beta: A Tensor of type float32. \n
  978. */
  979. REG_OP(INTrainingUpdateGradGammaBeta)
  980. .INPUT(res_gamma, TensorType({DT_FLOAT}))
  981. .INPUT(res_beta, TensorType({DT_FLOAT}))
  982. .OUTPUT(pd_gamma, TensorType({DT_FLOAT}))
  983. .OUTPUT(pd_beta, TensorType({DT_FLOAT}))
  984. .OP_END_FACTORY_REG(INTrainingUpdateGradGammaBeta)
  985. /**
  986. *@brief Performs reduced group normalization . \n
  987. *@par Inputs:
  988. *x: A Tensor of type float16 or float32, with format NCHW NHWC . \n
  989. *@par Outputs:
  990. *@li sum: A Tensor of type float32 for SUM reduced "x".
  991. *@li square_sum: A Tensor of type float32 for SUMSQ reduced "x".
  992. *@par Attributes:
  993. *num_groups: Int, specifying the num of groups. required, same to GNTrainingUpdate . \n
  994. *@attention Constraints:
  995. * This operator is a GroupNorm fusion operator for updating the moving averages for training.
  996. * This operator is used in conjunction with GNTrainingUpdate.
  997. */
  998. REG_OP(GNTrainingReduce)
  999. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1000. .OUTPUT(sum, TensorType({DT_FLOAT}))
  1001. .OUTPUT(square_sum, TensorType({DT_FLOAT}))
  1002. .ATTR(num_groups, Int, 2)
  1003. .OP_END_FACTORY_REG(GNTrainingReduce)
  1004. /**
  1005. *@brief Performs update group normalization . \n
  1006. *@par Inputs:
  1007. * Seven inputs, including: (NCHW NHWC supported)
  1008. *@li x: A Tensor of type float16 or float32.
  1009. *@li sum: A tensor of type float32,
  1010. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1011. for the output of operator GNTrainingReduce.
  1012. *@li square_sum: A tensor of type float32,
  1013. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1014. for the output of operator GNTrainingReduce.
  1015. *@li scale: A tensor of type float32,
  1016. shape is [1, G, 1, 1, 1] for NCHW, [1, 1, 1, G, 1] for NHWC
  1017. is for the scaling gamma.
  1018. *@li offset: A tensor of type float32,
  1019. shape is [1, G, 1, 1, 1] for NCHW, [1, 1, 1, G, 1] for NHWC
  1020. for the scaling beta.
  1021. *@li mean: A tensor of type float32,
  1022. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1023. for the updated mean.
  1024. *@li variance: A tensor of type float32,
  1025. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1026. for the updated variance.
  1027. *@par Attributes:
  1028. *@li epsilon: A float32, specifying the small value added to variance to avoid dividing by zero.
  1029. *@li num_groups: Int, specifying the num of groups. required, same to GNTrainingReduce
  1030. *@par Outputs:
  1031. * Three outputs, including:
  1032. *@li y: A Tensor of type float16 or float32, for normalized "x".
  1033. *@li batch_mean: A Tensor of type float32, for the updated mean.
  1034. *@li batch_variance: A Tensor of type float32, for the updated variance . \n
  1035. *@attention Constraints:
  1036. *@li This operator is a InstanceNorm fusion operator for updating the moving averages for training.
  1037. * This operator is used in conjunction with GNTrainingUpdate.
  1038. *@li For Ascend 310, the result accuracy fails to reach 1/1000 due to the square root instruction.
  1039. */
  1040. REG_OP(GNTrainingUpdate)
  1041. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1042. .INPUT(sum, TensorType({DT_FLOAT}))
  1043. .INPUT(square_sum, TensorType({DT_FLOAT}))
  1044. .OPTIONAL_INPUT(scale, TensorType({DT_FLOAT}))
  1045. .OPTIONAL_INPUT(offset, TensorType({DT_FLOAT}))
  1046. .OPTIONAL_INPUT(mean, TensorType({DT_FLOAT}))
  1047. .OPTIONAL_INPUT(variance, TensorType({DT_FLOAT}))
  1048. .ATTR(num_groups, Int, 2)
  1049. .ATTR(epsilon, Float, 0.0001)
  1050. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1051. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  1052. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  1053. .OP_END_FACTORY_REG(GNTrainingUpdate)
  1054. /**
  1055. *@brief Joins a string Tensor across the given dimensions. \n
  1056. *@par Inputs:
  1057. include:
  1058. *@li input:A Tensor of type string. The text to be processed.
  1059. *@li reduction_indices:A Tensor of type int. The text to be processed.
  1060. *@par Attributes:
  1061. *@li keep_dims:A bool, An optional bool. Defaults to False. If True, retain reduced dimensions with length 1..
  1062. *@li separator:string.
  1063. *@par Outputs:
  1064. *output:A Tensor of type string.
  1065. */
  1066. REG_OP(ReduceJoin)
  1067. .INPUT(input, TensorType({DT_STRING}))
  1068. .INPUT(reduction_indices, TensorType({DT_INT32}))
  1069. .OUTPUT(output, TensorType({DT_STRING}))
  1070. .ATTR(keep_dims, Bool, true)
  1071. .ATTR(separator, String, "")
  1072. .OP_END_FACTORY_REG(ReduceJoin)
  1073. /**
  1074. * @brief Calculates the standard deviation and average value of Tensors.
  1075. * @par Inputs:
  1076. * x: A Tensor. Must be one of the following types:
  1077. * float16, float32. \n
  1078. * @par Attributes:
  1079. * Three Attributes, including:
  1080. * @li dim: An optional listint, Defaults to "None". \n
  1081. * @li unbiased: An optional bool. Defaults to "True".
  1082. * If "True", Use Bessel Correction.
  1083. * If "False", Do not use Bessel Correction. \n
  1084. * @li keepdim: An optional bool. Defaults to "False".
  1085. * If "True", Keep the original tensor dimension.
  1086. * If "False", Do not keep the original tensor dimension. \n
  1087. * @par Outputs:
  1088. * Two Outputs, including:
  1089. * @li y1: A Tensor. Has the same type as "x".
  1090. * @li y2: A Tensor. Has the same type as "x". \n
  1091. * @par Third-party framework compatibility
  1092. * Compatible with the Pytorch operator ReduceStd.
  1093. */
  1094. REG_OP(ReduceStd)
  1095. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1096. .OUTPUT(y1, TensorType({DT_FLOAT, DT_FLOAT16}))
  1097. .OUTPUT(y2, TensorType({DT_FLOAT, DT_FLOAT16}))
  1098. .ATTR(dim, ListInt, {})
  1099. .ATTR(unbiased, Bool, true)
  1100. .ATTR(keepdim, Bool, false)
  1101. .OP_END_FACTORY_REG(ReduceStd)
  1102. /**
  1103. * @brief Calculates the standard deviation of Tensors.
  1104. * @par Inputs:
  1105. * include:
  1106. * @li x: A Tensor. Must be one of the following types: float16, float32. \n
  1107. * @li mean: A Tensor. It's the mean of X. Must be one of the following types: float16, float32. \n
  1108. * @par Attributes:
  1109. * Five Attributes, including:
  1110. * @li dim: An optional listint, Defaults to "None". \n
  1111. * @li unbiased: An optional bool. Defaults to "True".
  1112. * If "True", Use Bessel Correction.
  1113. * If "False", Do not use Bessel Correction. \n
  1114. * @li keepdim: An optional bool. Defaults to "False".
  1115. * If "True", Keep the original tensor dimension.
  1116. * If "False", Do not keep the original tensor dimension. \n
  1117. * @li invert: An optional bool, Defaults to "False".
  1118. * If "True", the output is inverse of variance.
  1119. * If "False", the output is variance.
  1120. * @li epsilon: An optional floar, Defaults to 0.001.
  1121. * Prevent division by 0.
  1122. * @par Outputs:
  1123. * @li y: A Tensor. It's the variance of X or reciprocal of vaiance of X. Has the same type as "x".
  1124. * @par Third-party framework compatibility
  1125. * Compatible with the Pytorch operator ReduceStdWithMean.
  1126. */
  1127. REG_OP(ReduceStdWithMean)
  1128. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1129. .INPUT(mean, TensorType({DT_FLOAT, DT_FLOAT16}))
  1130. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  1131. .ATTR(dim, ListInt, {})
  1132. .ATTR(unbiased, Bool, true)
  1133. .ATTR(keepdim, Bool, false)
  1134. .ATTR(invert, Bool, false)
  1135. .ATTR(epsilon, Float, 0.001)
  1136. .OP_END_FACTORY_REG(ReduceStdWithMean)
  1137. /**
  1138. *@brief Performs reduced batch normalization . \n
  1139. *@par Inputs:
  1140. *x: A tensor of type float16 or float32 . \n
  1141. *@par Outputs:
  1142. *@li mean: A Tensor of type float32 for SUM reduced "x".
  1143. *@li variance: A Tensor of type float32 for square sum reduced "x" . \n
  1144. *@par Restrictions:
  1145. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1146. */
  1147. REG_OP(ReduceMeanVariance)
  1148. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1149. .OUTPUT(mean, TensorType({DT_FLOAT16,DT_FLOAT}))
  1150. .OUTPUT(variance, TensorType({DT_FLOAT16,DT_FLOAT}))
  1151. .ATTR(axes, ListInt, {})
  1152. .ATTR(keep_dims, Bool, true)
  1153. .OP_END_FACTORY_REG(ReduceMeanVariance)
  1154. /**
  1155. * @brief Calculates the standard deviation or the variance of Tensors with the average value.
  1156. * @par Inputs:
  1157. * Two inputs, including:
  1158. * @li x: A Tensor. Must be one of the following types: float16, float32. \n
  1159. * @li mean: A Tensor. It's the mean of X. Has the same shape and type as "x" \n
  1160. * @par Attributes:
  1161. * Four Attributes, including:
  1162. * @li dim: An listint. \n
  1163. * @li if_std: An optional bool. Defaults to "False"
  1164. * If "True", Calculate the standard deviation
  1165. * If "False", Calculate the variance
  1166. * @li unbiased: An optional bool. Defaults to "True".
  1167. * If "True", Use Bessel Correction.
  1168. * If "False", Do not use Bessel Correction. \n
  1169. * @li keepdim: An optional bool. Defaults to "False".
  1170. * If "True", Keep the original tensor dimension.
  1171. * If "False", Do not keep the original tensor dimension. \n
  1172. * @par Outputs:
  1173. * @li output_var: A Tensor. It's the standard deviation or the variance of X. Has the same type as "x".
  1174. * @par Third-party framework compatibility
  1175. * Compatible with the Pytorch operator Var_mean.
  1176. */
  1177. REG_OP(ReduceStdV2Update)
  1178. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  1179. .INPUT(mean, TensorType({DT_FLOAT,DT_FLOAT16}))
  1180. .OUTPUT(output_var, TensorType({DT_FLOAT,DT_FLOAT16}))
  1181. .REQUIRED_ATTR(dim, ListInt)
  1182. .ATTR(if_std, Bool, false)
  1183. .ATTR(unbiased, Bool, true)
  1184. .ATTR(keepdim, Bool, false)
  1185. .OP_END_FACTORY_REG(ReduceStdV2Update)
  1186. /**
  1187. *@brief Computes the log and sum and exp of elements across dimensions of a tensor.
  1188. * Reduces "x" along the dimensions given in "axes".
  1189. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  1190. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  1191. * are retained with length 1.
  1192. *
  1193. *@par Inputs:
  1194. * Two inputs, including:
  1195. *@li x: A Tensor. Must be one of the following types:
  1196. * float32, float16, int32, int64, uint32, uint64, double
  1197. *@li axes: A 1D list or tuple of int32 or int64. Specifies the dimensions to reduce . \n
  1198. *
  1199. *@par Attributes:
  1200. *keep_dims: An optional bool. If "true", retains reduced dimensions with length 1. Defaults to "false" . \n
  1201. *
  1202. *@par Outputs:
  1203. *y: The reduced tensor. Has the same type and format as input "x" . \n
  1204. *
  1205. *@par Third-party framework compatibility
  1206. * Compatible with the Onnx operator ReduceLogSumExp.
  1207. */
  1208. REG_OP(ReduceLogSumExp)
  1209. .INPUT(x, TensorType::NumberType())
  1210. .INPUT(axes, TensorType::IndexNumberType())
  1211. .OUTPUT(y, TensorType::NumberType())
  1212. .ATTR(keep_dims, Bool, false)
  1213. .OP_END_FACTORY_REG(ReduceLogSumExp)
  1214. /**
  1215. *@brief Computes the log and sum of elements across dimensions of a tensor.
  1216. * Reduces "x" along the dimensions given in "axes".
  1217. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  1218. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  1219. * are retained with length 1.
  1220. *
  1221. *@par Inputs:
  1222. * Two inputs, including:
  1223. *@li x: A Tensor. Must be one of the following types:
  1224. * float32, float16, int32, int64, uint32, uint64, double
  1225. *@li axes: A 1D list or tuple of int32 or int64. Specifies the dimensions to reduce . \n
  1226. *
  1227. *@par Attributes:
  1228. *keep_dims: An optional bool. If "true", retains reduced dimensions with length 1. Defaults to "false" . \n
  1229. *
  1230. *@par Outputs:
  1231. *y: The reduced tensor. Has the same type and format as input "x" . \n
  1232. *
  1233. *@par Third-party framework compatibility
  1234. * Compatible with the Onnx operator ReduceLogSum.
  1235. */
  1236. REG_OP(ReduceLogSum)
  1237. .INPUT(x, TensorType::NumberType())
  1238. .INPUT(axes, TensorType::IndexNumberType())
  1239. .OUTPUT(y, TensorType::NumberType())
  1240. .ATTR(keep_dims, Bool, false)
  1241. .OP_END_FACTORY_REG(ReduceLogSum)
  1242. } //namespace ge
  1243. #endif // OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_

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