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.

math_ops.h 50 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546
  1. /**
  2. * Copyright 2019 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*!
  17. * \file math_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_
  22. #include "graph/operator_reg.h"
  23. #include "graph/operator.h"
  24. namespace ge {
  25. /**
  26. *@brief Computes the output as (shift + scale * x) ^ power . \n
  27. *@par Inputs:
  28. * x: A Tensor of type float16 or float32 . \n
  29. *@par Attributes:
  30. *@li power: Optional. Must be one of the following types: float32. Defaults to 1.0.
  31. *@li scale: Optional. Must be one of the following types: float32. Defaults to 1.0.
  32. *@li shift: Optional. Must be one of the following types: float32. Defaults to 0.0 . \n
  33. *@par Outputs:
  34. * y: A Tensor. Has the same type and shape as "x".
  35. *@par Third-party framework compatibility
  36. * Compatible with the Caffe operator Power.
  37. */
  38. REG_OP(Power)
  39. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  40. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  41. .ATTR(power, Float, 1.0)
  42. .ATTR(scale, Float, 1.0)
  43. .ATTR(shift, Float, 0.0)
  44. .OP_END_FACTORY_REG(Power);
  45. /**
  46. *@brief Compute the lower regularized incomplete Gamma function P(a, x) . \n
  47. *@par Inputs:
  48. *The input a and x must have the same type. Inputs include:
  49. *@li a:A Tensor. Must be one of the following types: float, double.
  50. *@li x:A Tensor. Must have the same type as a . \n
  51. *@par Outputs:
  52. *z:A Tensor. Has the same type as a . \n
  53. *@par Third-party framework compatibility.
  54. *Compatible with tensorflow Igamma operator.
  55. */
  56. REG_OP(Igamma)
  57. .INPUT(a, TensorType({DT_FLOAT, DT_DOUBLE}))
  58. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  59. .OUTPUT(z, TensorType({DT_FLOAT, DT_DOUBLE}))
  60. .OP_END_FACTORY_REG(Igamma)
  61. /**
  62. *@brief Compute the upper regularized incomplete Gamma function Q(a, x) . \n
  63. *@par Inputs:
  64. *The input a and x must have the same type. Inputs include:
  65. *@li a:A Tensor. Must be one of the following types: float, float64.
  66. *@li x:A Tensor. Must have the same type as a . \n
  67. *@par Outputs:
  68. *z:A Tensor. Has the same type as a . \n
  69. *@par Third-party framework compatibility.
  70. *Compatible with tensorflow Igammac operator.
  71. */
  72. REG_OP(Igammac)
  73. .INPUT(a, TensorType({DT_FLOAT, DT_DOUBLE}))
  74. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  75. .OUTPUT(z, TensorType({DT_FLOAT, DT_DOUBLE}))
  76. .OP_END_FACTORY_REG(Igammac)
  77. /**
  78. *@brief Compare values of input to threshold and pack resulting bits into
  79. a uint8 . \n
  80. *@par Inputs:
  81. *The input size must be a non-negative int32 scalar Tensor. Inputs include:
  82. *@li input:Values to compare against threshold and bitpack.
  83. *@li threshold:Threshold to compare against . \n
  84. *@par Outputs:
  85. *y:The bitpacked comparisons . \n
  86. *@attention Constraints:
  87. *Currently, the innermost dimension of the tensor must be divisible by 8. \n
  88. *@par Third-party framework compatibility
  89. *Compatible with tensorflow CompareAndBitpack operator
  90. */
  91. REG_OP(CompareAndBitpack)
  92. .INPUT(x, TensorType({ DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT8, \
  93. DT_INT16, DT_INT32, DT_INT64, DT_BOOL }))
  94. .INPUT(threshold, TensorType({ DT_FLOAT, DT_FLOAT16, DT_DOUBLE, \
  95. DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_BOOL }))
  96. .OUTPUT(y, TensorType(DT_UINT8))
  97. .OP_END_FACTORY_REG(CompareAndBitpack)
  98. /**
  99. *@brief Counts the number of occurrences of each value in an integer array.
  100. Outputs a vector with length size and the same dtype as weights. If weights
  101. are empty, then index i stores the number of times the value i is counted in
  102. arr. If weights are non-empty, then index i stores the sum of the value in
  103. weights at each index . \n
  104. *@par Inputs:
  105. *The input size must be a non-negative int32 scalar Tensor. Inputs include:
  106. *@li array:int32 Tensor.
  107. *@li size:non-negative int32 scalar Tensor.
  108. *@li weights: is an int32, int64, float32, or double Tensor with the same
  109. shape as arr, or a length-0 Tensor, in which case it acts as all weights
  110. equal to 1 . \n
  111. *@par Outputs:
  112. *bins:1D Tensor with length equal to size. The counts or summed weights for
  113. each value in the range [0, size) . \n
  114. *@par Third-party framework compatibility
  115. *Compatible with tensorflow Bincount operator
  116. */
  117. REG_OP(Bincount)
  118. .INPUT(array, TensorType(DT_INT32))
  119. .INPUT(size, TensorType(DT_INT32))
  120. .INPUT(weights, TensorType({ DT_FLOAT, DT_INT32, DT_INT64, DT_DOUBLE }))
  121. .OUTPUT(bins, TensorType({ DT_FLOAT, DT_INT32, DT_INT64, DT_DOUBLE }))
  122. .OP_END_FACTORY_REG(Bincount)
  123. /**
  124. *@brief Compute the regularized incomplete beta integral . \n
  125. *@par Inputs:
  126. *The input b and x must have the same types as a. Inputs include:
  127. *@li a:A Tensor. Must be one of the following types: float32, double.
  128. *@li b:A Tensor. Must have the same type as a.
  129. *@li x:A Tensor. Must have the same type as a . \n
  130. *@par Outputs:
  131. *z:A Tensor. Has the same type as a . \n
  132. *@par Third-party framework compatibility.
  133. *Compatible with tensorflow Betainc operator.
  134. */
  135. REG_OP(Betainc)
  136. .INPUT(a, TensorType({DT_DOUBLE, DT_FLOAT}))
  137. .INPUT(b, TensorType({DT_DOUBLE, DT_FLOAT}))
  138. .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT}))
  139. .OUTPUT(z, TensorType({DT_DOUBLE, DT_FLOAT}))
  140. .OP_END_FACTORY_REG(Betainc)
  141. /**
  142. *@brief Compute the Hurwitz zeta function
  143. *@par Inputs:
  144. *The input q must be the same type as x. Inputs include:
  145. *@li x:A Tensor. Must be one of the following types: float32, double.
  146. *@li q:A Tensor. Must have the same type as x . \n
  147. *@par Outputs:
  148. *z:A Tensor. Has the same type as x . \n
  149. *@attention Constraints:
  150. *The implementation for Zeta on Ascend uses ai cpu, with bad performance.
  151. *@par Third-party framework compatibility.
  152. *Compatible with tensorflow Zeta operator.
  153. */
  154. REG_OP(Zeta)
  155. .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT}))
  156. .INPUT(q, TensorType({DT_DOUBLE, DT_FLOAT}))
  157. .OUTPUT(z, TensorType({DT_DOUBLE, DT_FLOAT}))
  158. .OP_END_FACTORY_REG(Zeta)
  159. /**
  160. *@brief Bucketize 'input' based on 'boundaries'. For example, if the inputs
  161. are boundaries = [0, 10, 100] input = [[-5, 10000] [150, 10] [5, 100]] then
  162. the output will be output = [[0, 3] [3, 2] [1, 3]]
  163. *@par Inputs:
  164. *The dtype of input x int float double. Inputs include:
  165. *x:Any shape of Tensor contains with int or float type . \n
  166. *@par Attributes:
  167. *boundaries:A sorted list of floats gives the boundary of the buckets . \n
  168. *@par Outputs:
  169. *y:Same shape with 'input', each value of input replaced with bucket index . \n
  170. *@par Third-party framework compatibility.
  171. *Compatible with tensorflow Bucketize operator.
  172. */
  173. REG_OP(Bucketize)
  174. .INPUT(x, TensorType({DT_INT32, DT_INT64, DT_DOUBLE, DT_FLOAT}))
  175. .OUTPUT(y, TensorType({DT_INT32}))
  176. .REQUIRED_ATTR(boundaries, ListFloat)
  177. .OP_END_FACTORY_REG(Bucketize)
  178. /**
  179. *@brief Returns a new tensor with the truncated integer values of the elements of input. \n
  180. *@par Inputs:
  181. *One inputs, including:
  182. *input_x: A tensor. Must be one of the following types: float16, float32, int8, uint8, int32. \n
  183. *@par Outputs:
  184. * output_y: A tensor with the same type and shape of input_x \n
  185. *@par Third-party framework compatibility
  186. *Compatible with the Pytorch operator Trunc. \n
  187. */
  188. REG_OP(Trunc)
  189. .INPUT(input_x, TensorType({DT_FLOAT16,DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8}))
  190. .OUTPUT(output_y, TensorType({DT_FLOAT16,DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8}))
  191. .OP_END_FACTORY_REG(Trunc)
  192. /**
  193. *@brief Computes the sum along sparse segments of a tensor . \n
  194. *@par Inputs:
  195. *The input indices and segment_ids must have same rank. Inputs include:
  196. *@li x:A Tensor. Must be one of the following types: float, double, int32,
  197. uint8, int16, int8, int64, uint16, uint32, uint64.
  198. *@li indices: A Tensor. Must be one of the following types: int32, int64.
  199. A 1-D tensor. Has same rank as segment_ids.
  200. *@li segment_ids: A Tensor of type int32. A 1-D tensor. Values should be
  201. sorted and can be repeated . \n
  202. *@par Outputs:
  203. *y:A Tensor. Has the same type as x . \n
  204. *@par Third-party framework compatibility
  205. *Compatible with tensorflow SparseSegmentSum operator
  206. */
  207. REG_OP(SparseSegmentSum)
  208. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  209. DT_INT32, DT_UINT32, DT_INT64, DT_UINT64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16}))
  210. .INPUT(indices, TensorType({DT_INT32, DT_INT64}))
  211. .INPUT(segment_ids, TensorType({DT_INT32, DT_INT64}))
  212. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  213. DT_INT32, DT_UINT32, DT_INT64, DT_UINT64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16}))
  214. .OP_END_FACTORY_REG(SparseSegmentSum)
  215. /**
  216. *@brief Computes the mean along sparse segments of a tensor . \n
  217. *@par Inputs:
  218. *The input indices and segment_ids must have same rank. Inputs include:
  219. *@li x: A Tensor. Must be one of the following types: float, double.
  220. *@li indices: A Tensor. Must be one of the following types: int32, int64.
  221. A 1-D tensor. Has same rank as segment_ids.
  222. *@li segment_ids: A Tensor of type int32. A 1-D tensor. Values should be
  223. sorted and can be repeated . \n
  224. *@par Outputs:
  225. *y:A Tensor. Has the same type as x . \n
  226. *@par Third-party framework compatibility
  227. *Compatible with tensorflow SparseSegmentMean operator
  228. */
  229. REG_OP(SparseSegmentMean)
  230. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE, DT_FLOAT16}))
  231. .INPUT(indices, TensorType({DT_INT32, DT_INT64}))
  232. .INPUT(segment_ids, TensorType({DT_INT32, DT_INT64}))
  233. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE, DT_FLOAT16}))
  234. .OP_END_FACTORY_REG(SparseSegmentMean)
  235. /**
  236. *@brief Computes gradients for SparseSegmentMean . \n
  237. *@par Inputs:
  238. *The input grad must have be type float or double. Inputs include:
  239. *@li x: A Tensor. Must be one of the following types: float, double.
  240. gradient propagated to the SparseSegmentMean op.
  241. *@li indices: A Tensor. Must be one of the following types: int32, int64.
  242. indices passed to the corresponding SparseSegmentMean op.
  243. *@li segment_ids: A Tensor of type int32. segment_ids passed to the
  244. corresponding SparseSegmentMean op.
  245. *@li output_dim0: A Tensor of type int32. dimension 0 of "x" passed to
  246. SparseSegmentMean op . \n
  247. *@par Outputs:
  248. *y:A Tensor. Has the same type as grad . \n
  249. *@par Third-party framework compatibility
  250. *Compatible with tensorflow SparseSegmentMeanGrad operator
  251. */
  252. REG_OP(SparseSegmentMeanGrad)
  253. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE, DT_FLOAT16}))
  254. .INPUT(indices, TensorType({DT_INT32, DT_INT64}))
  255. .INPUT(segment_ids, TensorType({DT_INT32, DT_INT64}))
  256. .INPUT(output_dim0, TensorType({DT_INT32}))
  257. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE, DT_FLOAT16}))
  258. .OP_END_FACTORY_REG(SparseSegmentMeanGrad)
  259. /**
  260. *@brief Computes the gradient of igamma(a, x) wrt a
  261. *@par Inputs:
  262. *The input a and x must have the same type. Inputs include:
  263. *@li a:A Tensor. Must be one of the following types: float32, double.
  264. *@li x:A Tensor. Must have the same type as a . \n
  265. *@par Outputs:
  266. *y:A Tensor. Has the same type as a . \n
  267. *@par Third-party framework compatibility
  268. *Compatible with tensorflow IgammaGradA operator
  269. */
  270. REG_OP(IgammaGradA)
  271. .INPUT(a, TensorType({DT_FLOAT, DT_DOUBLE}))
  272. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  273. .OUTPUT(z, TensorType({DT_FLOAT, DT_DOUBLE}))
  274. .OP_END_FACTORY_REG(IgammaGradA)
  275. /**
  276. *@brief Initialize data process channel . \n
  277. *@par Attributes:
  278. *channel_name: A string. Default "" . \n
  279. *@par Third-party framework compatibility
  280. *Compatible with tensorflow InitData operator
  281. */
  282. REG_OP(InitData)
  283. .ATTR(channel_name, String, "")
  284. .OP_END_FACTORY_REG(InitData)
  285. /**
  286. *@brief Get the next batch of data in data processing . \n
  287. *@par Attributes:
  288. *@li output_types: A nested structure of DType objects corresponding to each
  289. component of an element of this dataset.
  290. *@li output_shapes: A nested structure of TensorShape objects corresponding
  291. to each component of an element of this dataset.
  292. *@li output_num:output of nums.
  293. *@li channel_name: A string. Default "" . \n
  294. *@par Outputs:
  295. *y:A nested structure of Tensor objects . \n
  296. *@par Third-party framework compatibility
  297. *Compatible with tensorflow GetNext operator
  298. */
  299. REG_OP(GetNext)
  300. .DYNAMIC_OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64,
  301. DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_BOOL}))
  302. .ATTR(output_types, ListType, {})
  303. .ATTR(output_shapes, ListListInt, {})
  304. .ATTR(output_num, Int, 1)
  305. .ATTR(channel_name, String, "")
  306. .OP_END_FACTORY_REG(GetNext)
  307. /**
  308. *@brief Get dynamic dims after GetNext. \n
  309. *@par Inputs:
  310. *input: A nested structure of Tensor objects, from GetNext's output. \n
  311. *@par Attributes:
  312. *@li shape_info: GE shape_info for each inputs, -1 means unknow dim.
  313. *@li N: Inputs number. \n
  314. *@par Outputs:
  315. *dims: GE unknow dims, a vector of int64. \n
  316. */
  317. REG_OP(GetDynamicDims)
  318. .DYNAMIC_INPUT(input, TensorType({DT_INT32, DT_INT64}))
  319. .OUTPUT(dims, TensorType({DT_INT32, DT_INT64}))
  320. .REQUIRED_ATTR(shape_info, ListInt)
  321. .REQUIRED_ATTR(N, Int)
  322. .OP_END_FACTORY_REG(GetDynamicDims)
  323. /**
  324. *@brief End of sequence . \n
  325. *@par Inputs:
  326. *x: A Tensor of type uint8 . \n
  327. *@par Outputs:
  328. *y: A Tensor. Has the same type as "x".
  329. */
  330. REG_OP(EndOfSequence)
  331. .INPUT(x, TensorType({DT_UINT8}))
  332. .OUTPUT(y, TensorType({DT_UINT8}))
  333. .OP_END_FACTORY_REG(EndOfSequence)
  334. /**
  335. *@brief: Computes the Gauss error function of `x` element-wise . \n
  336. *@par Inputs:
  337. *x: A Tensor of type float16, float32 or double. the format can be
  338. * [NCHW,NHWC,ND]
  339. *@par Outputs:
  340. *y: A Tensor. Has the same type and format as "x" . \n
  341. *@par Third-party framework compatibility
  342. * Compatible with the TensorFlow operator Erf.
  343. */
  344. REG_OP(Erf)
  345. .INPUT(x, TensorType::FloatingDataType())
  346. .OUTPUT(y, TensorType::FloatingDataType())
  347. .OP_END_FACTORY_REG(Erf)
  348. /**
  349. *@brief: Computes the Gauss complementary error function of "x" element-wise . \n
  350. *@par Inputs:
  351. *x: A Tensor of type float16 ,float32, double . \n
  352. *@par Outputs:
  353. *y: A Tensor. Has the same type as "x" . \n
  354. *@par Third-party framework compatibility
  355. * Compatible with the TensorFlow operator Erfc.
  356. */
  357. REG_OP(Erfc)
  358. .INPUT(x, TensorType::FloatingDataType())
  359. .OUTPUT(y, TensorType::FloatingDataType())
  360. .OP_END_FACTORY_REG(Erfc)
  361. /**
  362. *@brief This operation returns a rank 1 histogram counting the number of entries in `values`
  363. * that fell into every bin.The bins are equal width and determined by the arguments
  364. * 'value_range' and 'nbins' . \n
  365. *@par Inputs:
  366. *Three inputs, including:
  367. *@li x: A Tensor of type float32, int32, int64. float16 is currently not supported.
  368. *@li range: A Tensor of type float32, int32, int64. float16 is currently not supported.
  369. *@li nbins: A Tensor of type int32 . \n
  370. *@par Attributes:
  371. * dtype: An optional attribute. Defaults to "int32" . \n
  372. *@par Outputs:
  373. *y: A Tensor. A Tensor of type int32. \n
  374. *@par Third-party framework compatibility
  375. * Compatible with TensorFlow operator HistogramFixedWidth.
  376. */
  377. REG_OP(HistogramFixedWidth)
  378. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  379. .INPUT(range, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  380. .INPUT(nbins, TensorType({DT_INT32}))
  381. .OUTPUT(y, TensorType({DT_INT32}))
  382. .ATTR(dtype, Int, 3)
  383. .OP_END_FACTORY_REG(HistogramFixedWidth)
  384. /**
  385. *@brief This operation returns a rank 1 histogram counting the number of entries in `values`
  386. * that fell into every bin.The bins are equal width and determined by the arguments
  387. * 'value_range' and 'nbins' . \n
  388. *@par Inputs:
  389. *Two inputs, including:
  390. *@li x: A Tensor of type float32,float16,int32, int64.
  391. *@li range: A Tensor of type float32,float16,int32, int64 . \n
  392. *@par Attributes:
  393. *@li dtype: An optional attribute. Defaults to "int32".
  394. *@li nbins: A required attribute,the type is int32 . \n
  395. *@par Outputs:
  396. *y: A Tensor. A Tensor of type int32 . \n
  397. *@par Third-party framework compatibility
  398. * Compatible with TensorFlow operator HistogramFixedWidth.
  399. *
  400. * @par Restrictions:
  401. * Warning: THIS FUNCTION IS DEPRECATED. Please use HistogramFixedWidth instead.
  402. */
  403. REG_OP(HistogramFixedWidthD)
  404. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  405. .INPUT(range, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  406. .OUTPUT(y, TensorType({DT_INT32}))
  407. .REQUIRED_ATTR(nbins, Int)
  408. .ATTR(dtype, Int, 3)
  409. .OP_END_FACTORY_REG(HistogramFixedWidthD)
  410. /**
  411. *@brief Returns the next representable value of x1 in the direction of x2, element-wise . \n
  412. *@par Inputs:
  413. *The input X1 and x2 must have the same type. Inputs include:
  414. *@li x1:A Tensor. Must be one of the following types: float32, double.
  415. *@li x2:A Tensor. Must have the same type as x1 . \n
  416. *@par Outputs:
  417. *output:A Tensor. Has the same type as x1 . \n
  418. *@par Third-party framework compatibility
  419. *Compatible with tensorflow NextAfter operator
  420. */
  421. REG_OP(NextAfter)
  422. .INPUT(x1, TensorType({DT_FLOAT, DT_DOUBLE}))
  423. .INPUT(x2, TensorType({DT_FLOAT, DT_DOUBLE}))
  424. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  425. .OP_END_FACTORY_REG(NextAfter)
  426. /**
  427. *@brief Calculate the P-norm distance between vectors function. \n
  428. *@par Inputs:
  429. *One inputs, including:
  430. * input_x: A tensor. Must be one of the following types:
  431. * float16, float32. \n
  432. *@par Attributes:
  433. *p: An optional float.Defaults to 2. \n
  434. *@par Outputs:
  435. *y: A Tensor with the same type and shape of input_x's. \n
  436. *@par Third-party framework compatibility
  437. *Compatible with the Pytorch operator Pdist. \n
  438. */
  439. REG_OP(Pdist)
  440. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  441. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  442. .ATTR(p, Float, 2.0)
  443. .OP_END_FACTORY_REG(Pdist)
  444. /**
  445. *@brief Compute element-wise finiteness, return a boolean tensor.
  446. *@par Inputs:
  447. *x:A Tensor of type float16, float32, double.
  448. *@par Outputs:
  449. *y:A Tensor. Returns which elements of x are finite
  450. *@par Third-party framework compatibility.
  451. *Compatible with tensorflow IsFinite operator.
  452. */
  453. REG_OP(IsFinite)
  454. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  455. .OUTPUT(y, TensorType({DT_BOOL}))
  456. .OP_END_FACTORY_REG(IsFinite)
  457. /**
  458. *@brief Compute element-wise infiniteness, return a boolean tensor.
  459. *@par Inputs:
  460. *x:A Tensor of type float16, float32, double.
  461. *@par Outputs:
  462. *y:A Tensor. Has the same shape as x. Returns which elements of x are isinf.
  463. *@par Third-party framework compatibility.
  464. *Compatible with tensorflow IsInf operator.
  465. */
  466. REG_OP(IsInf)
  467. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  468. .OUTPUT(y, TensorType({DT_BOOL}))
  469. .OP_END_FACTORY_REG(IsInf)
  470. /**
  471. *@brief Computes the complex absolute value of a tensor.
  472. *@par Inputs:
  473. *x: x of complex numbers, this operation returns a tensor of type
  474. float or double that is the absolute value of each element in x .
  475. * @par Attributes:
  476. * Tout: representing the output of type.
  477. *@par Outputs:
  478. *y:A tensor of type `float` or `double` that is the absolute value of each element in `x`.
  479. *@par Third-party framework compatibility.
  480. *Compatible with tensorflow ComplexAbs operator.
  481. */
  482. REG_OP(ComplexAbs)
  483. .INPUT(x, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  484. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  485. .ATTR(Tout, Type, DT_FLOAT)
  486. .OP_END_FACTORY_REG(ComplexAbs)
  487. /**
  488. *@brief Returns which elements of x are NaN.
  489. *@par Inputs:
  490. *x:A Tensor of type float16, float32, double.
  491. *@par Outputs:
  492. *y:A Tensor. Has the same shape as x. Returns which elements of x are isnan
  493. *@par Third-party framework compatibility.
  494. *Compatible with tensorflow IsNan operator.
  495. */
  496. REG_OP(IsNan)
  497. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  498. .OUTPUT(y, TensorType({DT_BOOL}))
  499. .OP_END_FACTORY_REG(IsNan)
  500. /**
  501. *@brief Returns the real part of a complex number.
  502. *@par Inputs:
  503. *input:A Tensor. Must have numeric type.
  504. *@par Attributes:
  505. *Tout: Type of outputs. \n
  506. *@par Outputs:
  507. *output:A Tensor. Has the same shape as input.
  508. *@par Third-party framework compatibility.
  509. *Compatible with tensorflow Real operator.
  510. */
  511. REG_OP(Real)
  512. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  513. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  514. .ATTR(Tout, Type, DT_FLOAT)
  515. .OP_END_FACTORY_REG(Real)
  516. /**
  517. *@brief Returns the complex conjugate of a complex number.
  518. *@par Inputs:
  519. *input:A Tensor.
  520. *@par Outputs:
  521. *output:A Tensor. Has the same shape as input.
  522. *@par Third-party framework compatibility.
  523. *Compatible with tensorflow output operator.
  524. */
  525. REG_OP(Conj)
  526. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  527. .OUTPUT(output, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  528. .OP_END_FACTORY_REG(Conj)
  529. /**
  530. *@brief The negative log likelihood loss . \n
  531. *@par Inputs:
  532. *The input x and weight must have the same type. Inputs include:
  533. *@li x: A Tensor dtype of float32.
  534. *@li target: A Tensor dtype of int32 or int64.
  535. *@li weight: A Tensor dtype of float32 . \n
  536. *@par Attributes:
  537. *@li reduction: An optional attribute. Defaults to "mean" .
  538. *@li ignore_index:An optional attribute.Defaults to -100 . \n
  539. *@par Outputs:
  540. *@li y: A Tensor dtype of float32.
  541. *@li total_weight: A Tensor dtype of float32 . \n
  542. *@par Third-party framework compatibility
  543. *Compatible with pytorch NLLLoss operator
  544. */
  545. REG_OP(NLLLoss)
  546. .INPUT(x, TensorType({DT_FLOAT}))
  547. .INPUT(target, TensorType({DT_INT32, DT_INT64}))
  548. .OPTIONAL_INPUT(weight, TensorType({DT_FLOAT}))
  549. .OUTPUT(y, TensorType({DT_FLOAT}))
  550. .OUTPUT(total_weight, TensorType({DT_FLOAT}))
  551. .ATTR(reduction, String, "mean")
  552. .ATTR(ignore_index, Int, -100)
  553. .OP_END_FACTORY_REG(NLLLoss)
  554. /**
  555. *@brief The negative log likelihood loss grad . \n
  556. *@par Inputs:
  557. *@li x:A Tensor dtype of float32.
  558. *@li y_grad:A Tensor dtype of float32.
  559. *@li target:A Tensor dtype of int32, int64.
  560. *@li weight:A Tensor dtype of float32.
  561. *@li total_weight:A Tensor dtype of float32 . \n
  562. *@par Attributes:
  563. *@li reduction: An optional attribute. Defaults to "mean" .
  564. *@li ignore_index:An optional attribute.Defaults to -100 . \n
  565. *@par Outputs:
  566. *x_grad: A Tensor. Must be the following type: float32 . \n
  567. *@par Third-party framework compatibility
  568. *Compatible with pytorch NLLLossGrad operator
  569. */
  570. REG_OP(NLLLossGrad)
  571. .INPUT(x, TensorType({DT_FLOAT}))
  572. .INPUT(y_grad, TensorType({DT_FLOAT}))
  573. .INPUT(target, TensorType({DT_INT32, DT_INT64}))
  574. .INPUT(weight, TensorType({DT_FLOAT}))
  575. .INPUT(total_weight, TensorType({DT_FLOAT}))
  576. .OUTPUT(x_grad, TensorType({DT_FLOAT}))
  577. .ATTR(reduction, String, "mean")
  578. .ATTR(ignore_index, Int, -100)
  579. .OP_END_FACTORY_REG(NLLLossGrad)
  580. /**
  581. *@brief IFMR(Input Feature Map Reconstruction). \n
  582. *@par Inputs:
  583. *@li data: A Tensor of feature map.
  584. *@li data_min: A Tensor of min value of feature map.
  585. *@li data_max: A Tensor of max value of feature map.
  586. *@li cumsum: A Tensor of cumsum bin of data . \n
  587. *@par Attributes:
  588. *@li min_percentile: min init percentile.
  589. *@li max_percentile: max init percentile.
  590. *@li search_range: search range.
  591. *@li search_step: step size of searching.
  592. *@li with_offset: whether using offset . \n
  593. *@par Outputs:
  594. *@li scale: optimal scale.
  595. *@li offset: optimal offset . \n
  596. *@par Third-party framework compatibility
  597. *Compatible with mindspore
  598. */
  599. REG_OP(IFMR)
  600. .INPUT(data, TensorType({DT_FLOAT16, DT_FLOAT}))
  601. .INPUT(data_min, TensorType({DT_FLOAT16, DT_FLOAT}))
  602. .INPUT(data_max, TensorType({DT_FLOAT16, DT_FLOAT}))
  603. .INPUT(cumsum, TensorType({DT_INT32}))
  604. .OUTPUT(scale, TensorType({DT_FLOAT}))
  605. .OUTPUT(offset, TensorType({DT_FLOAT}))
  606. .REQUIRED_ATTR(min_percentile, Float)
  607. .REQUIRED_ATTR(max_percentile, Float)
  608. .REQUIRED_ATTR(search_range, ListFloat)
  609. .REQUIRED_ATTR(search_step, Float)
  610. .REQUIRED_ATTR(with_offset, Bool)
  611. .OP_END_FACTORY_REG(IFMR)
  612. /**
  613. *@brief Weights Adaptive Range Quantization. \n
  614. *@par Inputs:
  615. *@li w: A Tensor of weights. \n
  616. *@li w_min: A Tensor of weights reduce_min. \n
  617. *@li w_max: A Tensor of weights reduce_max. \n
  618. *@par Attributes:
  619. *@li num_bits: the bits num used for quantize.
  620. *@li offset_flag: whether using offset. \n
  621. *@par Outputs:
  622. *y: fake quantized weights. \n
  623. *@par Third-party framework compatibility
  624. *Compatible with mindspore
  625. *@par Restrictions:
  626. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  627. */
  628. REG_OP(WtsARQ)
  629. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  630. .INPUT(w_min, TensorType({DT_FLOAT16, DT_FLOAT}))
  631. .INPUT(w_max, TensorType({DT_FLOAT16, DT_FLOAT}))
  632. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  633. .ATTR(num_bits, Int, 8)
  634. .ATTR(offset_flag, Bool, false)
  635. .OP_END_FACTORY_REG(WtsARQ)
  636. /**
  637. *@brief Activations Universal Linear Quantization. \n
  638. *@par Inputs:
  639. *@li x: A Tensor of feature map.
  640. *@li clamp _min: A Tensor of min clamp value of feature map.
  641. *@li clamp _max: A Tensor of max clamp value of feature map.
  642. *@par Attributes:
  643. *@li fixed_min: fix min to zero.
  644. *@li num_bits: quant bits. \n
  645. *@par Outputs:
  646. *@li y: output fake quant feature map.
  647. *@li clamp_min_mask: where x > clamp_min.
  648. *@li clamp_min_mask: where x < clamp_max.
  649. *@li x_clamped_loss: clamp loss. \n
  650. *@par Third-party framework compatibility
  651. *Compatible with mindspore
  652. *@par Restrictions:
  653. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  654. */
  655. REG_OP(ActsULQ)
  656. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  657. .INPUT(clamp_min, TensorType({DT_FLOAT16, DT_FLOAT}))
  658. .INPUT(clamp_max, TensorType({DT_FLOAT16, DT_FLOAT}))
  659. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  660. .OUTPUT(clamp_min_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  661. .OUTPUT(clamp_max_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  662. .OUTPUT(x_clamped_loss, TensorType({DT_FLOAT16, DT_FLOAT}))
  663. .ATTR(fixed_min, Bool, false)
  664. .ATTR(num_bits, Int, 8)
  665. .OP_END_FACTORY_REG(ActsULQ)
  666. /**
  667. *@brief The gradient of Activations Universal Linear Quantization. \n
  668. *@par Inputs:
  669. *@li y_grad: A Tensor of gradient.
  670. *@li clamp_min_mask: A Tensor of boolean mask indicating whether an additional one is needed'.
  671. *@li clamp_max_mask: A Tensor of boolean mask indicating whether an additional one is needed'.
  672. *@par Outputs:
  673. *x_grapd: The gradient of inpust. \n
  674. *@par Third-party framework compatibility
  675. *Compatible with mindspore
  676. *@par Restrictions:
  677. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  678. */
  679. REG_OP(ActsULQInputGrad)
  680. .INPUT(y_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  681. .INPUT(clamp_min_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  682. .INPUT(clamp_max_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  683. .OUTPUT(x_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  684. .OP_END_FACTORY_REG(ActsULQInputGrad)
  685. /**
  686. *@brief The gradient of Activations Universal Linear Quantization clamp max. \n
  687. *@par Inputs:
  688. *@li y_grad: A Tensor of gradient.
  689. *@li clamp_max_mask: A Tensor of boolean mask indicating whether an additional one is needed.
  690. *@li x_clamped_loss: A Tensor of gradient. \n
  691. *@par Outputs:
  692. *clamp_max_grad: The gradient of clamp max. \n
  693. *@par Third-party framework compatibility
  694. *Compatible with mindspore
  695. *@par Restrictions:
  696. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  697. */
  698. REG_OP(ActULQClampMaxGrad)
  699. .INPUT(y_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  700. .INPUT(clamp_max_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  701. .INPUT(x_clamped_loss, TensorType({DT_FLOAT16, DT_FLOAT}))
  702. .OUTPUT(clamp_max_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  703. .OP_END_FACTORY_REG(ActULQClampMaxGrad)
  704. /**
  705. *@brief The gradient of Activations Universal Linear Quantization clamp min. \n
  706. *@par Inputs:
  707. *@li y_grad: A Tensor of gradient.
  708. *@li clamp_min_mask: A Tensor of boolean mask indicating whether an additional one is needed.
  709. *@li x_clamped_loss: A Tensor of gradient. \n
  710. *@par Outputs:
  711. *clamp_min_grad: The gradient of clamp min. \n
  712. *@par Third-party framework compatibility
  713. *Compatible with mindspore
  714. *@par Restrictions:
  715. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  716. */
  717. REG_OP(ActULQClampMinGrad)
  718. .INPUT(y_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  719. .INPUT(clamp_min_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  720. .INPUT(x_clamped_loss, TensorType({DT_FLOAT16, DT_FLOAT}))
  721. .OUTPUT(clamp_min_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  722. .OP_END_FACTORY_REG(ActULQClampMinGrad)
  723. /**
  724. * @brief Computes Lp norm.
  725. * @par Inputs:
  726. * x: An ND tensor of type float16, float32. \n
  727. *
  728. * @par Attributes:
  729. * @li p: Int, "inf" or "-inf", default value is 2.
  730. * @li axes: ListInt, {} means all axes will be computed.
  731. * @li keepdim: Bool, default is false.
  732. * @li epsilon: Float, default is 1e-12. \n
  733. * @par Outputs:
  734. * y: An ND tensor of type float16, float32. The shape of y is depending
  735. * on axes and keepdim. \n
  736. * @par Third-party framework compatibility
  737. * Compatible with the Pytorch operator LpNorm.
  738. */
  739. REG_OP(LpNorm)
  740. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  741. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  742. .ATTR(p, Int, 2)
  743. .ATTR(axes, ListInt, {})
  744. .ATTR(keepdim, Bool, false)
  745. .ATTR(epsilon, Float, 1e-12)
  746. .OP_END_FACTORY_REG(LpNorm)
  747. /**
  748. * @brief Computes LpNormReduce.
  749. * @par Inputs:
  750. * x: An ND tensor of type float16, float32. \n
  751. *
  752. * @par Attributes:
  753. * @li p: Int, "inf" or "-inf", default value is 2.
  754. * @li axes: ListInt, {} means all axes will be computed.
  755. * @li keepdim: Bool, default is false.
  756. * @li epsilon: Float, default is 1e-12. \n
  757. * @par Outputs:
  758. * y: An ND tensor of type float16, float32. The shape of y is depending
  759. * on axes and keepdim. \n
  760. * @par Third-party framework compatibility
  761. * Compatible with the Pytorch operator LpNormReduce.
  762. */
  763. REG_OP(LpNormReduce)
  764. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  765. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  766. .ATTR(p, Int, 2)
  767. .ATTR(axes, ListInt, {})
  768. .ATTR(keepdim, Bool, false)
  769. .ATTR(epsilon, Float, 1e-12)
  770. .OP_END_FACTORY_REG(LpNormReduce)
  771. /**
  772. * @brief Computes LpNormUpdate.
  773. * @par Inputs:
  774. * x: An ND tensor of type float16, float32. \n
  775. *
  776. * @par Attributes:
  777. * @li p: Int, "inf" or "-inf", default value is 2.
  778. * @li epsilon: Float, default is 1e-12. \n
  779. * @par Outputs:
  780. * y: An ND tensor of type float16, float32. \n
  781. * @par Third-party framework compatibility
  782. * Compatible with the Pytorch operator LpNormUpdate.
  783. */
  784. REG_OP(LpNormUpdate)
  785. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  786. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  787. .ATTR(p, Int, 2)
  788. .ATTR(epsilon, Float, 1e-12)
  789. .OP_END_FACTORY_REG(LpNormUpdate)
  790. /**
  791. * @brief get complex.
  792. * @par Inputs:
  793. * @li real: An ND tensor of type float32 double, representing the real part of a complex number.
  794. * @li imag: An ND tensor of type float32 double, representing the imaginary part of a complex number. \n
  795. *
  796. * @par Attributes:
  797. * Tout: representing the output of type.
  798. * @par Outputs:
  799. * out: An ND tensor of type complex64, complex128 \n
  800. */
  801. REG_OP(Complex)
  802. .INPUT(real, TensorType({DT_FLOAT, DT_DOUBLE}))
  803. .INPUT(imag, TensorType({DT_FLOAT, DT_DOUBLE}))
  804. .OUTPUT(out, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  805. .ATTR(Tout, Type, DT_COMPLEX64)
  806. .OP_END_FACTORY_REG(Complex)
  807. /**
  808. * @brief Counts the number of occurrences of each value in an integer array . \n
  809. * @par Inputs:
  810. * Five inputs, including:
  811. * indices: A 2D Tensor of type int64.
  812. * values: A 1D Tensor of type int32 or int64.
  813. * dense_shape: A 1D Tensor of type int64.
  814. * size: A non-negative scalar Tensor.
  815. * weights: A Tensor of type int32 or int64 or fp32 or fp64 or only 1 \n
  816. * @par Attributes:
  817. * dtype: An optional bool.Defaults to False. bool . \n
  818. * @par Outputs:
  819. * y: A Tensor . Has the same type as `input_weights` .\n
  820. * @par Third-party framework compatibility
  821. * Compatible with the TensorFlow operator SparseBincount.
  822. */
  823. REG_OP(SparseBincount)
  824. .INPUT(indices, TensorType({DT_INT64}))
  825. .INPUT(values, TensorType({DT_INT32, DT_INT64}))
  826. .INPUT(dense_shape, TensorType({DT_INT64}))
  827. .INPUT(size, TensorType({DT_INT32, DT_INT64}))
  828. .INPUT(weights, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE}))
  829. .ATTR(binary_output, Bool, false)
  830. .OUTPUT(output, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE}))
  831. .OP_END_FACTORY_REG(SparseBincount)
  832. /**
  833. * @brief deal complex.
  834. * @par Inputs:
  835. * input: An ND tensor of type complex64, complex128 \n
  836. * @par Attributes:
  837. * Tout: representing the output of type.
  838. * @par Outputs:
  839. * output: An ND tensor of type float32. double \n
  840. */
  841. REG_OP(Imag)
  842. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  843. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  844. .ATTR(Tout, Type, DT_FLOAT)
  845. .OP_END_FACTORY_REG(Imag)
  846. /**
  847. * @brief deal complex.
  848. * @par Inputs:
  849. * @li input: An ND tensor of type complex64, complex128 \n
  850. *
  851. * @par Outputs:
  852. * @li output: An ND tensor of type float32. double \n
  853. */
  854. REG_OP(Angle)
  855. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  856. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  857. .ATTR(Tout, Type, DT_FLOAT)
  858. .OP_END_FACTORY_REG(Angle)
  859. /**
  860. *@brief Computes the gradient of SoftMarginLossGrad. \n
  861. *@par Inputs:
  862. *Three inputs, including:
  863. * @li predict: A tensor. Must be one of the following types:
  864. * float16, float32. \n
  865. * @li label: A tensor with same shape of predict. Must be one of the following types:
  866. * float16, float32. \n
  867. * @li dout: A tensor with same shpae of predcit. Must be one of the following types:
  868. * float16, float32. \n
  869. *@par Attributes:
  870. * reduction: Specifies the reduction to apply to the output:
  871. * 'none' | 'mean' | 'sum'. Default: 'mean'. \n
  872. *@par Outputs:
  873. * gradient: A Tensor with the same type of predict. \n
  874. *@par Third-party framework compatibility
  875. *Compatible with the Pytorch operator SoftMarginLoss Backward. \n
  876. */
  877. REG_OP(SoftMarginLossGrad)
  878. .INPUT(predict, TensorType({DT_FLOAT16,DT_FLOAT}))
  879. .INPUT(label, TensorType({DT_FLOAT16,DT_FLOAT}))
  880. .INPUT(dout, TensorType({DT_FLOAT16,DT_FLOAT}))
  881. .OUTPUT(gradient, TensorType({DT_FLOAT16,DT_FLOAT}))
  882. .ATTR(reduction, String, "mean")
  883. .OP_END_FACTORY_REG(SoftMarginLossGrad)
  884. /**
  885. *@brief Calculate the cross product of two tensors. \n
  886. *@par Inputs:
  887. *One inputs, including:
  888. * @li x1: A tensor. Must be one of the following types:
  889. * float16, float32, int32, int8, uint8, int16. \n
  890. * @li x2: A tensor. Must be one of the following types:
  891. * float16, float32, int32, int8, uint8, int16. \n
  892. *@par Attributes:
  893. *@li dim: the dimination of compute.Defaults to -65530. \n
  894. *@par Outputs:
  895. *y: A Tensor with the same type and shape of x1's. \n
  896. *@par Third-party framework compatibility
  897. *Compatible with the Pytorch operator cross. \n
  898. */
  899. REG_OP(Cross)
  900. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  901. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  902. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  903. .ATTR(dim, Int, -65530)
  904. .OP_END_FACTORY_REG(Cross)
  905. /**
  906. * @brief Computes batched the p-norm distance between each pair of
  907. *the two collections of row vectors. \n
  908. *@par Inputs:
  909. *Two inputs, including:
  910. * @li x1: A tensor with shpae: BxPXM. Must be one of the following types:
  911. * float16, float32. \n
  912. * @li x2: A tensor with shpae: BxRxM. Must be one of the following types:
  913. * float16, float32. \n
  914. *@par Attributes:
  915. * @li p: An optional float >= 0 or inf. Defaults to 2.0. \n
  916. *@par Outputs:
  917. * y: A Tensor with the same type of x1's and with shape BxPxR. \n
  918. *@par Third-party framework compatibility
  919. *Compatible with the Pytorch operator Cdist. \n
  920. */
  921. REG_OP(Cdist)
  922. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT}))
  923. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT}))
  924. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  925. .ATTR(p, Float, 2.0)
  926. .OP_END_FACTORY_REG(Cdist)
  927. /**
  928. *@brief Computes the grad of x1 in cdist. \n
  929. *@par Inputs:
  930. *Four inputs, including:
  931. * @li grad: Grad with shape BxPxR. Must be one of the following types:
  932. * float16, float32. \n
  933. * @li x1: A tensor with shpae: BxPXM. Must be one of the following types:
  934. * float16, float32. \n
  935. * @li x2: A tensor with shpae: BxRxM. Must be one of the following types:
  936. * float16, float32. \n
  937. * @li cdist: Output tensor of cdist forward with shpae: BxPXR.
  938. * Must be one of the following types: float16, float32. \n
  939. *@par Attributes:
  940. * @li p: An optional float >= 0 or inf. Defaults to 2.0. \n
  941. *@par Outputs:
  942. * y: A Tensor with the same type and shape of x1's. \n
  943. *@par Third-party framework compatibility
  944. *Compatible with the Pytorch operator Cdist Backward. \n
  945. */
  946. REG_OP(CdistGrad)
  947. .INPUT(grad, TensorType({DT_FLOAT16,DT_FLOAT}))
  948. .INPUT(x1, TensorType({DT_FLOAT16,DT_FLOAT}))
  949. .INPUT(x2, TensorType({DT_FLOAT16,DT_FLOAT}))
  950. .INPUT(cdist, TensorType({DT_FLOAT16,DT_FLOAT}))
  951. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  952. .ATTR(p, Float, 2.0)
  953. .OP_END_FACTORY_REG(CdistGrad)
  954. /**
  955. * @brief Computes the RaggedBincount. \n
  956. * @par Inputs:
  957. * Four inputs, including:
  958. * @li splits: A tensor with shpae: BxPXM. Must be one of the following types:
  959. * int64.
  960. * @li values: A tensor with shpae: BxPXM. Must be one of the following types:
  961. * float16, float32.
  962. * @li size: A tensor with shpae: BxRxM. Must be one of the following types:
  963. * int32, int64.
  964. * @li weights: A tensor with shpae: BxRxM.
  965. * Must be one of the following types: int32, int64, float, double. \n
  966. * @par Attributes:
  967. * @li binary_output: An optional bool \n
  968. * @par Outputs:
  969. * output: Must be one of the following types: int32, int64, float, double. \n
  970. */
  971. REG_OP(RaggedBincount)
  972. .INPUT(splits, TensorType({DT_INT64}))
  973. .INPUT(values, TensorType({DT_INT32, DT_INT64}))
  974. .INPUT(size, TensorType({DT_INT32, DT_INT64}))
  975. .INPUT(weights, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE}))
  976. .OUTPUT(output, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE}))
  977. .ATTR(binary_output, Bool, false)
  978. .OP_END_FACTORY_REG(RaggedBincount)
  979. /**
  980. * @brief Count the number of occurrences of each value in the input dense integer array,
  981. * and output it according to the sparse matrix. \n
  982. * @par Inputs:
  983. * @li values: A 1D or 2D tensor of type int32 or int64.
  984. * @li weights: A tensor of type int32 or int64 or float or double. \n
  985. * @par Attributes:
  986. * @li minlength: An optional int >=-1. Defaults to -1.
  987. * @li maxlength: An optional int >=-1. Defaults to -1.
  988. * @li binary_output: A required bool. \n
  989. * @par Outputs:
  990. * output_indices: A tensor of type int64.
  991. * output_values: A tensor of the same type as "weights".
  992. * output_dense_shape: A tensor of type int64. \n
  993. * @par Third-party framework compatibility
  994. * Compatible with the TensorFlow operator DenseCountSparseOutput. \n
  995. */
  996. REG_OP(DenseCountSparseOutput)
  997. .INPUT(values, TensorType({DT_INT32,DT_INT64}))
  998. .INPUT(weights, TensorType({DT_INT32,DT_INT64,DT_FLOAT,DT_DOUBLE}))
  999. .OUTPUT(output_indices, TensorType({DT_INT64}))
  1000. .OUTPUT(output_values, TensorType({DT_INT32,DT_INT64,DT_FLOAT,DT_DOUBLE}))
  1001. .OUTPUT(output_dense_shape, TensorType({DT_INT64}))
  1002. .ATTR(minlength, Int, -1)
  1003. .ATTR(maxlength, Int, -1)
  1004. .REQUIRED_ATTR(binary_output, Bool)
  1005. .OP_END_FACTORY_REG(DenseCountSparseOutput)
  1006. /**
  1007. * @brief Computes gradients for SparseSegmentSum . \n
  1008. * @par Inputs:
  1009. * The input grad must have be type float or double. Inputs include:
  1010. * @li grad: A Tensor. Must be one of the following types: bfloat16, float16, float32, double.
  1011. gradient propagated to the SparseSegmentSum op.
  1012. * @li indices: A Tensor. Must be one of the following types: int32, int64.
  1013. indices passed to the corresponding SparseSegmentSum op.
  1014. * @li segment_ids: A Tensor of type int32, int64. segment_ids passed to the
  1015. corresponding SparseSegmentSum op.
  1016. * @li output_dim0: A Tensor of type int32. dimension 0 of "x" passed to
  1017. SparseSegmentSum op . \n
  1018. * @par Outputs:
  1019. * output:A Tensor. Has the same type as grad . \n
  1020. * @par Third-party framework compatibility
  1021. * Compatible with tensorflow SparseSegmentSumGrad operator
  1022. */
  1023. REG_OP(SparseSegmentSumGrad)
  1024. .INPUT(grad, TensorType({DT_BF16, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1025. .INPUT(indices, TensorType({DT_INT32, DT_INT64}))
  1026. .INPUT(segment_ids, TensorType({DT_INT32, DT_INT64}))
  1027. .INPUT(output_dim0, TensorType({DT_INT32}))
  1028. .OUTPUT(output, TensorType({DT_BF16, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1029. .OP_END_FACTORY_REG(SparseSegmentSumGrad)
  1030. /**
  1031. * @brief Count the number of occurrences of each value in the input ragged integer array,
  1032. * and output it according to the sparse matrix. \n
  1033. * @par Inputs:
  1034. * @li splits: A 1D tensor of type int64.
  1035. * @li values: A 1D or 2D tensor of type int32 or int64.
  1036. * @li weights: A tensor of type int32 or int64 or float or double. \n
  1037. * @par Attributes:
  1038. * @li minlength: An optional int >=-1. Defaults to -1.
  1039. * @li maxlength: An optional int >=-1. Defaults to -1.
  1040. * @li binary_output: A required bool. \n
  1041. * @par Outputs:
  1042. * output_indices: A tensor of type int64.
  1043. * output_values: A tensor of the same type as "weights".
  1044. * output_dense_shape: A tensor of type int64. \n
  1045. * @par Third-party framework compatibility
  1046. * Compatible with the TensorFlow operator RaggedCountSparseOutput. \n
  1047. */
  1048. REG_OP(RaggedCountSparseOutput)
  1049. .INPUT(splits, TensorType({DT_INT64}))
  1050. .INPUT(values, TensorType({DT_INT32,DT_INT64}))
  1051. .INPUT(weights, TensorType({DT_INT32,DT_INT64,DT_FLOAT,DT_DOUBLE}))
  1052. .OUTPUT(output_indices, TensorType({DT_INT64}))
  1053. .OUTPUT(output_values, TensorType({DT_INT32,DT_INT64,DT_FLOAT,DT_DOUBLE}))
  1054. .OUTPUT(output_dense_shape, TensorType({DT_INT64}))
  1055. .ATTR(minlength, Int, -1)
  1056. .ATTR(maxlength, Int, -1)
  1057. .REQUIRED_ATTR(binary_output, Bool)
  1058. .OP_END_FACTORY_REG(RaggedCountSparseOutput)
  1059. /**
  1060. * @brief SignBitsUnpack.
  1061. * @par Inputs:
  1062. * one input, including:
  1063. * @li x: A 1D Tensor of uint8.
  1064. * @par Attributes:
  1065. * @li size: dim of out put tensor, defaults to 1.
  1066. * @li dtype: dtype of out put tensor: DT_FLOAT(0) or DT_FLOAT16(1).
  1067. * @par Outputs:
  1068. * @li y: A 2D Tensor of type float32 (float16) with shape (size, (x.shape * 8) / size),
  1069. */
  1070. REG_OP(SignBitsUnpack)
  1071. .INPUT(x, TensorType({DT_UINT8}))
  1072. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  1073. .REQUIRED_ATTR(size, Int)
  1074. .REQUIRED_ATTR(dtype, Type)
  1075. .OP_END_FACTORY_REG(SignBitsUnpack)
  1076. /**
  1077. * @brief Function scaled masked softmax . \n
  1078. * @par Inputs:
  1079. * Two inputs, including:
  1080. * @li x: A mutable Tensor. The type support float16/float32.
  1081. * @li mask: An optional Tensor. Must meet all of the following rules:
  1082. * shape of mask should be broadcastable with x.
  1083. * dtype of mask should be bool.
  1084. * mask is binary
  1085. * @par Attributes:
  1086. * scale: A attribute used to scale tensor. The type is float. The dimension softmax would be performed on. Defaults
  1087. * to "1.0" . \n
  1088. * fixed_triu_mask: A flag used to enable or disable a fixed upper triangle mask. The type is bool. Defaults
  1089. * to "false" . \n
  1090. * @par Outputs:
  1091. * y: A mutable Tensor. Has the same type as "x". \n
  1092. * @par Restrictions:
  1093. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1094. */
  1095. REG_OP(ScaledMaskedSoftmax)
  1096. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1097. .OPTIONAL_INPUT(mask, TensorType({DT_BOOL, DT_UINT1}))
  1098. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1099. .ATTR(scale, Float, 1.0)
  1100. .ATTR(fixed_triu_mask, Bool, false)
  1101. .OP_END_FACTORY_REG(ScaledMaskedSoftmax)
  1102. /**
  1103. * @brief Function scaled masked softmax grad . \n
  1104. * @par Inputs:
  1105. * Three inputs, including:
  1106. * @li y_grad: A mutable Tensor. The type support float16/float32.
  1107. * @li y: A mutable Tensor. The type support float16/float32.
  1108. * @li mask: An optional Tensor. Must meet all of the following rules:
  1109. * shape of mask should be broadcastable with x.
  1110. * dtype of mask should be bool.
  1111. * mask is binary
  1112. * @par Attributes:
  1113. * scale: A attribute used to scale tensor. The type is float. The dimension softmax would be performed on. Defaults
  1114. * to "1.0" . \n
  1115. * fixed_triu_mask: A flag used to enable or disable a fixed upper triangle mask. The type is bool. Defaults
  1116. * to "false" . \n
  1117. * @par Outputs:
  1118. * x_grad: A mutable Tensor. Has the same type as "x". \n
  1119. * @par Restrictions:
  1120. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1121. */
  1122. REG_OP(ScaledMaskedSoftmaxGrad)
  1123. .INPUT(y_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  1124. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1125. .OPTIONAL_INPUT(mask, TensorType({DT_BOOL, DT_UINT1}))
  1126. .OUTPUT(x_grad, TensorType({DT_FLOAT16}))
  1127. .ATTR(scale, Float, 1.0)
  1128. .ATTR(fixed_triu_mask, Bool, false)
  1129. .OP_END_FACTORY_REG(ScaledMaskedSoftmaxGrad)
  1130. /**
  1131. * @brief SignBitsPack.
  1132. * @par Inputs:
  1133. * one input, including:
  1134. * @li x: A 1D Tensor of float32 or float16.
  1135. *
  1136. * @par Attributes:
  1137. * @li size: first dim value of output tensor.
  1138. *
  1139. * @par Outputs:
  1140. * @li y: A 2D Tensor of type uint8 with shape (size, N)
  1141. */
  1142. REG_OP(SignBitsPack)
  1143. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1144. .OUTPUT(y, TensorType({DT_UINT8}))
  1145. .REQUIRED_ATTR(size, Int)
  1146. .OP_END_FACTORY_REG(SignBitsPack)
  1147. /**
  1148. * @brief Get sobol samples. \n
  1149. * @par Inputs:
  1150. * Three inputs, including:
  1151. * @li dim: Dimension of results, which must be a scalar of type int32.
  1152. * @li num_results: Number of results, which must be a scalar of type int32.
  1153. * @li skip: Number of initial points, which must be a scalar of type int32. \n
  1154. * @par Attributes:
  1155. * @li dtype: Data type of output samples. \n
  1156. * @par Outputs:
  1157. * @li y: A Tensor with the DT_FLOAT or DT_DOUBLE type generated samples. \n
  1158. * @par Third-party framework compatibility
  1159. * @li compatible with tensorflow SobolSample operator.
  1160. **/
  1161. REG_OP(SobolSample)
  1162. .INPUT(dim, TensorType({DT_INT32}))
  1163. .INPUT(num_results, TensorType({DT_INT32}))
  1164. .INPUT(skip, TensorType({DT_INT32}))
  1165. .OUTPUT(samples, TensorType({DT_FLOAT,DT_DOUBLE}))
  1166. .ATTR(dtype, Type, DT_FLOAT)
  1167. .OP_END_FACTORY_REG(SobolSample)
  1168. /**
  1169. * @brief Count the number of occurrences of each value in the input sparse integer array,
  1170. * and output it according to the sparse matrix. \n
  1171. * @par Inputs:
  1172. * @li indices: A tensor of type int64.
  1173. * @li values: A tensor of type int32 or int64.
  1174. * @li dense_shape: A tensor of type int64.
  1175. * @li weights: A tensor of type int32 or int64 or float or double. \n
  1176. * @par Attributes:
  1177. * @li minlength: An optional int >=-1. Defaults to -1.
  1178. * @li maxlength: An optional int >=-1. Defaults to -1.
  1179. * @li binary_output: A required bool. \n
  1180. * @par Outputs:
  1181. * @li output_indices: A tensor of type int64.
  1182. * @li output_values: A tensor of the same type as "weights".
  1183. * @li output_dense_shape: A tensor of type int64. \n
  1184. * @par Third-party framework compatibility
  1185. * Compatible with the TensorFlow operator SparseCountSparseOutput. \n
  1186. */
  1187. REG_OP(SparseCountSparseOutput)
  1188. .INPUT(indices, TensorType({DT_INT64}))
  1189. .INPUT(values, TensorType({DT_INT32,DT_INT64}))
  1190. .INPUT(dense_shape, TensorType({DT_INT64}))
  1191. .INPUT(weights, TensorType({DT_INT32,DT_INT64,DT_FLOAT,DT_DOUBLE}))
  1192. .OUTPUT(output_indices, TensorType({DT_INT64}))
  1193. .OUTPUT(output_values, TensorType({DT_INT32,DT_INT64,DT_FLOAT,DT_DOUBLE}))
  1194. .OUTPUT(output_dense_shape, TensorType({DT_INT64}))
  1195. .ATTR(minlength, Int, -1)
  1196. .ATTR(maxlength, Int, -1)
  1197. .REQUIRED_ATTR(binary_output, Bool)
  1198. .OP_END_FACTORY_REG(SparseCountSparseOutput)
  1199. /**
  1200. * @brief Counts the number of occurrences of each value in an integer array. \n
  1201. * @par Inputs:
  1202. * @li splits: A Tensor of type int64. 1D int64 Tensor.
  1203. * @li values: A Tensor. Must be one of the following types: int32, int64. 2D int Tensor.
  1204. * @li size: A Tensor. Must have the same type as values. non-negative int scalar Tensor.
  1205. * @li weights: A Tensor. Must be one of the following types: float32.
  1206. is a float32 Tensor with the same shape as input,
  1207. or a length-0 Tensor, in which case it acts as all weights equal to 1. \n
  1208. * @par Outputs:
  1209. * @li output: A Tensor with length "size" for each stride and has the same dtype as weights. \n
  1210. * @par Attributes:
  1211. * binary_output: An optional bool. Defaults to False. bool;
  1212. Whether the kernel should count the appearance or number of occurrences. \n
  1213. * @attention Constraints:
  1214. * The operator will use the interface set_atomic_add(), therefore weights and output should be float32 only. \n
  1215. * @par Third-party framework compatibility
  1216. * Compatible with tensorflow RaggedBinCount operator.
  1217. */
  1218. REG_OP(RaggedBinCount)
  1219. .INPUT(splits, TensorType(DT_INT64))
  1220. .INPUT(values, TensorType({DT_INT32, DT_INT64}))
  1221. .INPUT(size, TensorType({DT_INT32, DT_INT64}))
  1222. .INPUT(weights, TensorType(DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE))
  1223. .OUTPUT(output, TensorType(DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE))
  1224. .ATTR(binary_output, Bool, false)
  1225. .OP_END_FACTORY_REG(RaggedBinCount)
  1226. /**
  1227. * @brief Counts the number of occurrences of each value in an integer array. \n
  1228. * @par Inputs:
  1229. * @li input: A Tensor of type int32, int64. 1D or 2D int Tensor.
  1230. * @li size: A Tensor. Must have the same type as input. non-negative int scalar Tensor.
  1231. * @li weights: A Tensor. Must be one of the following types: int32, int64, float32, float64.
  1232. with the same shape as input,
  1233. or a length-0 Tensor, in which case it acts as all weights equal to 1. \n
  1234. * @par Outputs:
  1235. * @li output: A Tensor with length "size" for each stride and has the same dtype as weights. \n
  1236. * @par Attributes:
  1237. * binary_output: An optional bool. Defaults to False. bool;
  1238. Whether the kernel should count the appearance or number of occurrences. \n
  1239. * @attention Constraints:
  1240. * The operator will use the interface set_atomic_add(), therefore weights and output should be float32 only. \n
  1241. * @par Third-party framework compatibility
  1242. * Compatible with tensorflow DenseBincount operator.
  1243. */
  1244. REG_OP(DenseBincount)
  1245. .INPUT(input, TensorType({DT_INT32, DT_INT64}))
  1246. .INPUT(size, TensorType({DT_INT32, DT_INT64}))
  1247. .INPUT(weights, TensorType(DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE))
  1248. .OUTPUT(output, TensorType(DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE))
  1249. .ATTR(binary_output, Bool, false)
  1250. .OP_END_FACTORY_REG(DenseBincount)
  1251. } // namespace ge
  1252. #endif // OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_

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