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 36 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
3 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  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_INT64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16}))
  210. .INPUT(indices, TensorType({DT_INT32}))
  211. .INPUT(segment_ids, TensorType({DT_INT32}))
  212. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  213. DT_INT32, DT_INT64, 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}))
  231. .INPUT(indices, TensorType({DT_INT32}))
  232. .INPUT(segment_ids, TensorType({DT_INT32}))
  233. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  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}))
  254. .INPUT(indices, TensorType({DT_INT32}))
  255. .INPUT(segment_ids, TensorType({DT_INT32}))
  256. .INPUT(output_dim0, TensorType({DT_INT32}))
  257. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  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,NC1HWC0,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, float16, int32, int64.
  368. *@li range: A Tensor of type float32,float16,int32, int64.
  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 or int64 . \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.
  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}))
  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.
  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}))
  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 deal complex.
  809. * @par Inputs:
  810. * input: An ND tensor of type complex64, complex128 \n
  811. * @par Attributes:
  812. * Tout: representing the output of type.
  813. * @par Outputs:
  814. * output: An ND tensor of type float32. double \n
  815. */
  816. REG_OP(Imag)
  817. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  818. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  819. .ATTR(Tout, Type, DT_FLOAT)
  820. .OP_END_FACTORY_REG(Imag)
  821. /**
  822. * @brief deal complex.
  823. * @par Inputs:
  824. * @li input: An ND tensor of type complex64, complex128 \n
  825. *
  826. * @par Outputs:
  827. * @li output: An ND tensor of type float32. double \n
  828. */
  829. REG_OP(Angle)
  830. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  831. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  832. .ATTR(Tout, Type, DT_FLOAT)
  833. .OP_END_FACTORY_REG(Angle)
  834. /**
  835. *@brief Computes the gradient of SoftMarginLossGrad. \n
  836. *@par Inputs:
  837. *Three inputs, including:
  838. * @li predict: A tensor. Must be one of the following types:
  839. * float16, float32. \n
  840. * @li label: A tensor with same shape of predict. Must be one of the following types:
  841. * float16, float32. \n
  842. * @li dout: A tensor with same shpae of predcit. Must be one of the following types:
  843. * float16, float32. \n
  844. *@par Attributes:
  845. * reduction: Specifies the reduction to apply to the output:
  846. * 'none' | 'mean' | 'sum'. Default: 'mean'. \n
  847. *@par Outputs:
  848. * gradient: A Tensor with the same type of predict. \n
  849. *@par Third-party framework compatibility
  850. *Compatible with the Pytorch operator SoftMarginLoss Backward. \n
  851. */
  852. REG_OP(SoftMarginLossGrad)
  853. .INPUT(predict, TensorType({DT_FLOAT16,DT_FLOAT}))
  854. .INPUT(label, TensorType({DT_FLOAT16,DT_FLOAT}))
  855. .INPUT(dout, TensorType({DT_FLOAT16,DT_FLOAT}))
  856. .OUTPUT(gradient, TensorType({DT_FLOAT16,DT_FLOAT}))
  857. .ATTR(reduction, String, "mean")
  858. .OP_END_FACTORY_REG(SoftMarginLossGrad)
  859. /**
  860. *@brief Calculate the cross product of two tensors. \n
  861. *@par Inputs:
  862. *One inputs, including:
  863. * @li x1: A tensor. Must be one of the following types:
  864. * float16, float32, int32, int8, uint8, int16. \n
  865. * @li x2: A tensor. Must be one of the following types:
  866. * float16, float32, int32, int8, uint8, int16. \n
  867. *@par Attributes:
  868. *@li dim: the dimination of compute.Defaults to -65530. \n
  869. *@par Outputs:
  870. *y: A Tensor with the same type and shape of x1's. \n
  871. *@par Third-party framework compatibility
  872. *Compatible with the Pytorch operator cross. \n
  873. */
  874. REG_OP(Cross)
  875. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  876. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  877. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  878. .ATTR(dim, Int, -65530)
  879. .OP_END_FACTORY_REG(Cross)
  880. /**
  881. *@brief Computes batched the p-norm distance between each pair of
  882. *the two collections of row vectors. \n
  883. *@par Inputs:
  884. *Two inputs, including:
  885. * @li x1: A tensor with shpae: BxPXM. Must be one of the following types:
  886. * float16, float32. \n
  887. * @li x2: A tensor with shpae: BxRxM. Must be one of the following types:
  888. * float16, float32. \n
  889. *@par Attributes:
  890. * @li p: An optional float >= 0 or inf. Defaults to 2.0. \n
  891. *@par Outputs:
  892. * y: A Tensor with the same type of x1's and with shape BxPxR. \n
  893. *@par Third-party framework compatibility
  894. *Compatible with the Pytorch operator Cdist. \n
  895. */
  896. REG_OP(Cdist)
  897. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT}))
  898. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT}))
  899. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  900. .ATTR(p, Float, 2.0)
  901. .OP_END_FACTORY_REG(Cdist)
  902. /**
  903. *@brief Computes the grad of x1 in cdist. \n
  904. *@par Inputs:
  905. *Four inputs, including:
  906. * @li grad: Grad with shape BxPxR. Must be one of the following types:
  907. * float16, float32. \n
  908. * @li x1: A tensor with shpae: BxPXM. Must be one of the following types:
  909. * float16, float32. \n
  910. * @li x2: A tensor with shpae: BxRxM. Must be one of the following types:
  911. * float16, float32. \n
  912. * @li cdist: Output tensor of cdist forward with shpae: BxPXR.
  913. * Must be one of the following types: 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 and shape of x1's. \n
  918. *@par Third-party framework compatibility
  919. *Compatible with the Pytorch operator Cdist Backward. \n
  920. */
  921. REG_OP(CdistGrad)
  922. .INPUT(grad, TensorType({DT_FLOAT16,DT_FLOAT}))
  923. .INPUT(x1, TensorType({DT_FLOAT16,DT_FLOAT}))
  924. .INPUT(x2, TensorType({DT_FLOAT16,DT_FLOAT}))
  925. .INPUT(cdist, TensorType({DT_FLOAT16,DT_FLOAT}))
  926. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  927. .ATTR(p, Float, 2.0)
  928. .OP_END_FACTORY_REG(CdistGrad)
  929. } // namespace ge
  930. #endif // OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_

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