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 54 kB

5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
3 years ago
5 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 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
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
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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454
  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 5D Tensor of type float16 or float32, with format NC1HWC0 . \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 6D Tensor of type float16 or float32, with format NDC1HWC0 . \n
  45. *@par Outputs:
  46. *@li sum: A 3D Tensor of type float32 for SUM reduced "x".
  47. *@li square_sum: A 3D 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 5D Tensor of type float16 or float32, with format NC1HWC0, for
  63. * the gradient.
  64. *@li x: A 5D Tensor of type float16 or float32, with format NC1HWC0.
  65. *@li diff_scale: A 5D Tensor of type float32, with format NC1HWC0,
  66. * for the mean of "x".
  67. *@li diff_offset: A 5D Tensor of type float32, with format NC1HWC0,
  68. * for the variance of "x".
  69. *@li scale: A 5D Tensor of type float32, with format NC1HWC0.
  70. *@li batch_mean: A 5D Tensor of type float32, with format NC1HWC0,
  71. * for the mean of "x".
  72. *@li batch_variance: A 5D Tensor of type float32, with format NC1HWC0,
  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, with format NC1HWC0, 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 6D Tensor of type float16 or float32, with format NDC1HWC0, for
  100. * the gradient.
  101. *@li x: A 6D Tensor of type float16 or float32, with format NDC1HWC0.
  102. *@li diff_scale: A 6D Tensor of type float32, with format NDC1HWC0,
  103. * for the mean of "x".
  104. *@li diff_offset: A 6D Tensor of type float32, with format NDC1HWC0,
  105. * for the variance of "x".
  106. *@li scale: A 6D Tensor of type float32, with format NDC1HWC0.
  107. *@li batch_mean: A 6D Tensor of type float32, with format NDC1HWC0,
  108. * for the mean of "x".
  109. *@li batch_variance: A 6D Tensor of type float32, with format NDC1HWC0,
  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, with format NDC1HWC0, 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: (NC1HWC0 supported)
  136. *@li x: A 5D 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: (NC1HWC0 supported)
  152. *@li y: A 5D Tensor of type float16 or float32, for normalized "x".
  153. *@li mean: A 5D Tensor of type float32, for the updated mean.
  154. *@li variance: A 5D 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: (NDC1HWC0 supported)
  184. *@li x: A 6D Tensor of type float16 or float32.
  185. *@li sum: A 6D Tensor of type float32 for the output of operator
  186. * BN3DTrainingUpdate.
  187. *@li square_sum: A 6D Tensor of type float32 for the output of operator
  188. * BN3DTrainingUpdate.
  189. *@li scale: A 6D Tensor of type float32, for the scaling factor.
  190. *@li offset: A 6D Tensor of type float32, for the scaling offset.
  191. *@li mean: A 6D Tensor of type float32, for the updated mean.
  192. *@li variance: A 6D 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: (NDC1HWC0 supported)
  200. *@li y: A 6D Tensor of type float16 or float32, for normalized "x".
  201. *@li mean: A 6D Tensor of type float32, for the updated mean.
  202. *@li variance: A 6D Tensor of type float32, for the updated variance.
  203. *@li batch_mean: A 6D Tensor of type float32, for the mean of "x".
  204. *@li batch_variance: A 6D 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: (NC1HWC0 supported)
  232. *@li x: A 5D Tensor of type float16 or float32.
  233. *@li scale: A 5D Tensor of type float32, for the scaling factor.
  234. *@li offset: A 5D Tensor of type float32, for the scaling offset.
  235. *@li mean: A 5D Tensor of type float32, for the mean.
  236. *@li variance: A 5D 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 5D 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: (NC1HWC0 supported)
  260. *@li x: A 5D Tensor of type float16 or float32.
  261. *@li sum: A 5D Tensor of type float32 for the output of operator BNTrainingReduce.
  262. *@li square_sum: A 5D Tensor of type float32 for the output of operator BNTrainingReduce.
  263. *@li scale: A 5D Tensor of type float32, for the scaling factor.
  264. *@li offset: A 5D 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: (NC1HWC0 supported)
  269. *@li y: A 5D Tensor of type float16 or float32, for normalized "x".
  270. *@li batch_mean: A 5D Tensor of type float32, for the mean of "x".
  271. *@li batch_variance: A 5D 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: (NC1HWC0 supported)
  292. *@li x: A 5D Tensor of type float16 or float32.
  293. *@li sum: A 5D Tensor of type float32 for the output of operator BNTrainingReduce.
  294. *@li square_sum: A 5D Tensor of type float32 for the output of operator BNTrainingReduce.
  295. *@li scale: A 5D Tensor of type float32, for the scaling factor.
  296. *@li offset: A 5D 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 5D Tensor of type float16 or float32, for normalized "x".
  301. *@li batch_mean: A 5D Tensor of type float32, for the mean of "x".
  302. *@li batch_variance: A 5D Tensor of type float32, for the variance of "x".
  303. *@li reserve_1: A 5D Tensor of type float32, for the mean of batch "x". Has the same type as batch_mean.
  304. *@li reserve_2: A 5D 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 5D Tensor of type float16 or float32, with format NC1HWC0,
  327. * for the gradient.
  328. *@li x: A 5D Tensor of type float16 or float32, with format NC1HWC0.
  329. *@li batch_mean: A 5D Tensor of type float32, with format NC1HWC0,
  330. * for the mean of "x".
  331. *@li batch_variance: A 5D Tensor of type float32, with format NC1HWC0,
  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, with format NC1HWC0,
  338. * for the offset of "scale".
  339. *@li diff_offset: A Tensor of type float32, with format NC1HWC0,
  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 6D Tensor of type float16 or float32, with format NDC1HWC0,
  356. * for the gradient.
  357. *@li x: A 6D Tensor of type float16 or float32, with format NDC1HWC0.
  358. *@li batch_mean: A 6D Tensor of type float32, with format NDC1HWC0,
  359. * for the mean of "x".
  360. *@li batch_variance: A 6D Tensor of type float32, with format NDC1HWC0,
  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, with format NDC1HWC0,
  367. * for the offset of "scale".
  368. *@li diff_offset: A Tensor of type float32, with format NDC1HWC0,
  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 5D Tensor of type loat16 or float32, with format NC1HWC0, for the gradient.
  385. *@li scale: A 5D Tensor of type float32, with format NC1HWC0.
  386. *@li batch_variance: A 5D Tensor of type float32, with format NC1HWC0. 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, with format NC1HWC0, 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. *@par Outputs:
  566. *y: A Tensor. Has the same type as "x" . \n
  567. *@par Third-party framework compatibility:
  568. * Compatible with the TensorFlow operator ReduceMean.
  569. */
  570. REG_OP(ReduceMean)
  571. .INPUT(x, TensorType::NumberType())
  572. .INPUT(axes, TensorType::IndexNumberType())
  573. .OUTPUT(y, TensorType::NumberType())
  574. .ATTR(keep_dims, Bool, false)
  575. .OP_END_FACTORY_REG(ReduceMean)
  576. /**
  577. *@brief Reduces "x" along the dimensions according to "axis" . \n
  578. *@par Inputs:
  579. *One input:
  580. * @li x: A Tensor. Must be one of the following types: float16, float32 . \n
  581. *@par Attributes:
  582. *@li axes: The dimensions to reduce. Must be one of the following types: int, list, tuple, NoneType.
  583. * If None (the default), reduces all dimensions.
  584. * Must be in the range [-rank(x), rank(x)).
  585. *@li keep_dims: A bool or NoneType.
  586. * - If true, retains reduced dimensions with length 1.
  587. * - If false, the rank of the tensor is reduced by 1 for each entry in axis.
  588. *@par Outputs:
  589. *y: A Tensor. Has the same type as "x" . \n
  590. *@par Third-party framework compatibility:
  591. * Compatible with the TensorFlow operator ReduceMean.
  592. *
  593. * @par Restrictions:
  594. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMean instead.
  595. */
  596. REG_OP(ReduceMeanD)
  597. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  598. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  599. .REQUIRED_ATTR(axes, ListInt)
  600. .ATTR(keep_dims, Bool, false)
  601. .OP_END_FACTORY_REG(ReduceMeanD)
  602. /**
  603. *@brief Returns the maximum of elements across dimensions of a Tensor . \n
  604. *@par Inputs:
  605. * Two inputs, including:
  606. *@li x: A multi-dimensional Tensor of type float16, float32, or int16.
  607. *@li axes: A Scalar of type int32, specifying the axes information of the index with the maximum value . \n
  608. *@par Attributes:
  609. *keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false" . \n
  610. *@par Outputs:
  611. *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".)
  612. *@attention Constraints:
  613. * The value range of "axes" is [-dims, dims - 1]. "dims" indicates the dimension length of "x" . \n
  614. *@par Third-party framework compatibility
  615. * Compatible with TensorFlow operator Max.
  616. */
  617. REG_OP(ReduceMax)
  618. .INPUT(x, TensorType::NumberType())
  619. .INPUT(axes, TensorType::IndexNumberType())
  620. .OUTPUT(y, TensorType::NumberType())
  621. .ATTR(keep_dims, Bool, false)
  622. .OP_END_FACTORY_REG(ReduceMax)
  623. /**
  624. *@brief Returns the maximum of elements across dimensions of a Tensor . \n
  625. *@par Inputs:
  626. *x: A multi-dimensional Tensor of type float16, float32, or int16 . \n
  627. *@par Attributes:
  628. * Two attributes, including:
  629. *@li axes: A required listint, specifying the axes information of the index with the maximum value.
  630. *@li keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false" . \n
  631. *@par Outputs:
  632. *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".)
  633. *@attention Constraints:
  634. * The value range of "axis" is [-dims, dims - 1]. "dims" indicates the dimension length of "x" . \n
  635. *@par Third-party framework compatibility
  636. * Compatible with TensorFlow operator Max.
  637. *
  638. * @par Restrictions:
  639. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMax instead.
  640. */
  641. REG_OP(ReduceMaxD)
  642. .INPUT(x, TensorType({DT_FLOAT, DT_UINT8, DT_INT8,
  643. DT_FLOAT16, DT_INT32}))
  644. .OUTPUT(y, TensorType({DT_FLOAT, DT_UINT8, DT_INT8,
  645. DT_FLOAT16, DT_INT32}))
  646. .REQUIRED_ATTR(axes, ListInt)
  647. .ATTR(keep_dims, Bool, false)
  648. .OP_END_FACTORY_REG(ReduceMaxD)
  649. /**
  650. *@brief Computes the minimum of elements across dimensions of a tensor . \n
  651. *@par Inputs:
  652. *@li input_tensor: A Tensor. Must be one of the following types: float16, float32, int8, uint8.
  653. *@li axes: A Tensor of type int8 or int32. Specifies the dimensions to reduce. Defaults to "None".
  654. *@par Attributes:
  655. *keep_dims: An optional bool. If "True", reduced dimensions will be retained. Defaults to "False".
  656. *@par Outputs:
  657. *output_tensor: A Tensor. Must be one of the following types: float16, float32, int8, uint8 . \n
  658. *@attention Constraints:
  659. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  660. *@par Third-party framework compatibility
  661. * Compatible with the TensorFlow operator reduce_min.
  662. */
  663. REG_OP(ReduceMin)
  664. .INPUT(x, TensorType::NumberType())
  665. .INPUT(axes, TensorType::IndexNumberType())
  666. .OUTPUT(y, TensorType::NumberType())
  667. .ATTR(keep_dims, Bool, false)
  668. .OP_END_FACTORY_REG(ReduceMin)
  669. /**
  670. *@brief Computes the minimum of elements across dimensions of a tensor . \n
  671. *@par Inputs:
  672. *input_min: A Tensor. Must be one of the following types: float16, float32, int8, uint8 . \n
  673. *@par Attributes:
  674. *@li axes: An optional int32, list, tuple, or NoneType value. Specifies the dimensions to reduce. Defaults to "None".
  675. *@li keep_dims: An optional bool or NoneType value. If "True", reduced dimensions will be retained. Defaults to "None" (equivalent to "False").
  676. *@par Outputs:
  677. *output_min: A Tensor. Must be one of the following types: float16, float32, int8, uint8 . \n
  678. *@attention Constraints:
  679. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  680. *@par Third-party framework compatibility
  681. * Compatible with the TensorFlow operator reduce_min.
  682. *
  683. * @par Restrictions:
  684. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMin instead.
  685. */
  686. REG_OP(ReduceMinD)
  687. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8,DT_INT32}))
  688. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8,DT_INT32}))
  689. .REQUIRED_ATTR(axes, ListInt)
  690. .ATTR(keep_dims, Bool, false)
  691. .OP_END_FACTORY_REG(ReduceMinD)
  692. /**
  693. *@brief Computes the "logical or" of elements across dimensions of a tensor.
  694. * Reduces "x" along the dimensions given in "axes".
  695. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  696. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  697. * are retained with length 1.
  698. *
  699. * If "axes" is None, all dimensions are reduced, and a
  700. * tensor with a single element is returned.
  701. *
  702. *@attention Constraints:
  703. * Only support bool
  704. *
  705. *@par Inputs:
  706. *@li x : The boolean tensor to reduce.
  707. *@li axes: The dimensions to reduce. If "None" (default), reduces all
  708. * dimensions. Must be in the range "[-rank(x), rank(x))".
  709. *
  710. *@par Attributes:
  711. * keep_dims: If true, retains reduced dimensions with length 1.
  712. *
  713. *@par Outputs:
  714. * y: The reduced tensor
  715. *
  716. *@par Third-party framework compatibility
  717. *Compatible with the TensorFlow operator reduce_any.
  718. *
  719. */
  720. REG_OP(ReduceAny)
  721. .INPUT(x, TensorType({DT_BOOL}))
  722. .INPUT(axes, TensorType::IndexNumberType())
  723. .OUTPUT(y, TensorType({DT_BOOL}))
  724. .ATTR(keep_dims, Bool, false)
  725. .OP_END_FACTORY_REG(ReduceAny)
  726. /**
  727. *@brief Computes the "logical or" of elements across dimensions of a tensor.
  728. * Reduces "x" along the dimensions given in "axes".
  729. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  730. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  731. * are retained with length 1.
  732. *
  733. * If "axis" is None, all dimensions are reduced, and a
  734. * tensor with a single element is returned.
  735. *
  736. *@attention Constraints:
  737. * Only support bool
  738. *
  739. *@par Inputs:
  740. * x: The boolean tensor to reduce.
  741. *
  742. *@par Attributes:
  743. *@li axes: The dimensions to reduce. Must be in the range "[-rank(x), rank(x))".
  744. *@li keep_dims: If true, retains reduced dimensions with length 1.
  745. *
  746. *@par Outputs:
  747. * y: The reduced tensor
  748. *
  749. *@par Third-party framework compatibility
  750. *Compatible with the TensorFlow operator reduce_any.
  751. *
  752. * @par Restrictions:
  753. * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceAny instead.
  754. */
  755. REG_OP(ReduceAnyD)
  756. .INPUT(x, TensorType({DT_BOOL}))
  757. .OUTPUT(y, TensorType({DT_BOOL}))
  758. .REQUIRED_ATTR(axes, ListInt)
  759. .ATTR(keep_dims, Bool, false)
  760. .OP_END_FACTORY_REG(ReduceAnyD)
  761. /**
  762. *@brief Compute reduction on dimensions specified by "axis".
  763. *Four reduction operations are provided:
  764. *SUM Computes the sum of elements across specified dimensions of a tensor.
  765. *ASUM Computes the sum of absolute values of elements across specified dimensions of a tensor.
  766. *SUMSQ Computes the sum of squares of elements across specified dimensions of a tensor.
  767. *SUMSQ Computes the mean values of elements across specified dimensions of a tensor . \n
  768. *@par Inputs:
  769. *x: A Tensor of type float16 or float32
  770. *@par Attributes:
  771. *@li operation: An optional int32 from 1(SUM), 2(ASUM), 3(SUMSQ), and 4(MEAN),
  772. *specifying the reduction algorithm. Defaults to "1".
  773. *@li axis: An optional int32, specifying the first axis to reduce. Defaults to "0".
  774. *The value range is [-N, N-1], where N is the input tensor rank.
  775. *@li coeff: An optional float32, specifying the scale coefficient. Defaults to "1.0" . \n
  776. *@par Outputs:
  777. *y: A Tensor. Has the same type as "x" . \n
  778. *@attention Constraints: The Reduction operator supports type float16 only on the device chip.
  779. *@par Third-party framework compatibility
  780. * Compatible with the Caffe operator Reduction.
  781. */
  782. REG_OP(Reduction)
  783. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  784. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  785. .ATTR(operation, Int, 1)
  786. .ATTR(axis, Int, 0)
  787. .ATTR(coeff, Float, 1.0)
  788. .OP_END_FACTORY_REG(Reduction);
  789. /**
  790. *@brief Computes the euclidean norm of elements across dimensions of a tensor . \n
  791. *@par Inputs:
  792. *@li x: A Tensor. Must be one of the following types: float16, float32, int32.
  793. *@li axes: A Tensor of type int8 or int32. Specifies the dimensions to reduce. Defaults to "None" . \n
  794. *@par Attributes:
  795. *keep_dims: An optional bool. If "True", reduced dimensions will be retained. Defaults to "False" . \n
  796. *@par Outputs:
  797. *y: A Tensor. Must be one of the following types: float16, float32, int32 . \n
  798. *@attention Constraints:
  799. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  800. *@par Third-party framework compatibility
  801. * Compatible with the TensorFlow operator EuclideanNorm.
  802. */
  803. REG_OP(EuclideanNorm)
  804. .INPUT(x, TensorType::NumberType())
  805. .INPUT(axes, TensorType::IndexNumberType())
  806. .OUTPUT(y, TensorType::NumberType())
  807. .ATTR(keep_dims, Bool, false)
  808. .OP_END_FACTORY_REG(EuclideanNorm)
  809. /**
  810. *@brief Computes the euclidean norm of elements across dimensions of a tensor . \n
  811. *@par Inputs:
  812. *input_min: A Tensor. Must be one of the following types: float16, float32, int32 . \n
  813. *@par Attributes:
  814. *@li axes: An optional int32, list, tuple, or NoneType value. Specifies the dimensions to reduce. Defaults to "None".
  815. *@li keep_dims: An optional bool or NoneType value. If "True", reduced dimensions will be retained. Defaults to "None" (equivalent to "False") . \n
  816. *@par Outputs:
  817. *output_min: A Tensor. Must be one of the following types: float16, float32, int32 . \n
  818. *@attention Constraints:
  819. * If "axes = None", all dimensions will be reduced. "axes" must be in the range [-rank(input_shape), rank(input_shape)) . \n
  820. *@par Third-party framework compatibility
  821. * Compatible with the TensorFlow operator EuclideanNorm.
  822. *
  823. * @par Restrictions:
  824. * Warning: THIS FUNCTION IS DEPRECATED. Please use EuclideanNorm instead.
  825. */
  826. REG_OP(EuclideanNormD)
  827. .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16}))
  828. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16}))
  829. .ATTR(axes, ListInt, {})
  830. .ATTR(keep_dims, Bool, false)
  831. .OP_END_FACTORY_REG(EuclideanNormD)
  832. /**
  833. *@brief Performs instance normalization for inference . \n
  834. *@par Inputs:
  835. * Five inputs, including: (NC1HWC0 supported)
  836. *@li x: A Tensor of type float16 or float32.
  837. *@li gamma: A [N, C1, 1, 1, C0] Tensor of type float32, for the scaling gamma.
  838. *@li beta: A [N, C1, 1, 1, C0] Tensor of type float32, for the scaling beta.
  839. *@li mean: A [N, C1, 1, 1, C0] ensor of type float32, for the mean.
  840. *@li variance: A [N, C1, 1, 1, C0] Tensor of type float32, for the variance . \n
  841. *@par Attributes:
  842. *epsilon: An optional float32, specifying the small value added to variance to avoid dividing by zero.
  843. Defaults to "0.00001" . \n
  844. *@par Outputs:
  845. *@li y: A Tensor of type float16 or float32 for the normalized "x".
  846. *@li batch_mean: A Tensor of type float32 for the result mean.
  847. *@li batch_ variance: A Tensor of type float32 for the result variance . \n
  848. *@attention Constraints:
  849. *For Ascend 310, the result accuracy fails to reach 0.001 due to the square root instruction.
  850. */
  851. REG_OP(INInferV2)
  852. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  853. .OPTIONAL_INPUT(gamma, TensorType({DT_FLOAT}))
  854. .OPTIONAL_INPUT(beta, TensorType({DT_FLOAT}))
  855. .OPTIONAL_INPUT(mean, TensorType({DT_FLOAT}))
  856. .OPTIONAL_INPUT(variance, TensorType({DT_FLOAT}))
  857. .ATTR(epsilon, Float, 0.00001)
  858. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  859. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  860. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  861. .OP_END_FACTORY_REG(INInferV2)
  862. /**
  863. *@brief Performs reduce instance normalization. \n
  864. *@par Inputs:
  865. *x: A Tensor of type float16 or float32. \n
  866. *@par Outputs:
  867. *@li sum: A Tensor of type float32 for SUM reduced "x".
  868. *@li square_sum: A Tensor of type float32 for SUMSQ reduced "x" . \n
  869. *@attention Constraints:
  870. * This operator is a InstanceNorm fusion operator for updating the moving averages for training.
  871. * This operator is used in conjunction with INTrainingUpdateV2.
  872. */
  873. REG_OP(INTrainingReduceV2)
  874. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  875. .OUTPUT(sum, TensorType({DT_FLOAT}))
  876. .OUTPUT(square_sum, TensorType({DT_FLOAT}))
  877. .OP_END_FACTORY_REG(INTrainingReduceV2)
  878. /**
  879. *@brief Performs update instance normalization. \n
  880. *@par Inputs:
  881. * Seven inputs, including:
  882. *@li x: A Tensor of type float16 or float32.
  883. *@li sum: A Tensor of type float32 for the output of operator INTrainingReduceV2.
  884. *@li square_sum: A Tensor of type float32 for the output of operator INTrainingReduceV2.
  885. *@li gamma: A Tensor of type float32, for the scaling gamma.
  886. *@li beta: A Tensor of type float32, for the scaling beta.
  887. *@li mean: A Tensor of type float32, for the updated mean.
  888. *@li variance: A Tensor of type float32, for the updated variance. \n
  889. *@par Attributes:
  890. *@li momentum: A required float32, specifying the momentum to update mean and var.
  891. *@li epsilon: A required float32, specifying the small value added to variance to avoid dividing by zero. \n
  892. *@par Outputs:
  893. * Three outputs
  894. *@li y: A Tensor of type float16 or float32, for normalized "x".
  895. *@li batch_mean: A Tensor of type float32, for the updated mean.
  896. *@li batch_variance: A Tensor of type float32, for the updated variance. \n
  897. *@attention Constraints:
  898. * This operator is a InstanceNorm fusion operator for updating the moving averages for training.
  899. * This operator is used in conjunction with INTrainingReduceV2.
  900. */
  901. REG_OP(INTrainingUpdateV2)
  902. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  903. .INPUT(sum, TensorType({DT_FLOAT}))
  904. .INPUT(square_sum, TensorType({DT_FLOAT}))
  905. .OPTIONAL_INPUT(gamma, TensorType({DT_FLOAT}))
  906. .OPTIONAL_INPUT(beta, TensorType({DT_FLOAT}))
  907. .OPTIONAL_INPUT(mean, TensorType({DT_FLOAT}))
  908. .OPTIONAL_INPUT(variance, TensorType({DT_FLOAT}))
  909. .ATTR(momentum, Float, 0.1)
  910. .ATTR(epsilon, Float, 0.00001)
  911. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  912. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  913. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  914. .OP_END_FACTORY_REG(INTrainingUpdateV2)
  915. /**
  916. *@brief Performs the backpropagation of InstanceNorm. \n
  917. *@par Inputs:
  918. * Seven inputs, including:
  919. *@li dy: A Tensor of type float16 or float32.
  920. *@li x: A Tensor of type float16 or float32.
  921. *@li variance: A Tensor of type float32, for the variance of "x".
  922. *@li mean: A Tensor of type float32, for the mean of "x".
  923. *@li res_gamma: A Tensor of type float32.
  924. *@li res_beta: A Tensor of type float32.
  925. *@li gamma: A Tensor of type float32. \n
  926. *@par Outputs:
  927. *pd_x: A Tensor of type float16 or float32, for the offset of "x". \n
  928. *@attention Constraints:
  929. * The preceding layer of this operator must be INTrainingUpdateGrad. \n
  930. */
  931. REG_OP(INTrainingReduceGrad)
  932. .INPUT(dy, TensorType({DT_FLOAT16,DT_FLOAT}))
  933. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  934. .INPUT(variance, TensorType({DT_FLOAT}))
  935. .INPUT(mean, TensorType({DT_FLOAT}))
  936. .INPUT(res_gamma, TensorType({DT_FLOAT}))
  937. .INPUT(res_beta, TensorType({DT_FLOAT}))
  938. .INPUT(gamma, TensorType({DT_FLOAT}))
  939. .OUTPUT(pd_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  940. .OP_END_FACTORY_REG(INTrainingReduceGrad)
  941. /**
  942. *@brief Performs the backpropagation of InstanceNorm. \n
  943. *@par Inputs:
  944. * Four inputs, including:
  945. *@li dy: A Tensor of type float16 or float32, for the gradient.
  946. *@li x: A Tensor of type float16 or float32.
  947. *@li variance: A Tensor of type float32, for the variance of "x".
  948. *@li mean: A Tensor of type float32, for the mean of "x". \n
  949. *@par Outputs:
  950. *@li res_gamma: A Tensor of type float32.
  951. *@li res_beta: A Tensor of type float32. \n
  952. */
  953. REG_OP(INTrainingUpdateGrad)
  954. .INPUT(dy, TensorType({DT_FLOAT16,DT_FLOAT}))
  955. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  956. .INPUT(variance, TensorType({DT_FLOAT}))
  957. .INPUT(mean, TensorType({DT_FLOAT}))
  958. .OUTPUT(res_gamma, TensorType({DT_FLOAT}))
  959. .OUTPUT(res_beta, TensorType({DT_FLOAT}))
  960. .OP_END_FACTORY_REG(INTrainingUpdateGrad)
  961. /**
  962. *@brief Performs the backpropagation of InstanceNorm. \n
  963. *@par Inputs:
  964. * Two inputs, including:
  965. *@li res_gamma: A Tensor of type float32.
  966. *@li res_beta: A Tensor of type float32. \n
  967. *@par Outputs:
  968. *@li pd_gamma: A Tensor of type float32.
  969. *@li pd_beta: A Tensor of type float32. \n
  970. */
  971. REG_OP(INTrainingUpdateGradGammaBeta)
  972. .INPUT(res_gamma, TensorType({DT_FLOAT}))
  973. .INPUT(res_beta, TensorType({DT_FLOAT}))
  974. .OUTPUT(pd_gamma, TensorType({DT_FLOAT}))
  975. .OUTPUT(pd_beta, TensorType({DT_FLOAT}))
  976. .OP_END_FACTORY_REG(INTrainingUpdateGradGammaBeta)
  977. /**
  978. *@brief Performs reduced group normalization . \n
  979. *@par Inputs:
  980. *x: A Tensor of type float16 or float32, with format NCHW NHWC . \n
  981. *@par Outputs:
  982. *@li sum: A Tensor of type float32 for SUM reduced "x".
  983. *@li square_sum: A Tensor of type float32 for SUMSQ reduced "x".
  984. *@par Attributes:
  985. *num_groups: Int, specifying the num of groups. required, same to GNTrainingUpdate . \n
  986. *@attention Constraints:
  987. * This operator is a GroupNorm fusion operator for updating the moving averages for training.
  988. * This operator is used in conjunction with GNTrainingUpdate.
  989. */
  990. REG_OP(GNTrainingReduce)
  991. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  992. .OUTPUT(sum, TensorType({DT_FLOAT}))
  993. .OUTPUT(square_sum, TensorType({DT_FLOAT}))
  994. .ATTR(num_groups, Int, 2)
  995. .OP_END_FACTORY_REG(GNTrainingReduce)
  996. /**
  997. *@brief Performs update group normalization . \n
  998. *@par Inputs:
  999. * Seven inputs, including: (NCHW NHWC supported)
  1000. *@li x: A Tensor of type float16 or float32.
  1001. *@li sum: A 5D Tensor of type float32,
  1002. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1003. for the output of operator GNTrainingReduce.
  1004. *@li square_sum: A 5D Tensor of type float32,
  1005. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1006. for the output of operator GNTrainingReduce.
  1007. *@li scale: A 5D Tensor of type float32,
  1008. shape is [1, G, 1, 1, 1] for NCHW, [1, 1, 1, G, 1] for NHWC
  1009. is for the scaling gamma.
  1010. *@li offset: A 5D Tensor of type float32,
  1011. shape is [1, G, 1, 1, 1] for NCHW, [1, 1, 1, G, 1] for NHWC
  1012. for the scaling beta.
  1013. *@li mean: A 5D Tensor of type float32,
  1014. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1015. for the updated mean.
  1016. *@li variance: A 5D Tensor of type float32,
  1017. shape is [N, G, 1, 1, 1] for NCHW, [N, 1, 1, G, 1] for NHWC
  1018. for the updated variance.
  1019. *@par Attributes:
  1020. *@li epsilon: A float32, specifying the small value added to variance to avoid dividing by zero.
  1021. *@li num_groups: Int, specifying the num of groups. required, same to GNTrainingReduce
  1022. *@par Outputs:
  1023. * Three outputs, including: (NC1HWC0 supported)
  1024. *@li y: A Tensor of type float16 or float32, for normalized "x".
  1025. *@li batch_mean: A Tensor of type float32, for the updated mean.
  1026. *@li batch_variance: A Tensor of type float32, for the updated variance . \n
  1027. *@attention Constraints:
  1028. *@li This operator is a InstanceNorm fusion operator for updating the moving averages for training.
  1029. * This operator is used in conjunction with GNTrainingUpdate.
  1030. *@li For Ascend 310, the result accuracy fails to reach 1/1000 due to the square root instruction.
  1031. */
  1032. REG_OP(GNTrainingUpdate)
  1033. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1034. .INPUT(sum, TensorType({DT_FLOAT}))
  1035. .INPUT(square_sum, TensorType({DT_FLOAT}))
  1036. .OPTIONAL_INPUT(scale, TensorType({DT_FLOAT}))
  1037. .OPTIONAL_INPUT(offset, TensorType({DT_FLOAT}))
  1038. .OPTIONAL_INPUT(mean, TensorType({DT_FLOAT}))
  1039. .OPTIONAL_INPUT(variance, TensorType({DT_FLOAT}))
  1040. .ATTR(num_groups, Int, 2)
  1041. .ATTR(epsilon, Float, 0.0001)
  1042. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1043. .OUTPUT(batch_mean, TensorType({DT_FLOAT}))
  1044. .OUTPUT(batch_variance, TensorType({DT_FLOAT}))
  1045. .OP_END_FACTORY_REG(GNTrainingUpdate)
  1046. /**
  1047. *@brief Joins a string Tensor across the given dimensions. \n
  1048. *@par Inputs:
  1049. include:
  1050. *@li input:A Tensor of type string. The text to be processed.
  1051. *@li reduction_indices:A Tensor of type int. The text to be processed.
  1052. *@par Attributes:
  1053. *@li keep_dims:A bool, An optional bool. Defaults to False. If True, retain reduced dimensions with length 1..
  1054. *@li separator:string.
  1055. *@par Outputs:
  1056. *output:A Tensor of type string.
  1057. */
  1058. REG_OP(ReduceJoin)
  1059. .INPUT(input, TensorType({DT_STRING}))
  1060. .INPUT(reduction_indices, TensorType({DT_INT32}))
  1061. .OUTPUT(output, TensorType({DT_STRING}))
  1062. .ATTR(keep_dims, Bool, true)
  1063. .ATTR(separator, String, "")
  1064. .OP_END_FACTORY_REG(ReduceJoin)
  1065. /**
  1066. * @brief Calculates the standard deviation and average value of Tensors.
  1067. * @par Inputs:
  1068. * x: A Tensor. Must be one of the following types:
  1069. * float16, float32. \n
  1070. * @par Attributes:
  1071. * Three Attributes, including:
  1072. * @li dim: An optional listint, Defaults to "None". \n
  1073. * @li unbiased: An optional bool. Defaults to "True".
  1074. * If "True", Use Bessel Correction.
  1075. * If "False", Do not use Bessel Correction. \n
  1076. * @li keepdim: An optional bool. Defaults to "False".
  1077. * If "True", Keep the original tensor dimension.
  1078. * If "False", Do not keep the original tensor dimension. \n
  1079. * @par Outputs:
  1080. * Two Outputs, including:
  1081. * @li y1: A Tensor. Has the same type as "x".
  1082. * @li y2: A Tensor. Has the same type as "x". \n
  1083. * @par Third-party framework compatibility
  1084. * Compatible with the Pytorch operator ReduceStd.
  1085. */
  1086. REG_OP(ReduceStd)
  1087. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1088. .OUTPUT(y1, TensorType({DT_FLOAT, DT_FLOAT16}))
  1089. .OUTPUT(y2, TensorType({DT_FLOAT, DT_FLOAT16}))
  1090. .ATTR(dim, ListInt, {})
  1091. .ATTR(unbiased, Bool, true)
  1092. .ATTR(keepdim, Bool, false)
  1093. .OP_END_FACTORY_REG(ReduceStd)
  1094. /**
  1095. * @brief Calculates the standard deviation of Tensors.
  1096. * @par Inputs:
  1097. * include:
  1098. * @li x: A Tensor. Must be one of the following types: float16, float32. \n
  1099. * @li mean: A Tensor. It's the mean of X. Must be one of the following types: float16, float32. \n
  1100. * @par Attributes:
  1101. * Five Attributes, including:
  1102. * @li dim: An optional listint, Defaults to "None". \n
  1103. * @li unbiased: An optional bool. Defaults to "True".
  1104. * If "True", Use Bessel Correction.
  1105. * If "False", Do not use Bessel Correction. \n
  1106. * @li keepdim: An optional bool. Defaults to "False".
  1107. * If "True", Keep the original tensor dimension.
  1108. * If "False", Do not keep the original tensor dimension. \n
  1109. * @li invert: An optional bool, Defaults to "False".
  1110. * If "True", the output is inverse of variance.
  1111. * If "False", the output is variance.
  1112. * @li epsilon: An optional floar, Defaults to 0.001.
  1113. * Prevent division by 0.
  1114. * @par Outputs:
  1115. * @li y: A Tensor. It's the variance of X or reciprocal of vaiance of X. Has the same type as "x".
  1116. * @par Third-party framework compatibility
  1117. * Compatible with the Pytorch operator ReduceStdWithMean.
  1118. */
  1119. REG_OP(ReduceStdWithMean)
  1120. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1121. .INPUT(mean, TensorType({DT_FLOAT, DT_FLOAT16}))
  1122. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  1123. .ATTR(dim, ListInt, {})
  1124. .ATTR(unbiased, Bool, true)
  1125. .ATTR(keepdim, Bool, false)
  1126. .ATTR(invert, Bool, false)
  1127. .ATTR(epsilon, Float, 0.001)
  1128. .OP_END_FACTORY_REG(ReduceStdWithMean)
  1129. /**
  1130. *@brief Performs reduced batch normalization . \n
  1131. *@par Inputs:
  1132. *x: A 5D Tensor of type float16 or float32, with format NC1HWC0 . \n
  1133. *@par Outputs:
  1134. *@li mean: A Tensor of type float32 for SUM reduced "x".
  1135. *@li variance: A Tensor of type float32 for square sum reduced "x" . \n
  1136. *@par Restrictions:
  1137. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1138. */
  1139. REG_OP(ReduceMeanVariance)
  1140. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1141. .OUTPUT(mean, TensorType({DT_FLOAT16,DT_FLOAT}))
  1142. .OUTPUT(variance, TensorType({DT_FLOAT16,DT_FLOAT}))
  1143. .ATTR(axes, ListInt, {})
  1144. .ATTR(keep_dims, Bool, true)
  1145. .OP_END_FACTORY_REG(ReduceMeanVariance)
  1146. /**
  1147. * @brief Calculates the standard deviation or the variance of Tensors with the average value.
  1148. * @par Inputs:
  1149. * Two inputs, including:
  1150. * @li x: A Tensor. Must be one of the following types: float16, float32. \n
  1151. * @li mean: A Tensor. It's the mean of X. Has the same shape and type as "x" \n
  1152. * @par Attributes:
  1153. * Four Attributes, including:
  1154. * @li dim: An listint. \n
  1155. * @li if_std: An optional bool. Defaults to "False"
  1156. * If "True", Calculate the standard deviation
  1157. * If "False", Calculate the variance
  1158. * @li unbiased: An optional bool. Defaults to "True".
  1159. * If "True", Use Bessel Correction.
  1160. * If "False", Do not use Bessel Correction. \n
  1161. * @li keepdim: An optional bool. Defaults to "False".
  1162. * If "True", Keep the original tensor dimension.
  1163. * If "False", Do not keep the original tensor dimension. \n
  1164. * @par Outputs:
  1165. * @li output_var: A Tensor. It's the standard deviation or the variance of X. Has the same type as "x".
  1166. * @par Third-party framework compatibility
  1167. * Compatible with the Pytorch operator Var_mean.
  1168. */
  1169. REG_OP(ReduceStdV2Update)
  1170. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  1171. .INPUT(mean, TensorType({DT_FLOAT,DT_FLOAT16}))
  1172. .OUTPUT(output_var, TensorType({DT_FLOAT,DT_FLOAT16}))
  1173. .REQUIRED_ATTR(dim, ListInt)
  1174. .ATTR(if_std, Bool, false)
  1175. .ATTR(unbiased, Bool, true)
  1176. .ATTR(keepdim, Bool, false)
  1177. .OP_END_FACTORY_REG(ReduceStdV2Update)
  1178. /**
  1179. *@brief Computes the log and sum and exp of elements across dimensions of a tensor.
  1180. * Reduces "x" along the dimensions given in "axes".
  1181. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  1182. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  1183. * are retained with length 1.
  1184. *
  1185. *@par Inputs:
  1186. * Two inputs, including:
  1187. *@li x: A Tensor. Must be one of the following types:
  1188. * float32, float16, int32, int64, uint32, uint64, double
  1189. *@li axes: A 1D list or tuple of int32 or int64. Specifies the dimensions to reduce . \n
  1190. *
  1191. *@par Attributes:
  1192. *keep_dims: An optional bool. If "true", retains reduced dimensions with length 1. Defaults to "false" . \n
  1193. *
  1194. *@par Outputs:
  1195. *y: The reduced tensor. Has the same type and format as input "x" . \n
  1196. *
  1197. *@par Third-party framework compatibility
  1198. * Compatible with the Onnx operator ReduceLogSumExp.
  1199. */
  1200. REG_OP(ReduceLogSumExp)
  1201. .INPUT(x, TensorType::NumberType())
  1202. .INPUT(axes, TensorType::IndexNumberType())
  1203. .OUTPUT(y, TensorType::NumberType())
  1204. .ATTR(keep_dims, Bool, false)
  1205. .OP_END_FACTORY_REG(ReduceLogSumExp)
  1206. /**
  1207. *@brief Computes the log and sum of elements across dimensions of a tensor.
  1208. * Reduces "x" along the dimensions given in "axes".
  1209. * Unless "keep_dims" is true, the rank of the tensor is reduced by 1 for each
  1210. * entry in "axes". If "keep_dims" is true, the reduced dimensions
  1211. * are retained with length 1.
  1212. *
  1213. *@par Inputs:
  1214. * Two inputs, including:
  1215. *@li x: A Tensor. Must be one of the following types:
  1216. * float32, float16, int32, int64, uint32, uint64, double
  1217. *@li axes: A 1D list or tuple of int32 or int64. Specifies the dimensions to reduce . \n
  1218. *
  1219. *@par Attributes:
  1220. *keep_dims: An optional bool. If "true", retains reduced dimensions with length 1. Defaults to "false" . \n
  1221. *
  1222. *@par Outputs:
  1223. *y: The reduced tensor. Has the same type and format as input "x" . \n
  1224. *
  1225. *@par Third-party framework compatibility
  1226. * Compatible with the Onnx operator ReduceLogSum.
  1227. */
  1228. REG_OP(ReduceLogSum)
  1229. .INPUT(x, TensorType::NumberType())
  1230. .INPUT(axes, TensorType::IndexNumberType())
  1231. .OUTPUT(y, TensorType::NumberType())
  1232. .ATTR(keep_dims, Bool, false)
  1233. .OP_END_FACTORY_REG(ReduceLogSum)
  1234. } //namespace ge
  1235. #endif // OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_

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