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.

elewise_calculation_ops.h 79 kB

5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245
  1. /**
  2. * Copyright 2019-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. #ifndef GE_OP_ELEWISE_CALCULATION_OPS_H
  17. #define GE_OP_ELEWISE_CALCULATION_OPS_H
  18. #include "../graph/operator_reg.h"
  19. namespace ge {
  20. /**
  21. *@brief Adds all input tensors element-wise.
  22. *@par Inputs:
  23. *Dynamic inputs, including:
  24. * @li x: A list of Tensor objects, each with same shape and type. The supported types are:
  25. * float16, float32, double, int32, uint8, int16, int8, complex64, int64,
  26. * qint8, quint8, qint32, uint16, complex128, uint32, uint64.
  27. *@par Outputs:
  28. *y: A Tensor. Has the same shape and type as the elements of "x".
  29. */
  30. REG_OP(AddN)
  31. .DYNAMIC_INPUT(x, TensorType::NumberType())
  32. .OUTPUT(y, TensorType::NumberType())
  33. .REQUIRED_ATTR(N, Int)
  34. .OP_END_FACTORY_REG(AddN)
  35. REG_OP(MaximumGrad)
  36. .INPUT(grads, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  37. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  38. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  39. .OUTPUT(y1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  40. .OUTPUT(y2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  41. .ATTR(grad_x, Bool, true)
  42. .ATTR(grad_y, Bool, true)
  43. .OP_END_FACTORY_REG(MaximumGrad)
  44. /**
  45. *@brief Calculates the reversed outputs of the function "minimum"
  46. *@par Inputs:
  47. *Three inputs, including:
  48. * @li grads: A mutable Tensor. Must be one of the following types:
  49. * float16, float32, int32.
  50. * @li x1: A mutable Tensor of the same type as "grads".
  51. * @li x2: A mutable Tensor of the same type as "grads".
  52. *@par Attributes:
  53. *@li grad_x: An optional bool. Defaults to "True".
  54. * If "True", "y1" will be output.
  55. * If "False", "y1" will not be output.
  56. *@li grad_y: An optional bool. Defaults to "True".
  57. * If "True", "y2" will be output.
  58. * If "False", "y2" will not be output.
  59. *@par Outputs:
  60. * @li y1: A mutable Tensor. Has the same type as "grads".
  61. * @li y2: A mutable Tensor. Has the same type as "grads".
  62. */
  63. REG_OP(MinimumGrad)
  64. .INPUT(grads, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  65. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  66. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  67. .OUTPUT(y1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  68. .OUTPUT(y2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  69. .ATTR(grad_x, Bool, true)
  70. .ATTR(grad_y, Bool, true)
  71. .OP_END_FACTORY_REG(MinimumGrad)
  72. /**
  73. *@brief: Cast a tensor form src data type to dst data type.
  74. *@par Inputs:
  75. *One input:\n
  76. *x:A `Tensor`. Must be one of the following types: bool, float16, float, int8, int32, uint32, uint8,\n
  77. int64, uint64, int16, uint16, double, complex64, complex128, qint8, quint8, qint16, quint16, qint32.
  78. *@par Attributes:
  79. *@li dst_type: An required attribute of type int32, specifying the dst data type.
  80. *@li truncate: An optional attribute of type bool, specifying the src data type. Defaults to "false".
  81. *@par Outputs:
  82. *y:A `Tensor`. Has the same type as `x`.
  83. *@par Quantization supported or not
  84. *Not supported
  85. *@par Quantized inference supported or not
  86. *Not supported
  87. *@par Multiple batches supported or not
  88. *Supported
  89. *@since V100R001C33
  90. */
  91. REG_OP(Cast)
  92. .INPUT(x, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT32, DT_UINT8,
  93. DT_INT64, DT_UINT64, DT_INT16, DT_UINT16, DT_DOUBLE, DT_COMPLEX64,
  94. DT_COMPLEX128, DT_QINT8, DT_QUINT8, DT_QINT16, DT_QUINT16, DT_QINT32}))
  95. .OUTPUT(y, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT32, DT_UINT8,
  96. DT_INT64, DT_UINT64, DT_INT16, DT_UINT16, DT_DOUBLE, DT_COMPLEX64,
  97. DT_COMPLEX128, DT_QINT8, DT_QUINT8, DT_QINT16, DT_QUINT16, DT_QINT32}))
  98. .REQUIRED_ATTR(dst_type, Int)
  99. .ATTR(truncate, Bool, false)
  100. .OP_END_FACTORY_REG(Cast)
  101. /**
  102. *@brief Returns the truth value of (x1 >= x2) element-wise.
  103. *@par Inputs:
  104. *Two inputs, including:
  105. * @li x1: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
  106. * @li x2: A Tensor of the same type as "x1".
  107. *@par Outputs:
  108. *y: A Tensor. Has the same type as "x1".
  109. */
  110. REG_OP(GreaterEqual)
  111. .INPUT(x1, TensorType::RealNumberType())
  112. .INPUT(x2, TensorType::RealNumberType())
  113. .OUTPUT(y, TensorType({DT_BOOL}))
  114. .OP_END_FACTORY_REG(GreaterEqual)
  115. REG_OP(Less)
  116. .INPUT(x1, TensorType::RealNumberType())
  117. .INPUT(x2, TensorType::RealNumberType())
  118. .OUTPUT(y, TensorType({DT_BOOL}))
  119. .OP_END_FACTORY_REG(Less)
  120. /**
  121. *@brief Returns x1/x2 element-wise for real types.
  122. *@par Inputs:
  123. * Two inputs, including:
  124. *@li x1: A Tensor. Must be one of the following types: float16, float32, double, uint16,
  125. int8, uint8, int16, int32, int64, complex64, DT_COMPLEX128.
  126. *@li x2: A Tensor. Must be one of the following types: float16, float32, double, uint16,
  127. int8, uint8, int16, int32, int64, complex64, DT_COMPLEX128.
  128. *@par Outputs:
  129. * y: A Tensor. Has the same type and format as input "x1".
  130. */
  131. REG_OP(RealDiv)
  132. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  133. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  134. DT_COMPLEX64, DT_COMPLEX128}))
  135. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  136. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  137. DT_COMPLEX64, DT_COMPLEX128}))
  138. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  139. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  140. DT_COMPLEX64, DT_COMPLEX128}))
  141. .OP_END_FACTORY_REG(RealDiv)
  142. /**
  143. *@brief Computes square root of x element-wise.
  144. *@par Inputs:
  145. * x: A Tensor. Must be one of the following types: float16, float32, complex128, complex64, float64.
  146. *@par Outputs:
  147. *y: A Tensor. Has the same type as "x".
  148. */
  149. REG_OP(Sqrt)
  150. .INPUT(x, TensorType{(DT_FLOAT. DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128)})
  151. .OUTPUT(y, TensorType{(DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128)})
  152. .OP_END_FACTORY_REG(Sqrt)
  153. /**
  154. *@brief Returns the max of "x" and "y" (i.e. x > y ? x: y) element-wise.
  155. *@par Inputs:
  156. *Two inputs, including:
  157. * @li x1: A Tensor. Must be one of the following types: float16, float32, double, int32, int64.
  158. * @li x2: A Tensor of the same type as "x1".
  159. *@par Outputs:
  160. *y: A Tensor. Has the same type as "x1".
  161. */
  162. REG_OP(Maximum)
  163. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  164. DT_INT64}))
  165. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  166. DT_INT64}))
  167. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  168. DT_INT64}))
  169. .OP_END_FACTORY_REG(Maximum)
  170. /**
  171. *@brief Returns the min of x and y (i.e. x1 < x2 ? x1 : x2) element-wise.
  172. *@par Inputs:
  173. *Two inputs, include:
  174. * @li x1: A Tensor. Must be one of the following types: float32, float16, double, int32, int64.
  175. * @li x2: A Tensor of the same type as "x1".
  176. *@par Outputs:
  177. *y: A Tensor of the same type as "x1".
  178. */
  179. REG_OP(Minimum)
  180. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT32,
  181. DT_INT64}))
  182. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT32,
  183. DT_INT64}))
  184. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT32,
  185. DT_INT64}))
  186. .OP_END_FACTORY_REG(Minimum)
  187. /**
  188. *@brief: Computes the reciprocal of "x".
  189. *@par Inputs:
  190. *One inputs, include:
  191. *x:A Tensor of type float16, float32, int32, int64, double,
  192. * complex64, complex128.the format can be [NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND]
  193. *@par Outputs:
  194. *y:A Tensor with same type as "x".
  195. */
  196. REG_OP(Reciprocal)
  197. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_FLOAT16,
  198. DT_COMPLEX64, DT_COMPLEX128}))
  199. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_FLOAT16
  200. DT_COMPLEX64, DT_COMPLEX128}))
  201. .OP_END_FACTORY_REG(Reciprocal)
  202. REG_OP(Sub)
  203. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  204. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  205. DT_COMPLEX64, DT_COMPLEX128}))
  206. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  207. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  208. DT_COMPLEX64, DT_COMPLEX128}))
  209. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  210. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  211. DT_COMPLEX64, DT_COMPLEX128}))
  212. .OP_END_FACTORY_REG(Sub)
  213. REG_OP(Abs)
  214. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64}))
  215. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64}))
  216. .OP_END_FACTORY_REG(Abs)
  217. /**
  218. *@brief Computes gradients for absolute operation.
  219. *
  220. *@par Inputs:
  221. *@li y: A tensor of type float16 or float32.
  222. *@li dy: A tensor of the same type as "y".
  223. *
  224. *@attention Constraints:
  225. * "dy" has the same type as "y".
  226. *
  227. *@par Outputs:
  228. * z: A tensor. Has the same type as "y".
  229. *
  230. */
  231. REG_OP(AbsGrad)
  232. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  233. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  234. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  235. .OP_END_FACTORY_REG(AbsGrad)
  236. /**
  237. *@brief: Computes the sign of "x".
  238. *@par Inputs:
  239. *One inputs, include:
  240. *x:A Tensor of type float16, float32, int32, int64, double,
  241. * complex64, complex128.
  242. *@par Outputs:
  243. *y:A Tensor with same type as "x".
  244. */
  245. REG_OP(Sign)
  246. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT, DT_DOUBLE, DT_INT32,
  247. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  248. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  249. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  250. .OP_END_FACTORY_REG(Sign)
  251. /**
  252. *@brief Returns (x1 - x2)(x1 - x2) element-wise.
  253. *@par Inputs:
  254. *Two inputs, including: \n
  255. *@li x1: A Tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64,complex128
  256. *@li x2: A Tensor. Has the same type as "x1".
  257. *@par Outputs:
  258. *y: A Tensor. Has the same type as "x1".
  259. */
  260. REG_OP(SquaredDifference)
  261. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  262. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  263. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  264. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  265. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  266. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  267. .OP_END_FACTORY_REG(SquaredDifference)
  268. /**
  269. *@brief Computes cosine of "x" element-wise.
  270. *@par Inputs:\n
  271. *x: A Tensor of type float16 or float32.
  272. *@par Outputs:\n
  273. *y: A Tensor of type float16 or float32.
  274. */
  275. REG_OP(Cos)
  276. .INPUT(x, TensorType::UnaryDataType())
  277. .OUTPUT(y, TensorType::UnaryDataType())
  278. .OP_END_FACTORY_REG(Cos)
  279. /**
  280. *@brief Returns x1/x2 element-wise.
  281. *@par Inputs:
  282. * Two inputs, including:
  283. *@li x1: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8
  284. *@li x2: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8
  285. *@par Outputs:
  286. * y: A Tensor. Has the same type and format as input "x1".
  287. */
  288. REG_OP(Div)
  289. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  290. DT_DOUBLE, DT_INT64, DT_UINT16, DT_INT16,
  291. DT_COMPLEX64, DT_COMPLEX128}))
  292. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  293. DT_DOUBLE, DT_INT64, DT_UINT16, DT_INT16,
  294. DT_COMPLEX64, DT_COMPLEX128}))
  295. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  296. DT_DOUBLE, DT_INT64, DT_UINT16, DT_INT16,
  297. DT_COMPLEX64, DT_COMPLEX128}))
  298. .OP_END_FACTORY_REG(Div)
  299. /**
  300. *@brief: Returns the truth value of (x = y) element-wise.
  301. *@par Inputs:
  302. * Two inputs, including:
  303. *@li x1: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8, \n
  304. * double, int16, int64, complex64, complex128, quint8, qint8, qint32, string, bool.
  305. *@li x2: A Tensor of the same type as "x1".
  306. *@par Outputs:
  307. *y: A Tensor of type bool.
  308. */
  309. REG_OP(Equal)
  310. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8, DT_UINT8,
  311. DT_DOUBLE, DT_INT16, DT_INT64, DT_COMPLEX64,
  312. DT_COMPLEX128, DT_QUINT8, DT_QINT8, DT_QINT32,
  313. DT_STRING, DT_BOOL}))
  314. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8, DT_UINT8,
  315. DT_DOUBLE, DT_INT16, DT_INT64, DT_COMPLEX64,
  316. DT_COMPLEX128, DT_QUINT8, DT_QINT8, DT_QINT32,
  317. DT_STRING, DT_BOOL}))
  318. .OUTPUT(y, TensorType({DT_BOOL}))
  319. .OP_END_FACTORY_REG(Equal)
  320. /**
  321. *@brief Computes the exponential of "x" element-wise.
  322. *@par Inputs:
  323. *One input:\n
  324. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128.
  325. *@par Attributes:
  326. *@li base: An optional attribute of type float32, specifying the base gamma. Defaults to "-1".
  327. *@li scale: An optional attribute of type float32, specifying the scale alpha. Defaults to "1".
  328. *@li shift: An optional attribute of type float32, specifying the shift beta. Defaults to "0".
  329. *@par Outputs:
  330. *y: A Tensor of the same type as "x".
  331. */
  332. REG_OP(Exp)
  333. .INPUT(x, TensorType::UnaryDataType())
  334. .OUTPUT(y, TensorType::UnaryDataType())
  335. .ATTR(base, Float, -1.0)
  336. .ATTR(scale, Float, 1.0)
  337. .ATTR(shift, Float, 0.0)
  338. .OP_END_FACTORY_REG(Exp)
  339. /**
  340. *@brief Computes the exp(x) - 1 element-wise, y = e^x - 1.
  341. *@par Inputs:
  342. *One input:\n
  343. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128.
  344. *@par Outputs:
  345. *y: A Tensor of the same type as "x".
  346. */
  347. REG_OP(Expm1)
  348. .INPUT(x, TensorType::UnaryDataType())
  349. .OUTPUT(y, TensorType::UnaryDataType())
  350. .OP_END_FACTORY_REG(Expm1)
  351. /**
  352. *@brief: Computes the reciprocal of "x".
  353. *@par Inputs:\n
  354. *x: A Tensor. Must be one of the following types: float16, float32, int32, int64, double, complex64, complex128.
  355. *@par Outputs:
  356. *y: A Tensor. Has the same type as "x".
  357. */
  358. REG_OP(Inv)
  359. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE,DT_INT32,DT_INT64,DT_COMPLEX64,DT_COMPLEX128}))
  360. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  361. .OP_END_FACTORY_REG(Inv)
  362. /**
  363. *@brief: Computes "x" reciprocal grad, dx = -1*dy*y*y, where, "y = 1/x", and "dy"
  364. is the corresponding input gradient.
  365. *@par Inputs:
  366. * Two inputs, including:
  367. * @li x: A Tensor. Must be one of the following types: float16, float32, int32, int8.
  368. * @li grad: A Tensor. Has the same type as "x".
  369. */
  370. REG_OP(InvGrad)
  371. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  372. .INPUT(grad, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  373. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  374. .OP_END_FACTORY_REG(InvGrad)
  375. /**
  376. *@brief: Returns the truth value of (x <= y) element-wise.
  377. *@par Inputs:
  378. * Two inputs, including:
  379. *@li x1: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
  380. *@li x2: A Tensor of the same type as "x1".
  381. *@par Outputs:
  382. *y: A Tensor of type bool.
  383. */
  384. REG_OP(LessEqual)
  385. .INPUT(x1, TensorType::RealNumberType())
  386. .INPUT(x2, TensorType::RealNumberType())
  387. .OUTPUT(y, TensorType({DT_BOOL}))
  388. .OP_END_FACTORY_REG(LessEqual)
  389. /**
  390. *@brief Computes the logarithm of (x + 1) element-wise, y = ln(x + 1).
  391. *@par Inputs:
  392. *One input:\n
  393. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128.
  394. *@par Outputs:
  395. *y: A Tensor of the same type as "x".
  396. */
  397. REG_OP(Log1p)
  398. .INPUT(x, TensorType::UnaryDataType())
  399. .OUTPUT(y, TensorType::UnaryDataType())
  400. .OP_END_FACTORY_REG(Log1p)
  401. /**
  402. *@brief Returns element-wise remainder of division.
  403. *@par Inputs:
  404. *Two inputs, including:
  405. * @li x1: A Tensor. Must be one of the following types: float16, float32, int32, int64, int8, uint8, double.
  406. * @li x2: A Tensor of the same type as "x1".
  407. *@par Outputs:
  408. *y: A Tensor. Has the same type as "x1".
  409. */
  410. REG_OP(Mod)
  411. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8,
  412. DT_INT64, DT_DOUBLE}))
  413. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8,
  414. DT_INT64, DT_DOUBLE}))
  415. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8,
  416. DT_INT64, DT_DOUBLE}))
  417. .OP_END_FACTORY_REG(Mod)
  418. /**
  419. *@brief: Returns the truth value of (x != y) element-wise.
  420. *@par Inputs:
  421. * Two inputs, including:
  422. *@li x1: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
  423. *@li x2: A Tensor of the same type as "x1".
  424. *@par Outputs:
  425. *y: A Tensor of type bool.
  426. */
  427. REG_OP(NotEqual)
  428. .INPUT(x1, TensorType::RealNumberType())
  429. .INPUT(x2, TensorType::RealNumberType())
  430. .OUTPUT(y, TensorType({DT_BOOL}))
  431. .OP_END_FACTORY_REG(NotEqual)
  432. /**
  433. *@brief Computes numerical negative value element-wise (y = -x)
  434. *@par Inputs:
  435. * One input:
  436. *x: A Tensor. Must be one of the following types: float16, float32, int32
  437. *@par Outputs:
  438. *y: A Tensor. Has the same type and format as input "x".
  439. */
  440. REG_OP(Neg)
  441. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  442. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  443. .OP_END_FACTORY_REG(Neg)
  444. /**
  445. *@brief Returns x1/x2 element-wise for integer types.
  446. *@par Inputs:\n
  447. *@li x1: A Tensor of type float16, float32, int32, int8, or uint8.
  448. *@li x2: A Tensor of the same data type as "x1".
  449. *@par Outputs:\n
  450. *y: A Tensor of type float16, float32, int32, int8, or uint8.
  451. *@attention Constraints:\n
  452. * Broadcasting is supported.
  453. */
  454. REG_OP(TruncateDiv)
  455. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  456. DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,
  457. DT_COMPLEX64, DT_COMPLEX128}))
  458. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  459. DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,
  460. DT_COMPLEX64, DT_COMPLEX128}))
  461. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  462. DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,
  463. DT_COMPLEX64, DT_COMPLEX128}))
  464. .OP_END_FACTORY_REG(TruncateDiv)
  465. /**
  466. *@brief Computes x1/x2 element-wise, if x1 == 0, return 0.
  467. *@par Inputs:
  468. * Two inputs, including:
  469. * @li x1: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128.
  470. * @li x2: A Tensor. Has the same type as "x1".
  471. *@par Outputs:
  472. *y: A Tensor. Has the same type as "x1".
  473. */
  474. REG_OP(Xdivy)
  475. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  476. DT_COMPLEX128}))
  477. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  478. DT_COMPLEX128}))
  479. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  480. DT_COMPLEX128}))
  481. .OP_END_FACTORY_REG(Xdivy)
  482. /**
  483. *@brief Computes "x" multiplied by the logarithm of y element-wise, if "x" == 0, return "0".
  484. *@par Inputs:
  485. * Two inputs, including:
  486. * @li x1: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128.
  487. * @li x2: A Tensor. Has the same type as "x1".
  488. *@par Outputs:
  489. *y: A Tensor. Has the same type as "x1".
  490. */
  491. REG_OP(Xlogy)
  492. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  493. DT_COMPLEX128}))
  494. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  495. DT_COMPLEX128}))
  496. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  497. DT_COMPLEX128}))
  498. .OP_END_FACTORY_REG(Xlogy)
  499. /**
  500. *@brief Computes square of "x" element-wise.
  501. *@par Inputs:
  502. *One input: \n
  503. *x: A Tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128
  504. *@par Outputs:
  505. *y: A Tensor. Has the same type as "x".
  506. */
  507. REG_OP(Square)
  508. .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT16, DT_FLOAT,
  509. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  510. .OUTPUT(y, TensorType({DT_DOUBLE, DT_FLOAT16, DT_FLOAT,
  511. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  512. .OP_END_FACTORY_REG(Square)
  513. /**
  514. *@brief Computes reciprocal of square root of "x" element-wise: y = 1/sqrt{x}.
  515. *
  516. *@par Inputs:
  517. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  518. *
  519. *@par Outputs:
  520. * y: A tensor. Has the same type as "x".
  521. *
  522. */
  523. REG_OP(Rsqrt)
  524. .INPUT(x, TensorType::UnaryDataType())
  525. .OUTPUT(y, TensorType::UnaryDataType())
  526. .OP_END_FACTORY_REG(Rsqrt)
  527. /**
  528. *@brief Computes the trignometric inverse sine of "x" element-wise.
  529. *
  530. *@par Inputs:
  531. * x: A tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128.
  532. *
  533. *@par Outputs:
  534. * y: A tensor. Has the same type as "x".
  535. *
  536. */
  537. REG_OP(Asin)
  538. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  539. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  540. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  541. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  542. .OP_END_FACTORY_REG(Asin)
  543. /**
  544. *@brief Computes gradients for Asin operation.
  545. *
  546. *@par Inputs:
  547. *@li y: A tensor of type float16 or float32.
  548. *@li dy: A tensor of the same type as "y".
  549. *
  550. *@attention Constraints:
  551. * "dy" has the same type as "y".
  552. *
  553. *@par Outputs:
  554. * z: A tensor. Has the same type as "y".
  555. *
  556. */
  557. REG_OP(AsinGrad)
  558. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  559. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  560. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  561. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  562. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  563. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  564. .OP_END_FACTORY_REG(AsinGrad)
  565. /**
  566. *@brief Computes acos of x element-wise.
  567. *
  568. *@par Inputs:
  569. * x: A tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128.
  570. *
  571. *@par Outputs:
  572. * y: A tensor. Has the same type as "x".
  573. *
  574. */
  575. REG_OP(Acos)
  576. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  577. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  578. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  579. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  580. .OP_END_FACTORY_REG(Acos)
  581. /**
  582. *@brief Computes gradients for Acos operation.
  583. *
  584. *@par Inputs:
  585. *@li y: A tensor of type float16 or float32.
  586. *@li dy: A tensor of the same type as "y".
  587. *
  588. *@attention Constraints:
  589. * "dy" has the same shape as "y".
  590. *
  591. *@par Outputs:
  592. * z: A tensor. Has the same type as "y".
  593. *
  594. */
  595. REG_OP(AcosGrad)
  596. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  597. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  598. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  599. .OP_END_FACTORY_REG(AcosGrad)
  600. /**
  601. *@brief Computes inverse hyperbolic cosine of x element-wise.
  602. *
  603. *@par Inputs:
  604. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  605. *
  606. *@attention Constraints:
  607. * x Given an input tensor, the function computes inverse hyperbolic cosine of every element.\n
  608. * Input range is [1, inf].
  609. *
  610. *@par Outputs:
  611. * y: A tensor. Has the same type as "x".
  612. *
  613. */
  614. REG_OP(Acosh)
  615. .INPUT(x, TensorType::UnaryDataType())
  616. .OUTPUT(y, TensorType::UnaryDataType())
  617. .OP_END_FACTORY_REG(Acosh)
  618. /**
  619. *@brief Computes gradients for Acosh operation.
  620. *
  621. *@par Inputs:
  622. *@li y: A tensor of type float16 or float32.
  623. *@li dy: A tensor of the same type as "y".
  624. *
  625. *@attention Constraints:
  626. * "dy" has the same type as "y".
  627. *
  628. *@par Outputs:
  629. * z: A tensor. Has the same type as "y".
  630. *
  631. */
  632. REG_OP(AcoshGrad)
  633. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  634. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  635. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  636. .OP_END_FACTORY_REG(AcoshGrad)
  637. /**
  638. *@brief Returns the truth value of x1 OR x2 element-wise.
  639. *
  640. *@par Inputs:
  641. *@li x1: A tensor of type bool.
  642. *@li x2 A tensor of the same type as "x1".
  643. *
  644. *@attention Constraints:
  645. * LogicalOr supports broadcasting.
  646. *
  647. *@par Outputs:
  648. * z: A tensor of the same type as "x1".
  649. *
  650. */
  651. REG_OP(LogicalOr)
  652. .INPUT(x1, TensorType({DT_BOOL}))
  653. .INPUT(x2, TensorType({DT_BOOL}))
  654. .OUTPUT(y, TensorType({DT_BOOL}))
  655. .OP_END_FACTORY_REG(LogicalOr)
  656. /**
  657. *@brief Returns the truth value of x1 AND x2 element-wise.
  658. *
  659. *@par Inputs:
  660. *@li x1: A tensor of type bool.
  661. *@li x2 A tensor of the same type as "x1".
  662. *
  663. *@attention Constraints:
  664. * LogicalOr supports broadcasting.
  665. *
  666. *@par Outputs:
  667. * z: A tensor of the same type as "x1".
  668. *
  669. */
  670. REG_OP(LogicalAnd)
  671. .INPUT(x1, TensorType({DT_BOOL}))
  672. .INPUT(x2, TensorType({DT_BOOL}))
  673. .OUTPUT(y, TensorType({DT_BOOL}))
  674. .OP_END_FACTORY_REG(LogicalAnd)
  675. /**
  676. *@brief Computes the Bessel i0e function of "x" element-wise.\n
  677. * Exponentially scaled modified Bessel function of order 0 \n
  678. * defined as: bessel_i0e(x) = exp(-abs(x)) bessel_i0(x).\n
  679. * This function is faster and numerically stabler than "bessel_i0(x)".
  680. *
  681. *@par Inputs:
  682. * x: A tensor of type float16, float32, or float64.
  683. *
  684. *@par Outputs:
  685. * y: A tensor. Has the same type as "x".
  686. *
  687. */
  688. REG_OP(BesselI0e)
  689. .INPUT(x, TensorType::FloatingDataType())
  690. .OUTPUT(y, TensorType::FloatingDataType())
  691. .OP_END_FACTORY_REG(BesselI0e)
  692. /**
  693. *@brief Computes the Bessel i1e function of "x" element-wise.\n
  694. * Exponentially scaled modified Bessel function of order 0 \n
  695. * defined as: bessel_i1e(x) = exp(-abs(x)) bessel_i1(x).\n
  696. * This function is faster and numerically stabler than "bessel_i1(x)".
  697. *
  698. *@par Inputs:
  699. * x: A tensor of type float16, float32, or float64.
  700. *
  701. *@par Outputs:
  702. * y: A tensor. Has the same type as "x".
  703. *
  704. */
  705. REG_OP(BesselI1e)
  706. .INPUT(x, TensorType::FloatingDataType())
  707. .OUTPUT(y, TensorType::FloatingDataType())
  708. .OP_END_FACTORY_REG(BesselI1e)
  709. /**
  710. * @brief Computes logarithm of x element-wise.\n
  711. * y = log_base(shift + scale * x), with "base" > 0.
  712. * @par Inputs:
  713. * @li x: A Tensor of type UnaryDataType.
  714. * @par Attributes:
  715. * @li base: An optional float32, specifying the base "e". Defaults to "-1"
  716. * @li scale: An optional float32, specifying the scale of input "x". Defaults
  717. * to "1"
  718. * @li shift: An optional float32, specifying the shift. Defaults to "0"
  719. * @par Outputs:
  720. * y: A Tensor of type UnaryDataType.
  721. * @attention Constraints:
  722. * @li base > 0 or if base is set to default (-1), base is set to e;
  723. */
  724. REG_OP(Log)
  725. .INPUT(x, TensorType::UnaryDataType())
  726. .OUTPUT(y, TensorType::UnaryDataType())
  727. .ATTR(base, Float, -1.0)
  728. .ATTR(scale, Float, 1.0)
  729. .ATTR(shift, Float, 0.0)
  730. .OP_END_FACTORY_REG(Log)
  731. /**
  732. * @brief Returns x1 * x2 element-wise.\n
  733. * y = x1 * x2
  734. * @par Inputs:
  735. * @li x1: A Tensor. Must be one of the following types: float16, float32,\n
  736. * float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.
  737. * @li x2: A Tensor. Must be one of the following types: float16, float32,
  738. * float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.
  739. * @par Outputs:
  740. * y: A Tensor. Must be one of the following types: float16, float32, float64,
  741. * uint8, int8, uint16, int16, int32, int64, complex64, complex128.
  742. * @attention Constraints:
  743. * @li "x1" and "x2" have incompatible shapes or types.
  744. */
  745. REG_OP(Mul)
  746. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  747. DI_UINT16, DT_INT16, DT_INT32, DT_INT64,
  748. DT_COMPLEX64, DT_COMPLEX128}))
  749. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  750. DI_UINT16, DT_INT16, DT_INT32, DT_INT64,
  751. DT_COMPLEX64, DT_COMPLEX128}))
  752. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  753. DI_UINT16, DT_INT16, DT_INT32, DT_INT64,
  754. DT_COMPLEX64, DT_COMPLEX128}))
  755. .OP_END_FACTORY_REG(Mul)
  756. /**
  757. * @brief Computes the gradient of the square root of "x" with regard to its\n
  758. * input. grad = dy * 0.5/y, where y = sqrt(x), and "dy" is the corresponding
  759. * input gradient.
  760. * @par Inputs:
  761. * @li y: A Tensor of type float32 or float16.
  762. * @li dy: A Tensor. Has the same type as "y".
  763. * @par Outputs:
  764. * z: A Tensor. Has the same type as "y".
  765. * @attention Constraints:
  766. * "dy" has the same shape and type as "y".
  767. */
  768. REG_OP(SqrtGrad)
  769. .INPUT(y, TensorType(UnaryDataType))
  770. .INPUT(dy, TensorType(UnaryDataType))
  771. .OUTPUT(z, TensorType(UnaryDataType))
  772. .OP_END_FACTORY_REG(SqrtGrad)
  773. REG_OP(Multiply)
  774. .INPUT(x, TensorType({DT_FLOAT,DT_UINT8,DT_INT8,DT_UINT16,DT_INT16,DT_INT32,DT_INT64,DT_DOUBLE,DT_FLOAT16}))
  775. .INPUT(y, TensorType({DT_FLOAT,DT_UINT8,DT_INT8,DT_UINT16,DT_INT16,DT_INT32,DT_INT64,DT_DOUBLE,DT_FLOAT16}))
  776. .OUTPUT(z, TensorType({DT_FLOAT,DT_UINT8,DT_INT8,DT_UINT16,DT_INT16,DT_INT32,DT_INT64,DT_DOUBLE,DT_FLOAT16}))
  777. .OP_END_FACTORY_REG(Multiply)
  778. /**
  779. *@brief Returns x + y element-wise.
  780. *@par Inputs:
  781. *Two inputs, including:
  782. * @li x1: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, float64,
  783. * float16, float32, complex128, complex64, string.
  784. * @li x2: A Tensor of the same type as "x1".
  785. *@par Outputs:
  786. *y: A Tensor. Has the same type as "x".
  787. */
  788. REG_OP(Add)
  789. .INPUT(x1, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  790. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX128,
  791. DT_COMPLEX64, DT_STRING}))
  792. .INPUT(x2, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  793. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX128,
  794. DT_COMPLEX64, DT_STRING}))
  795. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  796. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX128,
  797. DT_COMPLEX64, DT_STRING}))
  798. .OP_END_FACTORY_REG(Add)
  799. REG_OP(FusedMulAdd)
  800. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  801. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  802. .INPUT(x3, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  803. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  804. .OP_END_FACTORY_REG(FusedMulAdd)
  805. /**
  806. *@brief Returns x1 + x2 element-wise.
  807. *
  808. *@par Inputs:
  809. *@li x1: A tensor. Must be one of the following types: float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
  810. *@li x2 A tensor of the same type as "x1".
  811. *
  812. *@attention Constraints:
  813. * AddV2 supports broadcasting.
  814. *
  815. *@par Outputs:
  816. * y: A tensor. Has the same type as "x1".
  817. *
  818. */
  819. REG_OP(AddV2)
  820. .INPUT(x1, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  821. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX64,
  822. DT_COMPLEX128}))
  823. .INPUT(x2, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  824. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX64,
  825. DT_COMPLEX128}))
  826. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  827. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX64,
  828. DT_COMPLEX128}))
  829. .OP_END_FACTORY_REG(AddV2)
  830. /**
  831. *@brief Updates "ref" by adding "value" to it.
  832. *@par Inputs:
  833. *@li ref: A Tensor. Must be one of the following types: float16, float32, int8, uint8, int32, int64.
  834. *@li value: A Tensor of the same type as "ref".
  835. *@par Attributes:
  836. *use_locking: An optional bool. Defaults to "False".\n
  837. If "True", the addition will be protected by a lock;\n
  838. otherwise the behavior is undefined, but may exhibit less contention.\n
  839. * This attribute is reserved.
  840. *@par Outputs:
  841. *ref: A Tensor that holds the new value of ref after the value has been added.
  842. *@attention Constraints:\n
  843. *An input tensor of type int64 must have a shape with size 1.
  844. */
  845. REG_OP(AssignAdd)
  846. .INPUT(ref, TensorType::BasicType())
  847. .INPUT(value,TensorType::BasicType())
  848. .OUTPUT(ref, TensorType::BasicType())
  849. .ATTR(use_locking, Bool, false)
  850. .OP_END_FACTORY_REG(AssignAdd)
  851. /**
  852. *@brief Updates "ref" by assigning "value" to it.
  853. *@par Inputs:
  854. *@li ref: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64.
  855. *@li value: A Tensor of the same type as "ref".
  856. *@par Attributes:
  857. *@li validate_shape: An optional bool. Defaults to "true".\n
  858. If "true", the operation will validate that the shape of "value" matches the shape of the Tensor being assigned to.\n
  859. * If "false", "ref" will take on the shape of "value".\n
  860. * This attribute is reserved.
  861. *@li use_locking: An optional bool. Defaults to True.\n
  862. If True, the assignment will be protected by a lock;\n
  863. otherwise the behavior is undefined, but may exhibit less contention.\n
  864. * This attribute is reserved.
  865. *@par Outputs:
  866. *ref: A Tensor that holds the new value of ref after the value has been assigned.
  867. */
  868. REG_OP(Assign)
  869. .INPUT(ref, TensorType::BasicType())
  870. .INPUT(value,TensorType::BasicType())
  871. .OUTPUT(ref, TensorType::BasicType())
  872. .ATTR(validate_shape, Bool, true)
  873. .ATTR(use_locking, Bool, false)
  874. .OP_END_FACTORY_REG(Assign)
  875. /**
  876. *@brief Updates "var" by subtracting "value" from it.\n
  877. * This operation outputs "var" after the update is done. \n
  878. * This makes it easier to chain operations that need to use the reset value.
  879. *
  880. *@par Inputs:
  881. *@li var: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, uint32, uint64
  882. *@li value: A tensor of the same type as "var".
  883. *
  884. *@par Attributes:
  885. * use_locking: An optional bool. Defaults to "False". If "True", the subtraction will be protected \n
  886. * by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  887. *
  888. *@par Outputs:
  889. * y: A tensor. Has the same type as "var".
  890. *
  891. */
  892. REG_OP(AssignSub)
  893. .INPUT(var, TensorType::NumberType())
  894. .INPUT(value,TensorType::NumberType())
  895. .OUTPUT(var, TensorType::NumberType())
  896. .ATTR(use_locking, Bool, false)
  897. .OP_END_FACTORY_REG(AssignSub)
  898. /**
  899. *@brief: Computes the backpropagation of the square root operation.
  900. *@par Inputs:
  901. * Two inputs, including:
  902. *@li y: A Tensor. Must be one of the following types: float16, float32, int32, int8.
  903. *@li dy: A Tensor of the same type as "y".
  904. *@par Outputs:
  905. *z: A Tensor of the same type as "y".
  906. *@see Matmul() | Rsqrt ()
  907. */
  908. REG_OP(RsqrtGrad)
  909. .INPUT(y, TensorType({UnaryDataType,int32,int8}))
  910. .INPUT(dy, TensorType({UnaryDataType,int32,int8}))
  911. .OUTPUT(z, TensorType({UnaryDataType,int32,int8}))
  912. .OP_END_FACTORY_REG(RsqrtGrad)
  913. /**
  914. *@brief Computes hyperbolic sine of "x" element-wise.
  915. *@par Inputs:\n
  916. *x: A Tensor of type float16 or float32.
  917. *@par Outputs:\n
  918. *y: A Tensor of type float16 or float32.
  919. */
  920. REG_OP(Sinh)
  921. .INPUT(x, TensorType::UnaryDataType())
  922. .OUTPUT(y, TensorType::UnaryDataType())
  923. .OP_END_FACTORY_REG(Sinh)
  924. /**
  925. *@brief: Clips tensor values to a specified min and max.
  926. *@par Inputs:
  927. * Three inputs, including:
  928. *@li x: A Tensor of type float16, float32, or int32.
  929. *@li clip_value_min: A Tensor of the same type as "x".
  930. *@li clip_value_max: A Tensor of the same type as "x".
  931. *@par Outputs:
  932. *y: A Tensor. Has the same type as "x".
  933. */
  934. REG_OP(ClipByValue)
  935. .INPUT(x, TensorType::NumberType())
  936. .INPUT(clip_value_min, TensorType::NumberType())
  937. .INPUT(clip_value_max, TensorType::NumberType())
  938. .OUTPUT(y, TensorType::NumberType())
  939. .OP_END_FACTORY_REG(ClipByValue)
  940. /**
  941. *@brief Computes cosine of "x" element-wise.
  942. *@par Inputs:
  943. *x: A Tensor of type float16 or float32.
  944. *@par Outputs:
  945. *y: A Tensor of type float16 or float32.
  946. */
  947. REG_OP(Cosh)
  948. .INPUT(x, TensorType::UnaryDataType())
  949. .OUTPUT(y, TensorType::UnaryDataType())
  950. .OP_END_FACTORY_REG(Cosh)
  951. /**
  952. *@brief: Returns 0 if the denominator is zero, else, like Div.
  953. *@par Inputs:
  954. * Two inputs, including:
  955. *@li x1: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8, double, complex64, complex128.
  956. *@li x2: A Tensor of the same type as "x1".
  957. *@par Outputs:
  958. *y: A Tensor. Has the same type as "x1".
  959. */
  960. REG_OP(DivNoNan)
  961. .INPUT(x1, TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16,
  962. DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  963. .INPUT(x2, TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16,
  964. DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  965. .OUTPUT(y, TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16,
  966. DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  967. .OP_END_FACTORY_REG(DivNoNan)
  968. /**
  969. *@brief Reverses specific dimensions of a tensor.
  970. *@par Inputs:
  971. * One input: \n
  972. *x: A Tensor of type int16 or uint16. Up to 8D.
  973. *@par Outputs:
  974. *y: A Tensor. Has the same type and format as "x"
  975. */
  976. REG_OP(Invert)
  977. .INPUT(x, TensorType::IntegerDataType())
  978. .OUTPUT(y, TensorType::IntegerDataType())
  979. .OP_END_FACTORY_REG(Invert)
  980. /**
  981. *@brief Returns a tensor of the same shape and type with all elements set to one.
  982. *@par Inputs:
  983. *One input: \n
  984. *x: A Tensor. Must be one of the following types: float16, float32, int8, uint8, int16, uint16, int32, int64, complex128, bool.
  985. *@par Outputs:
  986. *y: A Tensor of the same type as "x".
  987. */
  988. REG_OP(OnesLike)
  989. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8,
  990. DT_UINT8, DT_INT16, DI_UINT16, DT_INT32,
  991. DT_INT64, DT_COMPLEX128, DT_BOOL}))
  992. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8,
  993. DT_UINT8, DT_INT16, DI_UINT16, DT_INT32,
  994. DT_INT64, DT_COMPLEX128, DT_BOOL}))
  995. .OP_END_FACTORY_REG(OnesLike)
  996. /**
  997. *@brief Computes the gradient for the inverse of "x" with regard its input.
  998. *@par Inputs:
  999. *@li input_y: A Tensor. Must be one of the following types: float16, float32, int8, int32.
  1000. *@li input_dy: A Tensor. Must be one of the following types: float16, float32, int8, int32.
  1001. *@par Outputs:\n
  1002. *output_data: A Tensor. Must be one of the following types: float16, float32, int8, int32.
  1003. *@attention Constraints:\n
  1004. * "input_dy" has the same shape and type as "input_y".
  1005. */
  1006. REG_OP(ReciprocalGrad)
  1007. .INPUT(y, TensorType::UnaryDataType())
  1008. .INPUT(dy, TensorType::UnaryDataType())
  1009. .OUTPUT(z, TensorType::UnaryDataType())
  1010. .OP_END_FACTORY_REG(ReciprocalGrad)
  1011. /**
  1012. *@brief Returns the truth value of (x1 > x2) element-wise.
  1013. *@par Inputs:\n
  1014. *@li x1: A Tensor of type float16, float32, int32, int8, or uint8.
  1015. *@li x2: A Tensor of the same data type as "x1".
  1016. *@par Outputs:\n
  1017. *y: A Tensor of type bool.
  1018. *@attention Constraints:\n
  1019. * Broadcasting is supported.
  1020. */
  1021. REG_OP(Greater)
  1022. .INPUT(x1, TensorType::RealNumberType())
  1023. .INPUT(x2, TensorType::RealNumberType())
  1024. .OUTPUT(y, TensorType({DT_BOOL}))
  1025. .OP_END_FACTORY_REG(Greater)
  1026. /**
  1027. *@brief Returns a tensor of the same type and shape as the input tensor with all elements set to zero.
  1028. *@par Inputs:\n
  1029. *x: A Tensor. Must be one of the following types: float16, float32, int8, int32, uint8.
  1030. *@par Outputs:\n
  1031. *y: A Tensor. Must be one of the following types: float16, float32, int8, int32, uint8.
  1032. *@attention Constraints:\n
  1033. * The output has the same shape and type as the input.
  1034. */
  1035. REG_OP(ZerosLike)
  1036. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8,
  1037. DT_UINT8, DT_INT16, DI_UINT16, DT_INT32,
  1038. DT_INT64, DT_COMPLEX128, DT_BOOL}))
  1039. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8,
  1040. DT_UINT8, DT_INT16, DI_UINT16, DT_INT32,
  1041. DT_INT64, DT_COMPLEX128, DT_BOOL}))
  1042. .OP_END_FACTORY_REG(ZerosLike)
  1043. /**
  1044. *@brief Returns the truth value of NOT "x" element-wise.
  1045. *@par Inputs:\n
  1046. *x: A Tensor of type int8.
  1047. *@par Outputs:\n
  1048. *y: A Tensor of type int8.
  1049. *@attention Constraints:\n
  1050. * The input and output values are "1" or "0", corresponding to bool values "true" and "false".
  1051. */
  1052. REG_OP(LogicalNot)
  1053. .INPUT(x, TensorType({DT_BOOL}))
  1054. .OUTPUT(y, TensorType({DT_BOOL}))
  1055. .OP_END_FACTORY_REG(LogicalNot)
  1056. /**
  1057. *@brief Computes inverse hyperbolic sine of x element-wise.\n
  1058. * Given an input tensor, this function computes inverse hyperbolic sine for every element in the tensor.
  1059. *
  1060. *@par Inputs:
  1061. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  1062. *
  1063. *@par Outputs:
  1064. * y: A tensor. Has the same type as "x".
  1065. *
  1066. */
  1067. REG_OP(Asinh)
  1068. .INPUT(x, TensorType::UnaryDataType())
  1069. .OUTPUT(y, TensorType::UnaryDataType())
  1070. .OP_END_FACTORY_REG(Asinh)
  1071. /**
  1072. *@brief Computes gradients for Asinh operation.
  1073. *
  1074. *@par Inputs:
  1075. *@li y: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  1076. *@li dy: A tensor of the same type as "y"
  1077. *
  1078. *@par Outputs:
  1079. * z: A tensor. Has the same type as "y".
  1080. *
  1081. */
  1082. REG_OP(AsinhGrad)
  1083. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1084. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1085. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  1086. .OP_END_FACTORY_REG(AsinhGrad)
  1087. /**
  1088. *@brief Computes inverse hyperbolic tangent of x element-wise.\n
  1089. * Given an input tensor, this function computes inverse hyperbolic tangent for every element in the tensor. \n Input range is [-1,1] and output range is [-inf, inf]. If input is -1, \n output will be -inf and if the input is 1, output will be inf.\n Values outside the range will have nan as output.
  1090. *
  1091. *@par Inputs:
  1092. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  1093. *
  1094. *@par Outputs:
  1095. * y: A tensor. Has the same type as "x".
  1096. *
  1097. */
  1098. REG_OP(Atanh)
  1099. .INPUT(x, TensorType::UnaryDataType())
  1100. .OUTPUT(y, TensorType::UnaryDataType())
  1101. .OP_END_FACTORY_REG(Atanh)
  1102. /**
  1103. *@brief Computes the trignometric inverse tangent of x element-wise.\n
  1104. * The atan operation returns the inverse of tan, such that if y = tan(x) then, x = atan(y).
  1105. *
  1106. *@par Inputs:
  1107. * x: A tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128.
  1108. *
  1109. *@par Outputs:
  1110. * y: A tensor. Has the same type as "x". The output of atan will lie within the invertible range of tan, i.e (-pi/2, pi/2).
  1111. *
  1112. */
  1113. REG_OP(Atan)
  1114. .INPUT(x, TensorType::UnaryDataType())
  1115. .OUTPUT(y, TensorType::UnaryDataType())
  1116. .OP_END_FACTORY_REG(Atan)
  1117. /**
  1118. *@brief Computes gradients for Atan operation.
  1119. *
  1120. *@par Inputs:
  1121. *@li y: A tensor of type float16 or float32.
  1122. *@li dy: A tensor of the same type as "y"
  1123. *
  1124. *@par Outputs:
  1125. * z: A tensor. Has the same type as "y".
  1126. *
  1127. */
  1128. REG_OP(AtanGrad)
  1129. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1130. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1131. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  1132. .OP_END_FACTORY_REG(AtanGrad)
  1133. /**
  1134. *@brief Computes arctangent of x1/x2 element-wise, respecting signs of the arguments.
  1135. *
  1136. *@par Inputs:
  1137. *@li x1: A tensor. Must be one of the following types: float16, float32, float64
  1138. *@li x2: A tensor of the same type as "x1".
  1139. *
  1140. *@par Outputs:
  1141. * y: A tensor. Has the same type as "x1".
  1142. *
  1143. */
  1144. REG_OP(Atan2)
  1145. .INPUT(x1, TensorType::FloatingDataType())
  1146. .INPUT(x2, TensorType::FloatingDataType())
  1147. .OUTPUT(y, TensorType::FloatingDataType())
  1148. .OP_END_FACTORY_REG(Atan2)
  1149. /**
  1150. *@brief Returns the truth value of abs(x1-x2) < tolerance element-wise.
  1151. *
  1152. *@par Inputs:
  1153. *@li x1: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, float16, uint32, uint64
  1154. *@li x2: A tensor of the same type as "x1".
  1155. *
  1156. *@par Attributes:
  1157. * tolerance: Defaults to "1e-05".
  1158. *
  1159. *@par Outputs:
  1160. * y: A tensor of type bool.
  1161. *
  1162. */
  1163. REG_OP(ApproximateEqual)
  1164. .INPUT(x1, TensorType::NumberType())
  1165. .INPUT(x2, TensorType::NumberType())
  1166. .OUTPUT(y, TensorType({DT_BOOL}))
  1167. .ATTR(tolerance, Float, 1e-5)
  1168. .OP_END_FACTORY_REG(ApproximateEqual)
  1169. /**
  1170. *@brief Returns the element-wise sum of a list of tensors.\n
  1171. * AccumulateNV2 performs the same operation as AddN, but does not wait for all of its inputs to be ready before beginning to sum.\n This can save memory if inputs are ready at different times, \n since minimum temporary storage is proportional to the output size rather than the inputs size.\n Returns a Tensor of same shape and type as the elements of inputs.
  1172. *
  1173. *@par Inputs:
  1174. * x: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, \n qint8, quint8, qint32, uint16, complex128, float16, uint32, uint64.
  1175. *
  1176. *@par Outputs:
  1177. * y: A tensor. Has the same type as "x".
  1178. *
  1179. */
  1180. REG_OP(AccumulateNV2)
  1181. .DYNAMIC_INPUT(x, TensorType::NumberType())
  1182. .OUTPUT(y, TensorType::NumberType())
  1183. .OP_END_FACTORY_REG(AccumulateNV2)
  1184. /**
  1185. *@brief Fake-quantizes the input Tensor, type float to output a Tensor of same type. \n
  1186. * [min, max] define the clamping range for the "inputs" data.\n
  1187. * the values of "x" are quantized into the quantization range ([0, 2^num_bits - 1] \n
  1188. * when "narrow_range" is "false" or [1, 2^num_bits - 1] when it is "true") and \n
  1189. * then de-quantized and output as float32 in [min; max] interval.\n
  1190. * num_bits is the bit width of the quantization, between 2 and 16, inclusive. \n
  1191. * Quantization is called fake since the output is still in floating point. \n
  1192. *@par Inputs:
  1193. *One input: \n
  1194. *x: A Tensor of type float32.
  1195. *@par Attributes:
  1196. *@li min: An optional attribute. Defaults to "-6".
  1197. *@li max: An optional attribute. Defaults to "6".
  1198. *@li num_bits: An optional attribute. Defaults to "8".
  1199. *@li narrow_range: An optional bool. Defaults to "false".
  1200. *@par Outputs:
  1201. *y: A Tensor. Has the same shape and type of "x".
  1202. */
  1203. REG_OP(FakeQuantWithMinMaxArgs)
  1204. .INPUT(x, TensorType({DT_FLOAT}))
  1205. .OUTPUT(y, TensorType({DT_FLOAT}))
  1206. .ATTR(min, Float, -6.0)
  1207. .ATTR(max, Float, 6.0)
  1208. .ATTR(num_bits, Int, 8)
  1209. .ATTR(narrow_range, Bool, false)
  1210. .OP_END_FACTORY_REG(FakeQuantWithMinMaxArgs)
  1211. /**
  1212. *@brief Computes gradients for a FakeQuantWithMinMaxArgs operation.
  1213. *@par Inputs:
  1214. *Two inputs, including: \n
  1215. *@li gradients: A Tensor of type float32. Backpropagated gradients above the FakeQuantWithMinMaxArgs operation.
  1216. *@li x: A Tensor of type float32. Has the same type and format as "gradients".\n
  1217. * This is the input Tensor of the FakeQuantWithMinMaxArgs operator.\n
  1218. *@par Attributes:
  1219. *@li min: An optional attribute. Defaults to "-6".
  1220. *@li max: An optional attribute. Defaults to "6".
  1221. *@li num_bits: An optional attribute. Defaults to "8".
  1222. *@li narrow_range: An optional bool. Defaults to "False".
  1223. *@par Outputs:
  1224. *y: A Tensor of type float32.
  1225. */
  1226. REG_OP(FakeQuantWithMinMaxArgsGradient)
  1227. .INPUT(gradients, TensorType({DT_FLOAT}))
  1228. .INPUT(x, TensorType({DT_FLOAT}))
  1229. .OUTPUT(y, TensorType({DT_FLOAT}))
  1230. .ATTR(min, Float, -6.0)
  1231. .ATTR(max, Float, 6.0)
  1232. .ATTR(num_bits, Int, 8)
  1233. .ATTR(narrow_range, Bool, false)
  1234. .OP_END_FACTORY_REG(FakeQuantWithMinMaxArgsGradient)
  1235. /**
  1236. *@brief Fake-quantize the 'inputs' tensor of type float via global float scalars.
  1237. *@par Inputs:
  1238. *Three inputs, including:
  1239. *@li x: A Tensor of type float32.
  1240. *@li min: A Tensor of type float32. Has the same type and format as "x".
  1241. *@li max: A Tensor of type float32. Has the same type and format as "x".\n
  1242. *[min; max] define the clamping range for the inputs data
  1243. *@par Attributes:
  1244. *@li num_bits: An optional attribute. Defaults to "8".
  1245. *@li narrow_range: An optional bool. Defaults to "False".
  1246. *@par Outputs:
  1247. *y: A Tensor of type float32.
  1248. */
  1249. REG_OP(FakeQuantWithMinMaxVars)
  1250. .INPUT(x, TensorType({DT_FLOAT}))
  1251. .INPUT(min, TensorType({DT_FLOAT}))
  1252. .INPUT(max, TensorType({DT_FLOAT}))
  1253. .OUTPUT(y, TensorType({DT_FLOAT}))
  1254. .ATTR(num_bits, Int, 8)
  1255. .ATTR(narrow_range, Bool, false)
  1256. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVars)
  1257. /**
  1258. *@brief Computes gradients for a FakeQuantWithMinMaxVars operation.
  1259. *@par Inputs:
  1260. *Four inputs, including:
  1261. *@li gradients: A Tensor of type float32.
  1262. *@li x: A Tensor of type float32.
  1263. *@li min: A Tensor of type float32.
  1264. *@li max: A Tensor of type float32.
  1265. *@par Attributes:
  1266. *@li num_bits: An integer specifying the quantization bit width. Defaults to "8".
  1267. *@li narrow_range: A Boolean specifying whether to use a narrow range for quantization. Defaults to "False".
  1268. *@par Outputs:
  1269. *@li backprops_wrt_x: A Tensor. Has the same type as input "x".
  1270. *@li backprops_wrt_min: A Tensor. Has the same type as input "min".
  1271. *@li backprops_wrt_max: A Tensor. Has the same type as input "max".
  1272. *@attention Constraints:
  1273. *@li "gradients" has the same shape as "x".
  1274. *@li "min" and "max" are scalars.
  1275. *@li "num_bits" is between 2 and 16
  1276. *@see Region()
  1277. *@par Third-party framework compatibility
  1278. * Compatible with the operator FakeQuantWithMinVarsGradient.
  1279. */
  1280. REG_OP(FakeQuantWithMinMaxVarsGradient)
  1281. .INPUT(gradients, TensorType({DT_FLOAT}))
  1282. .INPUT(x, TensorType({DT_FLOAT}))
  1283. .INPUT(min, TensorType({DT_FLOAT}))
  1284. .INPUT(max, TensorType({DT_FLOAT}))
  1285. .OUTPUT(backprops_wrt_x, TensorType({DT_FLOAT}))
  1286. .OUTPUT(backprops_wrt_min, TensorType({DT_FLOAT}))
  1287. .OUTPUT(backprops_wrt_max, TensorType({DT_FLOAT}))
  1288. .ATTR(num_bits, Int, 8)
  1289. .ATTR(narrow_range, Bool, false)
  1290. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVarsGradient)
  1291. /**
  1292. *@brief Fake-quantizes the "inputs" tensor of type float \n
  1293. via per-channel floats min and max of shape [d] to "outputs" \n
  1294. tensor of same shape as inputs
  1295. *@par Inputs:
  1296. *Three inputs, including:
  1297. *@li x: A Tensor of type float32.
  1298. *@li min: A Tensor of type float32.
  1299. *@li max: A Tensor of type float32.
  1300. *@par Attributes:
  1301. *@li num_bits: An integer specifying the quantization bit width. Defaults to "8".
  1302. *@li narrow_range: A Boolean specifying whether to use a narrow range for quantization. Defaults to "False".
  1303. *@par Outputs:
  1304. *y: A Tensor. Has the same type as input "x".
  1305. *@attention Constraints:
  1306. *@li "min" and "max" have one-dimensional shapes.
  1307. *@li "min" has the same last dimension size as "x". "max" has the same last dimension size as "x".
  1308. *@li "num_bits" is between 2 and 16
  1309. *@see Region()
  1310. */
  1311. REG_OP(FakeQuantWithMinMaxVarsPerChannel)
  1312. .INPUT(x, TensorType({DT_FLOAT}))
  1313. .INPUT(min, TensorType({DT_FLOAT}))
  1314. .INPUT(max, TensorType({DT_FLOAT}))
  1315. .OUTPUT(y, TensorType({DT_FLOAT}))
  1316. .ATTR(num_bits, Int, 8)
  1317. .ATTR(narrow_range, Bool, false)
  1318. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVarsPerChannel)
  1319. /**
  1320. *@brief Computes gradients for a FakeQuantWithMinMaxVarsPerChannel operation.
  1321. *@par Inputs:
  1322. *Four inputs, including:
  1323. *@li gradients: A Tensor of type float32.
  1324. *@li x: A Tensor of type float32.
  1325. *@li min: A Tensor of type float32.
  1326. *@li max: A Tensor of type float32.
  1327. *@par Attributes:
  1328. *@li num_bits: An integer specifying the quantization bit width. Defaults to "8".
  1329. *@li narrow_range: A Boolean specifying whether to use a narrow range for quantization. Defaults to "False".
  1330. *@par Outputs:
  1331. *@li backprops_wrt_x: A Tensor. Has the same type as input "x".
  1332. *@li backprops_wrt_min: A Tensor. Has the same type as input "min".
  1333. *@li backprops_wrt_max: A Tensor. Has the same type as input "max".
  1334. *@attention Constraints:
  1335. *@li "gradients" has the same shape as "x".
  1336. *@li "min" and "max" have one-dimensional shapes.
  1337. *@li "min" has the same last dimension size as "x". "max" has the same last dimension size as "x". "gradients" has the same last dimension size as "x".
  1338. *@li "num_bits" is between 2 and 16
  1339. *@see Region()
  1340. */
  1341. REG_OP(FakeQuantWithMinMaxVarsPerChannelGradient)
  1342. .INPUT(gradients, TensorType({DT_FLOAT}))
  1343. .INPUT(x, TensorType({DT_FLOAT}))
  1344. .INPUT(min, TensorType({DT_FLOAT}))
  1345. .INPUT(max, TensorType({DT_FLOAT}))
  1346. .OUTPUT(backprops_wrt_x, TensorType({DT_FLOAT}))
  1347. .OUTPUT(backprops_wrt_min, TensorType({DT_FLOAT}))
  1348. .OUTPUT(backprops_wrt_max, TensorType({DT_FLOAT}))
  1349. .ATTR(num_bits, Int, 8)
  1350. .ATTR(narrow_range, Bool, false)
  1351. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVarsPerChannelGradient)
  1352. /**
  1353. *@brief Element-wise computes the bitwise AND of "x1" and "x2".
  1354. *@par Inputs:
  1355. *Two inputs, including:
  1356. * @li x1: A Tensor. Must be one of the following types: int8, int16,
  1357. * int32, int64, uint8, uint16, uint32, uint64.
  1358. * @li x2: A Tensor of the same type as "x1".
  1359. *@par Outputs:
  1360. *y: A Tensor. Has the same type as "x1".
  1361. */
  1362. REG_OP(BitwiseAnd)
  1363. .INPUT(x1, TensorType::IntegerDataType())
  1364. .INPUT(x2, TensorType::IntegerDataType())
  1365. .OUTPUT(y, TensorType::IntegerDataType())
  1366. .OP_END_FACTORY_REG(BitwiseAnd)
  1367. /**
  1368. *@brief Element-wise computes the bitwise OR of "x1" and "x2".
  1369. *@par Inputs:
  1370. *Two inputs, including:
  1371. * @li x1: A Tensor. Must be one of the following types: int8, int16,
  1372. * int32, int64, uint8, uint16, uint32, uint64.
  1373. * @li x2: A Tensor of the same type as "x1".
  1374. *@par Outputs:
  1375. *y: A Tensor. Has the same type as "x1".
  1376. */
  1377. REG_OP(BitwiseOr)
  1378. .INPUT(x1, TensorType::IntegerDataType())
  1379. .INPUT(x2, TensorType::IntegerDataType())
  1380. .OUTPUT(y, TensorType::IntegerDataType())
  1381. .OP_END_FACTORY_REG(BitwiseOr)
  1382. /**
  1383. *@brief Elementwise computes the bitwise XOR of "x1" and "x2".
  1384. *@par Inputs:
  1385. *Two inputs, including: \n
  1386. *@li x1: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, uint32, uint64.\n
  1387. * The format is NC1HWC0 or ND.
  1388. *@li x2: A Tensor. Has the same type and format as "x1".
  1389. *@par Outputs:
  1390. *y: Output result. Has the same type as "x1".
  1391. */
  1392. REG_OP(BitwiseXor)
  1393. .INPUT(x1, TensorType::IntegerDataType())
  1394. .INPUT(x2, TensorType::IntegerDataType())
  1395. .OUTPUT(y, TensorType::IntegerDataType())
  1396. .OP_END_FACTORY_REG(BitwiseXor)
  1397. /**
  1398. *@brief Returns element-wise smallest integer not less than "x".
  1399. *@par Inputs:
  1400. * x: A Tensor. TensorType::FloatingDataType().
  1401. *@par Outputs:
  1402. *y: A Tensor. Has the same type as "x".
  1403. */
  1404. REG_OP(Ceil)
  1405. .INPUT(x, TensorType::FloatingDataType())
  1406. .OUTPUT(y, TensorType::FloatingDataType())
  1407. .OP_END_FACTORY_REG(Ceil)
  1408. REG_OP(Floor)
  1409. .INPUT(x, TensorType::FloatingDataType())
  1410. .OUTPUT(y, TensorType::FloatingDataType())
  1411. .OP_END_FACTORY_REG(Floor)
  1412. /**
  1413. *@brief Divides "x1/x2" element-wise, rounding toward the
  1414. * most negative integer.
  1415. *@par Inputs:
  1416. *Two inputs, including:
  1417. * @li x1: A Tensor. Must be one of the following types: float16, float32, int32, int64, int8,
  1418. * uint8, int16, uint16, double, complex64, complex128.
  1419. * @li x2: A Tensor of the same type as "x1".
  1420. *@par Outputs:
  1421. *y: A Tensor. Has the same type as "x1".
  1422. */
  1423. REG_OP(FloorDiv)
  1424. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  1425. DT_INT64, DT_INT16, DT_UINT16, DT_DOUBLE,
  1426. DT_COMPLEX64, DT_COMPLEX128}))
  1427. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  1428. DT_INT64, DT_INT16,DT_UINT16, DT_DOUBLE,
  1429. DT_COMPLEX64, DT_COMPLEX128}))
  1430. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  1431. DT_INT64, DT_INT16,DT_UINT16, DT_DOUBLE,
  1432. DT_COMPLEX64, DT_COMPLEX128}))
  1433. .OP_END_FACTORY_REG(FloorDiv)
  1434. /**
  1435. *@brief Returns element-wise remainder of division. Consistent with: floor(x1/x2) * x2 + mod(x1, x2) = x1.
  1436. *@par Inputs:
  1437. * Two inputs, including:
  1438. *@li x1: A Tensor
  1439. *@li x2: A Tensor. Must have the same type as "x1".
  1440. *
  1441. *@par Outputs:
  1442. *y: Result remainder.
  1443. */
  1444. REG_OP(FloorMod)
  1445. .INPUT(x1, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_FLOAT16,
  1446. DT_DOUBLE}))
  1447. .INPUT(x2, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_FLOAT16,
  1448. DT_DOUBLE}))
  1449. .OUTPUT(y, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_FLOAT16,
  1450. DT_DOUBLE}))
  1451. .OP_END_FACTORY_REG(FloorMod)
  1452. /**
  1453. *@brief Computes the power of "x1" to "x2".
  1454. *@par Inputs:
  1455. *Two inputs, including:
  1456. * @li x1: A Tensor. Must be one of the following types:
  1457. * float16, float32, int32, int64, int8, uint8, double, complex64, complex128.
  1458. * @li x2: A Tensor of the same type as "x1".
  1459. *@par Outputs:
  1460. *y: A Tensor. Has the same type as "x1".
  1461. */
  1462. REG_OP(Pow)
  1463. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_INT8,
  1464. DT_UINT8, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  1465. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_INT8,
  1466. DT_UINT8, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  1467. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_INT8,
  1468. DT_UINT8, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  1469. .OP_END_FACTORY_REG(Pow)
  1470. /**
  1471. *@brief Return element-wise integer closest to x.
  1472. *@par Inputs:
  1473. *One input, include:
  1474. *x: A mutable Tensor. Must be one of the following types:
  1475. * float16, float32, double.
  1476. *@par Outputs:
  1477. *y: A mutable Tensor. Has the same type as "x".
  1478. */
  1479. REG_OP(Rint)
  1480. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1481. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1482. .OP_END_FACTORY_REG(Rint)
  1483. /**
  1484. *@brief Rounds the values of a tensor to the nearest integer, element-wise. Rounds half to even.
  1485. *@par Inputs:
  1486. *Inputs including: \n
  1487. *x: A required Tensor of type float16, float32, or int32.
  1488. *@par Outputs:
  1489. *y: A required Tensor. Has the same data type and shape as "x".
  1490. */
  1491. REG_OP(Round)
  1492. .INPUT(x, TensorType(DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64,
  1493. DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128))
  1494. .OUTPUT(y, TensorType(DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64,
  1495. DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128))
  1496. .OP_END_FACTORY_REG(Round)
  1497. /**
  1498. *@brief: Computes sine of "x" element-wise.
  1499. *@par Inputs:
  1500. *One input:
  1501. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128, int32, int64
  1502. *@par Outputs:
  1503. *y: A Tensor. Has the same type as "x".
  1504. */
  1505. REG_OP(Sin)
  1506. .INPUT(x, TensorType::UnaryDataType())
  1507. .OUTPUT(y, TensorType::UnaryDataType())
  1508. .OP_END_FACTORY_REG(Sin)
  1509. /**
  1510. *@brief: Computes tan of "x" element-wise.
  1511. *@par Inputs:
  1512. *One input:
  1513. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128, int32, int64
  1514. *@par Outputs:
  1515. *y: A Tensor. Has the same type as "x".
  1516. */
  1517. REG_OP(Tan)
  1518. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64,
  1519. DT_COMPLEX128, DT_INT32, DT_INT64}))
  1520. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64,
  1521. DT_COMPLEX128, DT_INT32, DT_INT64}))
  1522. .OP_END_FACTORY_REG(Tan)
  1523. /**
  1524. *@brief Returns element-wise remainder of division.
  1525. *@par Inputs:
  1526. *Two inputs, including:
  1527. * @li x1: A Tensor. Must be one of the following types: float16, float32, double, int32, int64.
  1528. * @li x2: A Tensor of the same type as "x1".
  1529. *@par Outputs:
  1530. *y: A Tensor. Has the same type as "x1".
  1531. */
  1532. REG_OP(TruncateMod)
  1533. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT64,
  1534. DT_INT32}))
  1535. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT64,
  1536. DT_INT32}))
  1537. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT64,
  1538. DT_INT32}))
  1539. .OP_END_FACTORY_REG(TruncateMod)
  1540. /**
  1541. *@brief Adds 'bias' to 'x'.
  1542. *@par Inputs:
  1543. *Two inputs, including:
  1544. * @li x: A Tensor of type NumberType.
  1545. * @li bias: A 1D Tensor of the same type as "x".
  1546. *@par Attributes:
  1547. *data_format: An optional string. Defaults to "NHWC".
  1548. *@par Outputs:
  1549. *y: A Tensor with same type as "x".
  1550. */
  1551. REG_OP(BiasAdd)
  1552. .INPUT(x, TensorType::NumberType())
  1553. .INPUT(bias, TensorType::NumberType())
  1554. .OUTPUT(y, TensorType::NumberType())
  1555. .ATTR(data_format, String, "NHWC")
  1556. .OP_END_FACTORY_REG(BiasAdd)
  1557. /**
  1558. *@brief Returns the index with the smallest value across dimensions of a tensor.
  1559. *@par Inputs:
  1560. *Two inputs, including: \n
  1561. *@li x: A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, float16, uint32, uint64.\n
  1562. *format is ND.
  1563. *@li dimension: A Tensor. Must be one of the following types: int32, int64. Must be in the range [-rank(input x), rank(input x)]. Describes which dimension of the input Tensor to reduce across. \n
  1564. * The format is ND.
  1565. *@par Attributes:
  1566. *output_type: The output type, either "int32" or "int64". Defaults to "int64".
  1567. *@par Outputs:
  1568. *y: A Tensor of type "output_type".
  1569. */
  1570. REG_OP(ArgMin)
  1571. .INPUT(x, TensorType::NumberType())
  1572. .INPUT(dimension, TensorType::IndexNumberType())
  1573. .OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  1574. .ATTR(output_type, Type, DT_INT64)
  1575. .OP_END_FACTORY_REG(ArgMin)
  1576. /**
  1577. *@brief Returns the index with the smallest value across dimensions of a tensor.
  1578. *@par Inputs:
  1579. *One input: \n
  1580. *x: A Tensor of type float16 or float32 in ND format.
  1581. *@par Attributes:
  1582. *@li dimension: The dimension of the input Tensor to reduce across.
  1583. *@li output_type: An optional attribute, specifying the output data type. Must be "int32". Defaults to "int64".
  1584. *@par Outputs:
  1585. *y: A Tensor of type output_type.
  1586. */
  1587. REG_OP(ArgMinD)
  1588. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1589. .OUTPUT(y, TensorType({DT_INT32}))
  1590. .REQUIRED_ATTR(dimension, Int)
  1591. .ATTR(output_type, Type, DT_INT64)
  1592. .OP_END_FACTORY_REG(ArgMinD)
  1593. /**
  1594. *@brief Returns the index with the largest value across axes of a tensor.
  1595. *@par Inputs:
  1596. * Two inputs, including: \n
  1597. *@li x: A multi-dimensional Tensor of type float16, float32, or int16.
  1598. *@li dimension: A Scalar of type int32, specifying the index with the largest value.
  1599. *@par Outputs: \n
  1600. *y: A multi-dimensional Tensor of type int32, specifying the index with the largest value. The dimension is one less than that of "x".
  1601. *@attention Constraints:
  1602. *@li x: If there are multiple maximum values, the index of the first maximum value is used.
  1603. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x".
  1604. */
  1605. REG_OP(ArgMax)
  1606. .INPUT(x, TensorType::NumberType())
  1607. .INPUT(dimension, TensorType::IndexNumberType())
  1608. .OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  1609. .ATTR(output_type, Type, DT_INT64)
  1610. .OP_END_FACTORY_REG(ArgMax)
  1611. /**
  1612. *@brief Returns the index with the largest value across axes of a tensor.
  1613. *@par Inputs:
  1614. * One input, including: \n
  1615. *x: A multi-dimensional Tensor of type float16, float32.
  1616. *@par Attributes:
  1617. *dimension: An integer of type int32, specifying the axis information of the index with the maximum value.
  1618. *@par Outputs: \n
  1619. *y: A multi-dimensional Tensor of type int32, specifying the index with the largest value. The dimension is one less than that of "x".
  1620. *@attention Constraints:
  1621. *@li x: If there are multiple maximum values, the index of the first maximum value is used.
  1622. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x".
  1623. */
  1624. REG_OP(ArgMaxD)
  1625. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1626. .OUTPUT(y, TensorType({DT_INT32}))
  1627. .REQUIRED_ATTR(dimension, Int)
  1628. .ATTR(output_type, Type, DT_INT64)
  1629. .OP_END_FACTORY_REG(ArgMaxD)
  1630. /**
  1631. *@brief Returns the maximum value of all elements in the input in the given dimension.
  1632. *@par Inputs:
  1633. *One input: \n
  1634. *x: A multi-dimensional Tensor of type float16 or float32.
  1635. *@par Attributes:
  1636. *@li dimension: An integer of type int32, specifying the axis information of the index with the maximum value.
  1637. *@li keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false".
  1638. *@par Outputs:
  1639. *@li indice: A multi-dimensional Tensor of type int32, specifying the index. (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".)
  1640. *@li values: A Tensor, specifying the maximum value. Has the same dimensions as "indice" and the same type as "x".
  1641. *@attention Constraints:
  1642. *@li If there are multiple maximum values, the index of the first maximum value is used.
  1643. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x".
  1644. */
  1645. REG_OP(ArgMaxWithValue)
  1646. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  1647. .OUTPUT(indice,TensorType({DT_INT32}))
  1648. .OUTPUT(values, TensorType({DT_FLOAT,DT_FLOAT16}))
  1649. .REQUIRED_ATTR(dimension, Int)
  1650. .ATTR(keep_dims, Bool, false)
  1651. .OP_END_FACTORY_REG(ArgMaxWithValue)
  1652. /**
  1653. *@par Inputs:
  1654. *One input: \n
  1655. *x: A multi-dimensional Tensor of type float16 or float32.
  1656. *@par Attributes:
  1657. *@li dimension: An integer of type int32, specifying the axis information of the index with the maximum value.
  1658. *@li keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false".
  1659. *@par Outputs:
  1660. *@li indice: A multi-dimensional Tensor of type int32, specifying the index. (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".)
  1661. *@li values: A Tensor, specifying the minimum value. Has the same dimensions as "indice" and the same type as "x".
  1662. *@attention Constraints:
  1663. *@li If there are multiple minimum values, the index of the first minimum value is used.
  1664. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x".
  1665. *@li Performing the ArgMinWithValue operation on the last axis of float32 data is not supported on a mini platform.
  1666. */
  1667. REG_OP(ArgMinWithValue)
  1668. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  1669. .OUTPUT(indice,TensorType({DT_INT32}))
  1670. .OUTPUT(values, TensorType({DT_FLOAT,DT_FLOAT16}))
  1671. .REQUIRED_ATTR(dimension, Int)
  1672. .ATTR(keep_dims, Bool, false)
  1673. .OP_END_FACTORY_REG(ArgMinWithValue)
  1674. REG_OP(Eltwise)
  1675. .DYNAMIC_INPUT(__input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1676. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1677. .ATTR(mode, Int, 1)
  1678. .ATTR(coeff, ListFloat, {})
  1679. .OP_END_FACTORY_REG(Eltwise)
  1680. /**
  1681. *@brief Computes element-wise population count.
  1682. *@par Inputs:
  1683. *x: A Tensor of type TensorType::IntegerDataType().
  1684. *@par Outputs:
  1685. *y: A Tensor of type uint8.
  1686. */
  1687. REG_OP(PopulationCount)
  1688. .INPUT(x, TensorType::IntegerDataType())
  1689. .OUTPUT(y, TensorType({DT_UINT8}))
  1690. .OP_END_FACTORY_REG(PopulationCount)
  1691. REG_OP(LambNextMVWithDecay)
  1692. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1693. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1694. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1695. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1696. .INPUT(input5, TensorType({DT_FLOAT16,DT_FLOAT}))
  1697. .INPUT(input6, TensorType({DT_FLOAT16,DT_FLOAT}))
  1698. .INPUT(input7, TensorType({DT_FLOAT16,DT_FLOAT}))
  1699. .INPUT(input8, TensorType({DT_FLOAT16,DT_FLOAT}))
  1700. .INPUT(input9, TensorType({DT_FLOAT16,DT_FLOAT}))
  1701. .INPUT(inputx0, TensorType({DT_FLOAT16,DT_FLOAT}))
  1702. .INPUT(inputx1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1703. .INPUT(inputx2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1704. .INPUT(inputx3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1705. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1706. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1707. .OUTPUT(output3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1708. .OUTPUT(output4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1709. .OP_END_FACTORY_REG(LambNextMVWithDecay)
  1710. REG_OP(LambNextMVWithDecayV1)
  1711. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1712. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1713. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1714. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1715. .INPUT(input5, TensorType({DT_FLOAT16,DT_FLOAT}))
  1716. .INPUT(input6, TensorType({DT_FLOAT16,DT_FLOAT}))
  1717. .INPUT(input7, TensorType({DT_FLOAT16,DT_FLOAT}))
  1718. .INPUT(input8, TensorType({DT_FLOAT16,DT_FLOAT}))
  1719. .INPUT(input9, TensorType({DT_FLOAT16,DT_FLOAT}))
  1720. .INPUT(inputx0, TensorType({DT_FLOAT16,DT_FLOAT}))
  1721. .INPUT(inputx1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1722. .INPUT(inputx2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1723. .INPUT(inputx3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1724. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1725. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1726. .OUTPUT(output3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1727. .OUTPUT(output4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1728. .OP_END_FACTORY_REG(LambNextMVWithDecayV1)
  1729. REG_OP(LambNextMV)
  1730. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1731. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1732. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1733. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1734. .INPUT(input5, TensorType({DT_FLOAT16,DT_FLOAT}))
  1735. .INPUT(input6, TensorType({DT_FLOAT16,DT_FLOAT}))
  1736. .INPUT(input7, TensorType({DT_FLOAT16,DT_FLOAT}))
  1737. .INPUT(input8, TensorType({DT_FLOAT16,DT_FLOAT}))
  1738. .INPUT(input9, TensorType({DT_FLOAT16,DT_FLOAT}))
  1739. .INPUT(inputx0, TensorType({DT_FLOAT16,DT_FLOAT}))
  1740. .INPUT(inputx1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1741. .INPUT(inputx2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1742. .INPUT(inputx3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1743. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1744. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1745. .OUTPUT(output3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1746. .OUTPUT(output4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1747. .OP_END_FACTORY_REG(LambNextMV)
  1748. REG_OP(LambNextRight)
  1749. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1750. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1751. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1752. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1753. .INPUT(truediv1_recip, TensorType({DT_FLOAT16,DT_FLOAT}))
  1754. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1755. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1756. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1757. .OP_END_FACTORY_REG(LambNextRight)
  1758. REG_OP(LambNextLeft)
  1759. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1760. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1761. .INPUT(mul_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1762. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1763. .INPUT(truediv_recip, TensorType({DT_FLOAT16,DT_FLOAT}))
  1764. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1765. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1766. .OP_END_FACTORY_REG(LambNextLeft)
  1767. REG_OP(LambUpdateWithLr)
  1768. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1769. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1770. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1771. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1772. .INPUT(input5, TensorType({DT_FLOAT16,DT_FLOAT}))
  1773. .INPUT(input6, TensorType({DT_FLOAT16,DT_FLOAT}))
  1774. .INPUT(input7, TensorType({DT_FLOAT16,DT_FLOAT}))
  1775. .INPUT(input8, TensorType({DT_FLOAT16,DT_FLOAT}))
  1776. .INPUT(input9, TensorType({DT_FLOAT16,DT_FLOAT}))
  1777. .OUTPUT(output_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1778. .OP_END_FACTORY_REG(LambUpdateWithLr)
  1779. REG_OP(LambUpdateWithLrV2)
  1780. .INPUT(x1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1781. .INPUT(x2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1782. .INPUT(x3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1783. .INPUT(x4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1784. .INPUT(x5, TensorType({DT_FLOAT16,DT_FLOAT}))
  1785. .INPUT(greater_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1786. .INPUT(select_e, TensorType({DT_FLOAT16,DT_FLOAT}))
  1787. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1788. .OP_END_FACTORY_REG(LambUpdateWithLrV2)
  1789. REG_OP(AdamApplyOneWithDecay)
  1790. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  1791. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1792. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1793. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1794. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1795. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1796. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1797. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1798. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1799. .INPUT(mul4_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1800. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1801. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  1802. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1803. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1804. .OP_END_FACTORY_REG(AdamApplyOneWithDecay)
  1805. REG_OP(AdamApplyOne)
  1806. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  1807. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1808. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1809. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1810. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  1811. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1812. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1813. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1814. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1815. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1816. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  1817. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1818. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1819. .OP_END_FACTORY_REG(AdamApplyOne)
  1820. REG_OP(ClipByNormNoDivSum)
  1821. .INPUT(input_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1822. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1823. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1824. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  1825. .OUTPUT(output_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1826. .OP_END_FACTORY_REG(ClipByNormNoDivSum)
  1827. REG_OP(SquareSumV2)
  1828. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1829. .OUTPUT(y1, TensorType({DT_FLOAT16,DT_FLOAT}))
  1830. .OUTPUT(y2, TensorType({DT_FLOAT16,DT_FLOAT}))
  1831. .ATTR(axis, ListInt, {})
  1832. .ATTR(keep_dims, Bool, false)
  1833. .OP_END_FACTORY_REG(SquareSumV2)
  1834. REG_OP(SquareSumV1)
  1835. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1836. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1837. .ATTR(axis, ListInt, {})
  1838. .ATTR(keep_dims, Bool, false)
  1839. .OP_END_FACTORY_REG(SquareSumV1)
  1840. REG_OP(FusedMulAddN)
  1841. .INPUT(x1, TensorType::NumberType())
  1842. .INPUT(x2, TensorType::NumberType())
  1843. .INPUT(x3, TensorType::NumberType())
  1844. .OUTPUT(y, TensorType::NumberType())
  1845. .OP_END_FACTORY_REG(FusedMulAddN)
  1846. /**
  1847. *@brief Add 'bias' to 'x'.
  1848. *@par Inputs:
  1849. * Two inputs, including:
  1850. *@li x: An ND tensor of type float16 or float32.
  1851. *@li bias: An ND tensor of type float16 or float32.
  1852. *@par Attributes:
  1853. *@li axis: An optional int32 used to compute the shape of bias input from the online bottoms. Defaults to "1".
  1854. *@li num_axes:
  1855. *@li bias_from_blob:
  1856. *@par Outputs:
  1857. *y: An ND tensor of type float16 or float32.
  1858. *@attention Constraints:\n
  1859. * Assume that the shape length of "x" is "n" and that of "bias" is "m".
  1860. *@li "axis" is within the range [-n, n-1]. num_axes >= -1.
  1861. *@li If "bias_from_blob = true", "num_axes = -1", and "axis >= 0", the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < n-axis).\n
  1862. * If "axis < 0", the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < -axis).
  1863. *@li If "bias_from_blob = true" and "num_axes = 0", "bias" is a scalar with shape length 1 and dimension size 1.
  1864. *@li If "bias_from_blob = true", "num_axes > 0, and "axis >= 0", "axis + num_axes" must be less than or equal to "n" and the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < num_axes).\n
  1865. * If "axis < 0", "n + axis + num_axes" must be less than or equal to "n" and the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < num_axes).
  1866. *@li If "bias_from_blob = false", "bias" is not a scalar, and "axis >= 0","axis + m" must be less than or equal to "n" and the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < m).\n
  1867. * If "axis < 0", "n + axis + m" must be less than or equal to "n" and the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < m).
  1868. */
  1869. REG_OP(Bias)
  1870. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16})) /* "First operand." */
  1871. .INPUT(bias, TensorType({DT_FLOAT, DT_FLOAT16})) /* "Second operand." */
  1872. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16})) /* "Result, has same element type as x" */
  1873. .ATTR(axis, Int, 1)
  1874. .ATTR(num_axes, Int, 1)
  1875. .ATTR(bias_from_blob, Bool, true)
  1876. .OP_END_FACTORY_REG(Bias)
  1877. /**
  1878. * @brief Computes the gradient for Local Response Normalization.
  1879. * @par Inputs:
  1880. * @li grads: A 4D Tensor of type float16 or float32.
  1881. * @li x: A 4D Tensor of type float16 or float32.
  1882. * @li y: A 4D Tensor of type float16 or float32.
  1883. * @par Attributes:
  1884. * @li depth_radius: An optional int, specifying the half-width of the
  1885. * normalization window. Defaults to "5".
  1886. * @li bias: An optional float32. An offset, usually > 0 to avoid dividing by 0.
  1887. * Defaults to "1".
  1888. * @li alpha: An optional float32. A scaling factor, usually positive.
  1889. * Defaults to "1".
  1890. * @li beta: An optional float32. An exponent. Defaults to "0.5".
  1891. * @par Outputs:
  1892. * z: A Tensor. Has the same type and shape as "grads".
  1893. * @attention Constraints:
  1894. * "x" and "y" must have the same shape and type as "grads".
  1895. */
  1896. REG_OP(LRNGrad)
  1897. .INPUT(grads, TensorType({DT_FLOAT16,DT_FLOAT}))
  1898. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1899. .INPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1900. .OUTPUT(z, TensorType({DT_FLOAT16,DT_FLOAT}))
  1901. .ATTR(depth_radius, Int, 5)
  1902. .ATTR(bias, Float, 1.0)
  1903. .ATTR(alpha, Float, 1.0)
  1904. .ATTR(beta, Float, 0.5)
  1905. .OP_END_FACTORY_REG(LRNGrad)
  1906. REG_OP(LRN)
  1907. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  1908. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  1909. .ATTR(depth_radius, Int, 5)
  1910. .ATTR(bias, Float, 1.0)
  1911. .ATTR(alpha, Float, 1.0)
  1912. .ATTR(beta, Float, 0.5)
  1913. .ATTR(norm_region, String, "ACROSS_CHANNELS")
  1914. .OP_END_FACTORY_REG(LRN)
  1915. } // namespace ge
  1916. #endif // GE_OP_ELEWISE_CALCULATION_OPS_H

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