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

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