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

5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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. * @li input_x: A tensor. Must be one of the following types: float16, float32, int8, uint8, int32. \n
  183. *@par Outputs:
  184. *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 grad: 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 channel_name: A string. Default "" . \n
  293. *@par Outputs:
  294. *y:A nested structure of Tensor objects . \n
  295. *@par Third-party framework compatibility
  296. *Compatible with tensorflow GetNext operator
  297. */
  298. REG_OP(GetNext)
  299. .DYNAMIC_OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64,
  300. DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_BOOL}))
  301. .ATTR(output_types, ListInt, {})
  302. .ATTR(output_shapes, ListListInt, {})
  303. .ATTR(output_num, Int, 1)
  304. .ATTR(channel_name, String, "")
  305. .OP_END_FACTORY_REG(GetNext)
  306. /**
  307. *@brief Get dynamic dims after GetNext. \n
  308. *@par Inputs:
  309. *input: A nested structure of Tensor objects, from GetNext's output. \n
  310. *@par Attributes:
  311. *@li shape_info: GE shape_info for each inputs, -1 means unknow dim.
  312. *@li N: Inputs number. \n
  313. *@par Outputs:
  314. *dims: GE unknow dims, a vector of int64. \n
  315. */
  316. REG_OP(GetDynamicDims)
  317. .DYNAMIC_INPUT(input, TensorType({DT_INT32, DT_INT64}))
  318. .OUTPUT(dims, TensorType({DT_INT32, DT_INT64}))
  319. .REQUIRED_ATTR(shape_info, ListInt)
  320. .REQUIRED_ATTR(N, Int)
  321. .OP_END_FACTORY_REG(GetDynamicDims)
  322. /**
  323. *@brief End of sequence . \n
  324. *@par Inputs:
  325. *x: A Tensor of type uint8 . \n
  326. *@par Outputs:
  327. *y: A Tensor. Has the same type as "x".
  328. */
  329. REG_OP(EndOfSequence)
  330. .INPUT(x, TensorType({DT_UINT8}))
  331. .OUTPUT(y, TensorType({DT_UINT8}))
  332. .OP_END_FACTORY_REG(EndOfSequence)
  333. /**
  334. *@brief: Computes the Gauss error function of `x` element-wise . \n
  335. *@par Inputs:
  336. *x: A Tensor of type float16, float32 or double. the format can be
  337. * [NCHW,NC1HWC0,NHWC,ND]
  338. *@par Outputs:
  339. *y: A Tensor. Has the same type and format as "x" . \n
  340. *@par Third-party framework compatibility
  341. * Compatible with the TensorFlow operator Erf.
  342. */
  343. REG_OP(Erf)
  344. .INPUT(x, TensorType::FloatingDataType())
  345. .OUTPUT(y, TensorType::FloatingDataType())
  346. .OP_END_FACTORY_REG(Erf)
  347. /**
  348. *@brief: Computes the Gauss complementary error function of "x" element-wise . \n
  349. *@par Inputs:
  350. *x: A Tensor of type float16 ,float32, double . \n
  351. *@par Outputs:
  352. *y: A Tensor. Has the same type as "x" . \n
  353. *@par Third-party framework compatibility
  354. * Compatible with the TensorFlow operator Erfc.
  355. */
  356. REG_OP(Erfc)
  357. .INPUT(x, TensorType::FloatingDataType())
  358. .OUTPUT(y, TensorType::FloatingDataType())
  359. .OP_END_FACTORY_REG(Erfc)
  360. /**
  361. *@brief This operation returns a rank 1 histogram counting the number of entries in `values`
  362. * that fell into every bin.The bins are equal width and determined by the arguments
  363. * 'value_range' and 'nbins' . \n
  364. *@par Inputs:
  365. *Three inputs, including:
  366. *@li x: A Tensor of type float32, float16, int32, int64.
  367. *@li range: A Tensor of type float32,float16,int32, int64.
  368. *@li nbins: A Tensor of type int32 . \n
  369. *@par Attributes:
  370. * dtype: An optional attribute. Defaults to "int32" . \n
  371. *@par Outputs:
  372. *y: A Tensor. A Tensor of type int32 or int64 . \n
  373. *@par Third-party framework compatibility
  374. * Compatible with TensorFlow operator HistogramFixedWidth.
  375. */
  376. REG_OP(HistogramFixedWidth)
  377. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  378. .INPUT(range, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  379. .INPUT(nbins, TensorType({DT_INT32}))
  380. .OUTPUT(y, TensorType({DT_INT32}))
  381. .ATTR(dtype, String, "int32")
  382. .OP_END_FACTORY_REG(HistogramFixedWidth)
  383. /**
  384. *@brief This operation returns a rank 1 histogram counting the number of entries in `values`
  385. * that fell into every bin.The bins are equal width and determined by the arguments
  386. * 'value_range' and 'nbins' . \n
  387. *@par Inputs:
  388. *Two inputs, including:
  389. *@li x: A Tensor of type float32,float16,int32, int64.
  390. *@li range: A Tensor of type float32,float16,int32, int64 . \n
  391. *@par Attributes:
  392. *@li dtype: An optional attribute. Defaults to "int32".
  393. *@li nbins: A required attribute,the type is int32 . \n
  394. *@par Outputs:
  395. *y: A Tensor. A Tensor of type int32 . \n
  396. *@par Third-party framework compatibility
  397. * Compatible with TensorFlow operator HistogramFixedWidth.
  398. *
  399. * @par Restrictions:
  400. * Warning: THIS FUNCTION IS DEPRECATED. Please use HistogramFixedWidth instead.
  401. */
  402. REG_OP(HistogramFixedWidthD)
  403. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  404. .INPUT(range, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64}))
  405. .OUTPUT(y, TensorType({DT_INT32}))
  406. .REQUIRED_ATTR(nbins, Int)
  407. .ATTR(dtype, String, "int32")
  408. .OP_END_FACTORY_REG(HistogramFixedWidthD)
  409. /**
  410. *@brief Returns the next representable value of x1 in the direction of x2, element-wise . \n
  411. *@par Inputs:
  412. *The input X1 and x2 must have the same type. Inputs include:
  413. *@li x1:A Tensor. Must be one of the following types: float32, double.
  414. *@li x2:A Tensor. Must have the same type as x1 . \n
  415. *@par Outputs:
  416. *output:A Tensor. Has the same type as x1 . \n
  417. *@par Third-party framework compatibility
  418. *Compatible with tensorflow NextAfter operator
  419. */
  420. REG_OP(NextAfter)
  421. .INPUT(x1, TensorType({DT_FLOAT, DT_DOUBLE}))
  422. .INPUT(x2, TensorType({DT_FLOAT, DT_DOUBLE}))
  423. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  424. .OP_END_FACTORY_REG(NextAfter)
  425. /**
  426. *@brief Calculate the P-norm distance between vectors function. \n
  427. *@par Inputs:
  428. *One inputs, including:
  429. * @li input_x: A tensor. Must be one of the following types:
  430. * float16, float32. \n
  431. *@par Attributes:
  432. *@li p: An optional float.Defaults to 2. \n
  433. *@par Outputs:
  434. *y: A Tensor with the same type and shape of input_x's. \n
  435. *@par Third-party framework compatibility
  436. *Compatible with the Pytorch operator Pdist. \n
  437. */
  438. REG_OP(Pdist)
  439. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  440. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  441. .ATTR(p, Float, 2.0)
  442. .OP_END_FACTORY_REG(Pdist)
  443. /**
  444. *@brief Compute element-wise finiteness, return a boolean tensor.
  445. *@par Inputs:
  446. *x:A Tensor.
  447. *@par Outputs:
  448. *y:A Tensor. Has the same shape as x.
  449. *@par Third-party framework compatibility.
  450. *Compatible with tensorflow IsFinite operator.
  451. */
  452. REG_OP(IsFinite)
  453. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  454. .OUTPUT(y, TensorType({DT_BOOL}))
  455. .OP_END_FACTORY_REG(IsFinite)
  456. /**
  457. *@brief Compute element-wise infiniteness, return a boolean tensor.
  458. *@par Inputs:
  459. *x:A Tensor.
  460. *@par Outputs:
  461. *y:A Tensor. Has the same shape as x.
  462. *@par Third-party framework compatibility.
  463. *Compatible with tensorflow IsInf operator.
  464. */
  465. REG_OP(IsInf)
  466. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  467. .OUTPUT(y, TensorType({DT_BOOL}))
  468. .OP_END_FACTORY_REG(IsInf)
  469. /**
  470. *@brief Computes the complex absolute value of a tensor.
  471. *@par Inputs:
  472. *x:A Tensor.
  473. *@par Outputs:
  474. *y:A tensor of type `float` or `double` that is the absolute value of each element in `x`.
  475. *@par Third-party framework compatibility.
  476. *Compatible with tensorflow ComplexAbs operator.
  477. */
  478. REG_OP(ComplexAbs)
  479. .INPUT(x, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  480. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  481. .ATTR(Tout, Type, DT_FLOAT)
  482. .OP_END_FACTORY_REG(ComplexAbs)
  483. /**
  484. *@brief Returns which elements of x are NaN.
  485. *@par Inputs:
  486. *x:A Tensor.
  487. *@par Outputs:
  488. *y:A Tensor. Has the same shape as x.
  489. *@par Third-party framework compatibility.
  490. *Compatible with tensorflow IsNan operator.
  491. */
  492. REG_OP(IsNan)
  493. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  494. .OUTPUT(y, TensorType({DT_BOOL}))
  495. .OP_END_FACTORY_REG(IsNan)
  496. /**
  497. *@brief Returns the real part of a complex number.
  498. *@par Inputs:
  499. *input:A Tensor.
  500. *@par Outputs:
  501. *output:A Tensor. Has the same shape as input.
  502. *@par Third-party framework compatibility.
  503. *Compatible with tensorflow Real operator.
  504. */
  505. REG_OP(Real)
  506. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  507. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  508. .ATTR(Tout, Type, DT_FLOAT)
  509. .OP_END_FACTORY_REG(Real)
  510. /**
  511. *@brief Returns the complex conjugate of a complex number.
  512. *@par Inputs:
  513. *input:A Tensor.
  514. *@par Outputs:
  515. *output:A Tensor. Has the same shape as input.
  516. *@par Third-party framework compatibility.
  517. *Compatible with tensorflow output operator.
  518. */
  519. REG_OP(Conj)
  520. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  521. .OUTPUT(output, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  522. .OP_END_FACTORY_REG(Conj)
  523. /**
  524. *@brief The negative log likelihood loss . \n
  525. *@par Inputs:
  526. *The input x and weight must have the same type. Inputs include:
  527. *@li x: A Tensor dtype of float32.
  528. *@li target: A Tensor dtype of int32.
  529. *@li weight: A Tensor dtype of float32 . \n
  530. *@par Attributes:
  531. *@li reduction: An optional attribute. Defaults to "mean" .
  532. *@li ignore_index:An optional attribute.Defaults to -100 . \n
  533. *@par Outputs:
  534. *@li y: A Tensor dtype of float32.
  535. *@li total_weight: A Tensor dtype of float32 . \n
  536. *@par Third-party framework compatibility
  537. *Compatible with pytorch NLLLoss operator
  538. */
  539. REG_OP(NLLLoss)
  540. .INPUT(x, TensorType({DT_FLOAT}))
  541. .INPUT(target, TensorType({DT_INT32}))
  542. .INPUT(weight, TensorType({DT_FLOAT}))
  543. .OUTPUT(y, TensorType({DT_FLOAT}))
  544. .OUTPUT(total_weight, TensorType({DT_FLOAT}))
  545. .ATTR(reduction, String, "mean")
  546. .ATTR(ignore_index, Int, -100)
  547. .OP_END_FACTORY_REG(NLLLoss)
  548. /**
  549. *@brief The negative log likelihood loss grad . \n
  550. *@par Inputs:
  551. *@li x:A Tensor dtype of float32.
  552. *@li y_grad:A Tensor dtype of float32.
  553. *@li target:A Tensor dtype of int32.
  554. *@li weight:A Tensor dtype of float32.
  555. *@li total_weight:A Tensor dtype of float32 . \n
  556. *@par Attributes:
  557. *@li reduction: An optional attribute. Defaults to "mean" .
  558. *@li ignore_index:An optional attribute.Defaults to -100 . \n
  559. *@par Outputs:
  560. *x_grad: A Tensor. Must be the following type: float32 . \n
  561. *@par Third-party framework compatibility
  562. *Compatible with pytorch NLLLossGrad operator
  563. */
  564. REG_OP(NLLLossGrad)
  565. .INPUT(x, TensorType({DT_FLOAT}))
  566. .INPUT(y_grad, TensorType({DT_FLOAT}))
  567. .INPUT(target, TensorType({DT_INT32}))
  568. .INPUT(weight, TensorType({DT_FLOAT}))
  569. .INPUT(total_weight, TensorType({DT_FLOAT}))
  570. .OUTPUT(x_grad, TensorType({DT_FLOAT}))
  571. .ATTR(reduction, String, "mean")
  572. .ATTR(ignore_index, Int, -100)
  573. .OP_END_FACTORY_REG(NLLLossGrad)
  574. /**
  575. *@brief IFMR(Input Feature Map Reconstruction). \n
  576. *@par Inputs:
  577. *@li data: A Tensor of feature map.
  578. *@li data_min: A Tensor of min value of feature map.
  579. *@li data_max: A Tensor of max value of feature map.
  580. *@li cumsum: A Tensor of cumsum bin of data . \n
  581. *@par Attributes:
  582. *@li min_percentile: min init percentile.
  583. *@li max_percentile: max init percentile.
  584. *@li search_range: search range.
  585. *@li search_step: step size of searching.
  586. *@li with_offset: whether using offset . \n
  587. *@par Outputs:
  588. *@li scale: optimal scale.
  589. *@li offset: optimal offset . \n
  590. *@par Third-party framework compatibility
  591. *Compatible with mindspore
  592. */
  593. REG_OP(IFMR)
  594. .INPUT(data, TensorType({DT_FLOAT16, DT_FLOAT}))
  595. .INPUT(data_min, TensorType({DT_FLOAT16, DT_FLOAT}))
  596. .INPUT(data_max, TensorType({DT_FLOAT16, DT_FLOAT}))
  597. .INPUT(cumsum, TensorType({DT_INT32}))
  598. .OUTPUT(scale, TensorType({DT_FLOAT}))
  599. .OUTPUT(offset, TensorType({DT_FLOAT}))
  600. .REQUIRED_ATTR(min_percentile, Float)
  601. .REQUIRED_ATTR(max_percentile, Float)
  602. .REQUIRED_ATTR(search_range, ListFloat)
  603. .REQUIRED_ATTR(search_step, Float)
  604. .REQUIRED_ATTR(with_offset, Bool)
  605. .OP_END_FACTORY_REG(IFMR)
  606. /**
  607. *@brief Weights Adaptive Range Quantization. \n
  608. *@par Inputs:
  609. *@li w: A Tensor of weights. \n
  610. *@li w_min: A Tensor of weights reduce_min. \n
  611. *@li w_max: A Tensor of weights reduce_max. \n
  612. *@par Attributes:
  613. *@li num_bits: the bits num used for quantize.
  614. *@li offset_flag: whether using offset. \n
  615. *@par Outputs:
  616. *y: fake quantized weights. \n
  617. *@par Third-party framework compatibility
  618. *Compatible with mindspore
  619. *@par Restrictions:
  620. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  621. */
  622. REG_OP(WtsARQ)
  623. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  624. .INPUT(w_min, TensorType({DT_FLOAT16, DT_FLOAT}))
  625. .INPUT(w_max, TensorType({DT_FLOAT16, DT_FLOAT}))
  626. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  627. .ATTR(num_bits, Int, 8)
  628. .ATTR(offset_flag, Bool, false)
  629. .OP_END_FACTORY_REG(WtsARQ)
  630. /**
  631. *@brief Activations Universal Linear Quantization. \n
  632. *@par Inputs:
  633. *@li x: A Tensor of feature map.
  634. *@li clamp _min: A Tensor of min clamp value of feature map.
  635. *@li clamp _max: A Tensor of max clamp value of feature map.
  636. *@par Attributes:
  637. *@li fixed_min: fix min to zero.
  638. *@li num_bits: quant bits. \n
  639. *@par Outputs:
  640. *@li y: output fake quant feature map.
  641. *@li clamp_min_mask: where x > clamp_min.
  642. *@li clamp_min_mask: where x < clamp_max.
  643. *@li x_clamped_loss: clamp loss. \n
  644. *@par Third-party framework compatibility
  645. *Compatible with mindspore
  646. *@par Restrictions:
  647. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  648. */
  649. REG_OP(ActsULQ)
  650. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  651. .INPUT(clamp_min, TensorType({DT_FLOAT16, DT_FLOAT}))
  652. .INPUT(clamp_max, TensorType({DT_FLOAT16, DT_FLOAT}))
  653. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  654. .OUTPUT(clamp_min_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  655. .OUTPUT(clamp_max_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  656. .OUTPUT(x_clamped_loss, TensorType({DT_FLOAT16, DT_FLOAT}))
  657. .ATTR(fixed_min, Bool, false)
  658. .ATTR(num_bits, Int, 8)
  659. .OP_END_FACTORY_REG(ActsULQ)
  660. /**
  661. *@brief The gradient of Activations Universal Linear Quantization. \n
  662. *@par Inputs:
  663. *@li y_grad: A Tensor of gradient.
  664. *@li clamp_min_mask: A Tensor of boolean mask indicating whether an additional one is needed'.
  665. *@li clamp_max_mask: A Tensor of boolean mask indicating whether an additional one is needed'.
  666. *@par Outputs:
  667. *x_grapd: The gradient of inpust. \n
  668. *@par Third-party framework compatibility
  669. *Compatible with mindspore
  670. *@par Restrictions:
  671. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  672. */
  673. REG_OP(ActsULQInputGrad)
  674. .INPUT(y_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  675. .INPUT(clamp_min_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  676. .INPUT(clamp_max_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  677. .OUTPUT(x_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  678. .OP_END_FACTORY_REG(ActsULQInputGrad)
  679. /**
  680. *@brief The gradient of Activations Universal Linear Quantization clamp max. \n
  681. *@par Inputs:
  682. *@li y_grad: A Tensor of gradient.
  683. *@li clamp_max_mask: A Tensor of boolean mask indicating whether an additional one is needed.
  684. *@li x_clamped_loss: A Tensor of gradient. \n
  685. *@par Outputs:
  686. *clamp_max_grad: The gradient of clamp max. \n
  687. *@par Third-party framework compatibility
  688. *Compatible with mindspore
  689. *@par Restrictions:
  690. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  691. */
  692. REG_OP(ActULQClampMaxGrad)
  693. .INPUT(y_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  694. .INPUT(clamp_max_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  695. .INPUT(x_clamped_loss, TensorType({DT_FLOAT16, DT_FLOAT}))
  696. .OUTPUT(clamp_max_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  697. .OP_END_FACTORY_REG(ActULQClampMaxGrad)
  698. /**
  699. *@brief The gradient of Activations Universal Linear Quantization clamp min. \n
  700. *@par Inputs:
  701. *@li y_grad: A Tensor of gradient.
  702. *@li clamp_min_mask: A Tensor of boolean mask indicating whether an additional one is needed.
  703. *@li x_clamped_loss: A Tensor of gradient. \n
  704. *@par Outputs:
  705. *clamp_min_grad: The gradient of clamp min. \n
  706. *@par Third-party framework compatibility
  707. *Compatible with mindspore
  708. *@par Restrictions:
  709. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  710. */
  711. REG_OP(ActULQClampMinGrad)
  712. .INPUT(y_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  713. .INPUT(clamp_min_mask, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT}))
  714. .INPUT(x_clamped_loss, TensorType({DT_FLOAT16, DT_FLOAT}))
  715. .OUTPUT(clamp_min_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  716. .OP_END_FACTORY_REG(ActULQClampMinGrad)
  717. /**
  718. * @brief Computes Lp norm.
  719. * @par Inputs:
  720. * @li x: An ND tensor of type float16, float32. \n
  721. *
  722. * @par Attributes:
  723. * @li p: Int, "inf" or "-inf", default value is 2.
  724. * @li axes: ListInt, {} means all axes will be computed.
  725. * @li keepdim: Bool, default is false.
  726. * @li epsilon: Float, default is 1e-12. \n
  727. * @par Outputs:
  728. * @li y: An ND tensor of type float16, float32. The shape of y is depending
  729. * on axes and keepdim. \n
  730. * @par Third-party framework compatibility
  731. * Compatible with the Pytorch operator LpNorm.
  732. */
  733. REG_OP(LpNorm)
  734. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  735. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  736. .ATTR(p, Int, 2)
  737. .ATTR(axes, ListInt, {})
  738. .ATTR(keepdim, Bool, false)
  739. .ATTR(epsilon, Float, 1e-12)
  740. .OP_END_FACTORY_REG(LpNorm)
  741. /**
  742. * @brief get complex.
  743. * @par Inputs:
  744. * @li real: An ND tensor of type float32. double
  745. * @li imag: An ND tensor of type float32. double \n
  746. *
  747. * @par Outputs:
  748. * @li out: An ND tensor of type complex64, complex128 \n
  749. */
  750. REG_OP(Complex)
  751. .INPUT(real, TensorType({DT_FLOAT, DT_DOUBLE}))
  752. .INPUT(imag, TensorType({DT_FLOAT, DT_DOUBLE}))
  753. .OUTPUT(out, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  754. .ATTR(Tout, Type, DT_COMPLEX64)
  755. .OP_END_FACTORY_REG(Complex)
  756. /**
  757. * @brief deal complex.
  758. * @par Inputs:
  759. * @li input: An ND tensor of type complex64, complex128 \n
  760. *
  761. * @par Outputs:
  762. * @li output: An ND tensor of type float32. double \n
  763. */
  764. REG_OP(Imag)
  765. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  766. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  767. .ATTR(Tout, Type, DT_FLOAT)
  768. .OP_END_FACTORY_REG(Imag)
  769. /**
  770. * @brief deal complex.
  771. * @par Inputs:
  772. * @li input: An ND tensor of type complex64, complex128 \n
  773. *
  774. * @par Outputs:
  775. * @li output: An ND tensor of type float32. double \n
  776. */
  777. REG_OP(Angle)
  778. .INPUT(input, TensorType({DT_COMPLEX64, DT_COMPLEX128}))
  779. .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE}))
  780. .ATTR(Tout, Type, DT_FLOAT)
  781. .OP_END_FACTORY_REG(Angle)
  782. /**
  783. *@brief Computes the gradient of SoftMarginLossGrad. \n
  784. *@par Inputs:
  785. *Three inputs, including:
  786. * @li predict: A tensor. Must be one of the following types:
  787. * float16, float32. \n
  788. * @li label: A tensor with same shape of predict. Must be one of the following types:
  789. * float16, float32. \n
  790. * @li dout: A tensor with same shpae of predcit. Must be one of the following types:
  791. * float16, float32. \n
  792. *@par Attributes:
  793. * @li reduction: Specifies the reduction to apply to the output:
  794. * 'none' | 'mean' | 'sum'. Default: 'mean'. \n
  795. *@par Outputs:
  796. * gradient: A Tensor with the same type of predict. \n
  797. *@par Third-party framework compatibility
  798. *Compatible with the Pytorch operator SoftMarginLoss Backward. \n
  799. */
  800. REG_OP(SoftMarginLossGrad)
  801. .INPUT(predict, TensorType({DT_FLOAT16,DT_FLOAT}))
  802. .INPUT(label, TensorType({DT_FLOAT16,DT_FLOAT}))
  803. .INPUT(dout, TensorType({DT_FLOAT16,DT_FLOAT}))
  804. .OUTPUT(gradient, TensorType({DT_FLOAT16,DT_FLOAT}))
  805. .ATTR(reduction, String, "mean")
  806. .OP_END_FACTORY_REG(SoftMarginLossGrad)
  807. /**
  808. *@brief Calculate the cross product of two tensors. \n
  809. *@par Inputs:
  810. *One inputs, including:
  811. * @li x1: A tensor. Must be one of the following types:
  812. * float16, float32, int32, int8, uint8, int16. \n
  813. * @li x2: A tensor. Must be one of the following types:
  814. * float16, float32, int32, int8, uint8, int16. \n
  815. *@par Attributes:
  816. *@li dim: the dimination of compute.Defaults to -65530. \n
  817. *@par Outputs:
  818. *y: A Tensor with the same type and shape of x1's. \n
  819. *@par Third-party framework compatibility
  820. *Compatible with the Pytorch operator cross. \n
  821. */
  822. REG_OP(Cross)
  823. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  824. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  825. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT16}))
  826. .ATTR(dim, Int, -65530)
  827. .OP_END_FACTORY_REG(Cross)
  828. /**
  829. *@brief Computes batched the p-norm distance between each pair of
  830. *the two collections of row vectors. \n
  831. *@par Inputs:
  832. *Two inputs, including:
  833. * @li x1: A tensor with shpae: BxPXM. Must be one of the following types:
  834. * float16, float32. \n
  835. * @li x2: A tensor with shpae: BxRxM. Must be one of the following types:
  836. * float16, float32. \n
  837. *@par Attributes:
  838. * @li p: An optional float >= 0 or inf. Defaults to 2.0. \n
  839. *@par Outputs:
  840. * y: A Tensor with the same type of x1's and with shape BxPxR. \n
  841. *@par Third-party framework compatibility
  842. *Compatible with the Pytorch operator Cdist. \n
  843. */
  844. REG_OP(Cdist)
  845. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT}))
  846. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT}))
  847. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  848. .ATTR(p, Float, 2.0)
  849. .OP_END_FACTORY_REG(Cdist)
  850. /**
  851. *@brief Computes the grad of x1 in cdist. \n
  852. *@par Inputs:
  853. *Four inputs, including:
  854. * @li grad: Grad with shape BxPxR. Must be one of the following types:
  855. * float16, float32. \n
  856. * @li x1: A tensor with shpae: BxPXM. Must be one of the following types:
  857. * float16, float32. \n
  858. * @li x2: A tensor with shpae: BxRxM. Must be one of the following types:
  859. * float16, float32. \n
  860. * @li cdist: Output tensor of cdist forward with shpae: BxPXR.
  861. * Must be one of the following types: float16, float32. \n
  862. *@par Attributes:
  863. * @li p: An optional float >= 0 or inf. Defaults to 2.0. \n
  864. *@par Outputs:
  865. * y: A Tensor with the same type and shape of x1's. \n
  866. *@par Third-party framework compatibility
  867. *Compatible with the Pytorch operator Cdist Backward. \n
  868. */
  869. REG_OP(CdistGrad)
  870. .INPUT(grad, TensorType({DT_FLOAT16,DT_FLOAT}))
  871. .INPUT(x1, TensorType({DT_FLOAT16,DT_FLOAT}))
  872. .INPUT(x2, TensorType({DT_FLOAT16,DT_FLOAT}))
  873. .INPUT(cdist, TensorType({DT_FLOAT16,DT_FLOAT}))
  874. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  875. .ATTR(p, Float, 2.0)
  876. .OP_END_FACTORY_REG(CdistGrad)
  877. } // namespace ge
  878. #endif // OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_

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