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.

nonlinear_fuc_ops.h 33 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 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
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
5 years ago
5 years ago
5 years ago
5 years ago
4 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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
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
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
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*!
  17. * \file nonlinear_fuc_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Computes the for the gelu of "x" . \n
  26. *@par Inputs:
  27. *One input, including:
  28. *x: A Tensor. Must be one of the following types: float16, float32
  29. *@par Outputs:
  30. *y: A Tensor. Has the same type as "x".
  31. *@par Third-party framework compatibility
  32. *Compatible with the TensorFlow operator Gelu
  33. */
  34. REG_OP(Gelu)
  35. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  36. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  37. .OP_END_FACTORY_REG(Gelu)
  38. /**
  39. *@brief Computes the gradient for the gelu of "x" . \n
  40. *@par Inputs:
  41. *Three inputs, including:
  42. * @li dy: A Tensor. Must be one of the following types: float16, float32
  43. * @li x: A Tensor of the same type as "dy".
  44. * @li y: A Tensor of the same type as "dy" . \n
  45. *@par Outputs:
  46. *z: A Tensor. Has the same type as "dy".
  47. *@par Third-party framework compatibility
  48. *Compatible with the TensorFlow operator GeluGrad
  49. */
  50. REG_OP(GeluGrad)
  51. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  52. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  53. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  54. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  55. .OP_END_FACTORY_REG(GeluGrad)
  56. /**
  57. *@brief Computes the for the fast_gelu of "x" . \n
  58. *@par Inputs:
  59. *One input, including:
  60. *x: A Tensor. Must be one of the following types: float16, float32
  61. *@par Outputs:
  62. *y: A Tensor. Has the same type as "x".
  63. *@par Third-party framework compatibility
  64. *Compatible with the TensorFlow operator FastGelu
  65. */
  66. REG_OP(FastGelu)
  67. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  68. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  69. .OP_END_FACTORY_REG(FastGelu)
  70. /**
  71. *@brief Computes the gradient for the fast_gelu of "x" . \n
  72. *@par Inputs:
  73. *Two inputs, including:
  74. * @li dy: A Tensor. Must be one of the following types: float16, float32
  75. * @li x: A Tensor of the same type as "dy" . \n
  76. *@par Outputs:
  77. *z: A Tensor. Has the same type as "dy".
  78. *@par Third-party framework compatibility
  79. *Compatible with the TensorFlow operator FastGeluGrad
  80. */
  81. REG_OP(FastGeluGrad)
  82. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  83. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  84. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  85. .OP_END_FACTORY_REG(FastGeluGrad)
  86. /**
  87. * @brief Compute hardswish of "x" element-wise . \n
  88. *@par Inputs:
  89. *One input, including:
  90. *x: A Tensor. Must be one of the following types: float16, float32
  91. *@par Outputs:
  92. *y: A Tensor. Has the same type as "x".
  93. *@par Third-party framework compatibility
  94. * Compatible with the Torch operator Hardswish.
  95. */
  96. REG_OP(Hardswish)
  97. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  98. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  99. .OP_END_FACTORY_REG(Hardswish)
  100. /**
  101. *@brief Computes the gradient for the tanh of "x" . \n
  102. *@par Inputs:
  103. *Two inputs, including:
  104. * @li y: A Tensor. Must be one of the following types: float16, float32,
  105. * double, complex64, complex128.
  106. * @li dy: A Tensor of the same type as "y" . \n
  107. *@par Outputs:
  108. *z: A Tensor. Has the same type as "y".
  109. *@par Third-party framework compatibility
  110. *Compatible with the TensorFlow operator TanhGrad.
  111. */
  112. REG_OP(TanhGrad)
  113. .INPUT(y, TensorType::UnaryDataType())
  114. .INPUT(dy, TensorType::UnaryDataType())
  115. .OUTPUT(z, TensorType::UnaryDataType())
  116. .OP_END_FACTORY_REG(TanhGrad)
  117. /**
  118. *@brief: Computes hyperbolic tangent of "x" element-wise . \n
  119. *@par Inputs:
  120. *One input:
  121. *x: A Tensor. Must be one of the following types: float16, float32, complex64, complex128, double . \n
  122. *@par Outputs:
  123. *y: A Tensor. Has the same type as "x" . \n
  124. *@par Third-party framework compatibility
  125. * Compatible with TensorFlow operator Tanh.
  126. */
  127. REG_OP(Tanh)
  128. .INPUT(x, TensorType::UnaryDataType())
  129. .OUTPUT(y, TensorType::UnaryDataType())
  130. .OP_END_FACTORY_REG(Tanh)
  131. /**
  132. * @brief Computes rectified linear: "max(x, 0)".
  133. *
  134. * @par Inputs:
  135. * x: A tensor. Must be one of the following types: float32, float64, int32, uint8,
  136. * int16, int8, int64, uint16, float16, qint8.
  137. *
  138. * @par Outputs:
  139. * y: A tensor. Has the same type as "x".
  140. *
  141. * @par Third-party framework compatibility
  142. * @li Compatible with the TensorFlow operator Relu.
  143. * @li Compatible with the Caffe operator ReLULayer.
  144. *
  145. */
  146. REG_OP(Relu)
  147. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE,
  148. DT_INT8, DT_INT32, DT_INT16, DT_INT64,
  149. DT_UINT8, DT_UINT16, DT_QINT8}))
  150. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE,
  151. DT_INT8, DT_INT32, DT_INT16, DT_INT64,
  152. DT_UINT8, DT_UINT16, DT_QINT8}))
  153. .OP_END_FACTORY_REG(Relu)
  154. /**
  155. * @brief Computes rectified linear 6.
  156. * activations = min(max(x, 0), 6) . \n
  157. * @par Inputs:
  158. * x: A Tensor of type RealNumberType . \n
  159. * @par Outputs:
  160. * y: A Tensor with the same type as x . \n
  161. * @par Third-party framework compatibility
  162. * Compatible with the TensorFlow operator Relu6.
  163. */
  164. REG_OP(Relu6)
  165. .INPUT(x, TensorType::RealNumberType())
  166. .OUTPUT(y, TensorType::RealNumberType())
  167. .OP_END_FACTORY_REG(Relu6)
  168. /**
  169. * @brief Computes rectified linear 6*scale.
  170. * activations = min(max(x, 0), 6*scale) . \n
  171. * @par Inputs:
  172. * x: A Tensor of type RealNumberType . \n
  173. * @par Attributes:
  174. * epsilon: A required scalar. The data type is float32 . \n
  175. * @par Outputs:
  176. * y: A Tensor of type RealNumberType . \n
  177. * @par Third-party framework compatibility
  178. * Compatible with the TensorFlow operator Relu6.
  179. *
  180. *@par Restrictions:
  181. *Warning: THIS FUNCTION IS DEPRECATED. Please use Relu6 instead.
  182. */
  183. REG_OP(Relu6D)
  184. .INPUT(x, TensorType::RealNumberType())
  185. .OUTPUT(y, TensorType::RealNumberType())
  186. .ATTR(scale, Float, 1.0)
  187. .OP_END_FACTORY_REG(Relu6D)
  188. /**
  189. * @brief Computes rectified linear 6 gradients for a Relu6 operation.
  190. * backprops = gradients * (features > 0) * (features < 6) . \n
  191. * @par Inputs:
  192. * @li gradients: A Tensor of type RealNumberType. The backpropagated
  193. gradients to the corresponding Relu6 operation.
  194. * @li features: A Tensor with the same type as gradients.he features passed
  195. as input to the corresponding Relu6 operation, or its output;
  196. using either one produces the same result. \n
  197. * @par Outputs:
  198. * backprops: A Tensor of type RealNumberType . \n
  199. * @par Third-party framework compatibility
  200. * Compatible with the TensorFlow operator Relu6Grad.
  201. */
  202. REG_OP(Relu6Grad)
  203. .INPUT(gradients, TensorType::RealNumberType())
  204. .INPUT(features, TensorType::RealNumberType())
  205. .OUTPUT(backprops, TensorType::RealNumberType())
  206. .OP_END_FACTORY_REG(Relu6Grad)
  207. /**
  208. *@brief Calculate the elu_grad_v2 function.
  209. *Applies the element-wise function:
  210. * Computes the backward for the elu: if x>0, 1; otherwise elu() + alpha .
  211. *@par Inputs:
  212. *Two inputs, including:
  213. * @li grads: A tensor. Must be one of the following types:
  214. * float16, float32.
  215. * @li activations: A tensor. Must be one of the following types:
  216. * float16, float32.
  217. *
  218. *@par Outputs:
  219. *y: A Tensor with the same type and shape of grads's.
  220. *
  221. *@par Attributes:
  222. *alpha: scalar parameter, default value = 1.0
  223. */
  224. REG_OP(EluGradV2)
  225. .INPUT(grads, TensorType({DT_FLOAT, DT_FLOAT16}))
  226. .INPUT(activations, TensorType({DT_FLOAT, DT_FLOAT16}))
  227. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  228. .ATTR(alpha, Float, 1.0)
  229. .OP_END_FACTORY_REG(EluGradV2)
  230. /**
  231. * @brief Compute sigmoid of "x" element-wise . \n
  232. * @par Inputs:
  233. * A Tensor of type complex64, complex128, float16, float32 or double . \n
  234. * @par Outputs:
  235. * A Tensor. Has the same type as "x" . \n
  236. * @see Relu()
  237. * @par Third-party framework compatibility
  238. * Compatible with the TensorFlow operator Sigmoid.
  239. */
  240. REG_OP(Sigmoid)
  241. .INPUT(x, TensorType::UnaryDataType())
  242. .OUTPUT(y, TensorType::UnaryDataType())
  243. .OP_END_FACTORY_REG(Sigmoid)
  244. /**
  245. * @brief Computes z = (y - y*y)*dy . \n
  246. * @par Inputs:
  247. * @li y: The input is Tensor, dtype is UnaryDataType.
  248. * @li dy: The input is Tensor, dtype is UnaryDataType . \n
  249. * @par Outputs:
  250. * z: The shape of output, dtype is UnaryDataType.
  251. */
  252. REG_OP(SigmoidGrad)
  253. .INPUT(y, TensorType(UnaryDataType))
  254. .INPUT(dy, TensorType(UnaryDataType))
  255. .OUTPUT(z, TensorType(UnaryDataType))
  256. .OP_END_FACTORY_REG(SigmoidGrad)
  257. /**
  258. *@brief Computes the binomial normal log likelihood (BNLL) output:
  259. *if x>0, x+log(1+exp(-x)); otherwise log(1+exp(x)) . \n
  260. *@par Inputs:
  261. *x: A Tensor of type double, float16 or float32 . \n
  262. *@par Outputs:
  263. *y: A tensor. Has the same type and format as input "x" . \n
  264. *@par Third-party framework compatibility
  265. * Compatible with the Caffe operator BNLL.
  266. */
  267. REG_OP(BNLL)
  268. .INPUT(x, TensorType::FloatingDataType())
  269. .OUTPUT(y, TensorType::FloatingDataType())
  270. .OP_END_FACTORY_REG(BNLL)
  271. /**
  272. *@brief Computes softplus: log(exp(x) + 1) . \n
  273. *@par Inputs:
  274. * One input:
  275. *x: A Tensor of type float16 or float32. Up to 8D . \n
  276. *@par Outputs:
  277. *y: The activations tensor. Has the same type and format as input "x"
  278. *@par Third-party framework compatibility
  279. * Compatible with the TensorFlow operator Softplus.
  280. */
  281. REG_OP(Softplus)
  282. .INPUT(x, TensorType::FloatingDataType())
  283. .OUTPUT(y, TensorType::FloatingDataType())
  284. .OP_END_FACTORY_REG(Softplus)
  285. /**
  286. *@brief Computes softplus gradients for a softplus operation . \n
  287. *@par Inputs:
  288. *Two inputs:
  289. * @li gradients: An NC1HWC0 or ND Tensor of type float16 or float32.
  290. * @li features: An NC1HWC0 or ND Tensor of type float16 or float32.
  291. *@par Outputs:
  292. *backprops: A Tensor. Has the same type and format as input "gradients" . \n
  293. *@par Third-party framework compatibility
  294. * Compatible with the TensorFlow operator SoftplusGrad.
  295. */
  296. REG_OP(SoftplusGrad)
  297. .INPUT(gradients, TensorType::FloatingDataType())
  298. .INPUT(features, TensorType::FloatingDataType())
  299. .OUTPUT(backprops, TensorType::FloatingDataType())
  300. .OP_END_FACTORY_REG(SoftplusGrad)
  301. /**
  302. *@brief Computes softsign: x/(abs(x) + 1) . \n
  303. *@par Inputs:
  304. * One input:
  305. *x: A Tensor of type float16 or float32. Up to 8D . \n
  306. *@par Outputs:
  307. *y: The activations tensor. Has the same type and format as "x"
  308. *@par Third-party framework compatibility
  309. * Compatible with the TensorFlow operator Softsign.
  310. */
  311. REG_OP(Softsign)
  312. .INPUT(x, TensorType::FloatingDataType())
  313. .OUTPUT(y, TensorType::FloatingDataType())
  314. .OP_END_FACTORY_REG(Softsign)
  315. /**
  316. *@brief Computes scaled exponential linear: scale * alpha * (exp(x) - 1) . \n
  317. *@par Inputs:
  318. * One input:
  319. *x: A Tensor. Must be one of the following types: float16, float, double
  320. * int32, int8. format:ND, NC1HWC0 . \n
  321. *@par Outputs:
  322. *y: A Tensor. Has the same type and format as input "x". format:ND, NC1HWC0 . \n
  323. *@see Region()
  324. *@par Third-party framework compatibility
  325. * Compatible with the TensorFlow operator Selu.
  326. */
  327. REG_OP(Selu)
  328. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE,
  329. DT_INT8,DT_INT32}))
  330. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE,
  331. DT_INT8,DT_INT32}))
  332. .OP_END_FACTORY_REG(Selu)
  333. /**
  334. *@brief Computes rectified linear gradients for a ReLU operation . \n
  335. *@par Inputs:
  336. * Two inputs, including:
  337. *@li gradients: A Tensor. Must be one of the following types: float32, double,
  338. * int32, int8, int16, int64, uint16, float16, uint32, uint64
  339. *@li features: A Tensor. Must be one of the following types: float32, double,
  340. * int32, int8, int16, int64, uint16, float16, uint32, uint64
  341. *@par Outputs:
  342. *backprops: A Tensor. Must have the same type as"gradients" . \n
  343. *@attention Constraints:
  344. * The corresponding Relu operator needs to be called before using this operator on the network . \n
  345. *@see Relu
  346. *@par Third-party framework compatibility
  347. * Compatible with TensorFlow operator ReluGrad.
  348. */
  349. REG_OP(ReluGrad)
  350. .INPUT(gradients, TensorType::RealNumberType())
  351. .INPUT(features, TensorType::RealNumberType())
  352. .OUTPUT(backprops, TensorType::RealNumberType())
  353. .OP_END_FACTORY_REG(ReluGrad)
  354. /**
  355. *@brief Computes rectified linear gradients for a ReLU operation . \n
  356. *@par Inputs:
  357. * Two inputs, including:
  358. *@li gradients: A Tensor. Must be one of the following types: float32, double, int32, int8, int16, int8, int64, uint16, float16, uint32, uint64
  359. *@li mask: A Tensor. Must be the following types: uint8
  360. *@par Outputs:
  361. *backprops: A Tensor. Must have the same type as"gradients" . \n
  362. *@attention Constraints:
  363. * The corresponding Relu operator needs to be called before using this operator on the network . \n
  364. *@see Relu
  365. *@par Third-party framework compatibility
  366. * Compatible with TensorFlow operator ReluGradV2.
  367. */
  368. REG_OP(ReluGradV2)
  369. .INPUT(gradients, TensorType::RealNumberType())
  370. .INPUT(mask, TensorType({DT_UINT8}))
  371. .OUTPUT(backprops, TensorType::RealNumberType())
  372. .OP_END_FACTORY_REG(ReluGradV2)
  373. /**
  374. *@brief Computes rectified linear: "max(x, 0)".
  375. *
  376. *@attention Constraints:
  377. * The last dimension must be divisible by 8.
  378. * The second output "mask" is "1" (for y >= 0) or "0" ( for y < 0).
  379. *
  380. *@par Inputs:
  381. * x: A tensor. Must be one of the following types: float32, float64, int32, uint8,
  382. * int16, int8, int64, uint16, float16, qint8.
  383. *
  384. *@par Outputs:
  385. *@li y: A tensor. Has the same type as "x".
  386. *@li mask: A tensor of type uint8.
  387. *
  388. *@par Third-party framework compatibility
  389. * Incompatible with TensorFlow or Caffe.
  390. *
  391. */
  392. REG_OP(ReluV2)
  393. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT8, DT_INT32, DT_INT16, DT_INT64, DT_UINT8, DT_UINT16, DT_QINT8}))
  394. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT8, DT_INT32, DT_INT16, DT_INT64, DT_UINT8, DT_UINT16, DT_QINT8}))
  395. .OUTPUT(mask, TensorType({DT_UINT8}))
  396. .OP_END_FACTORY_REG(ReluV2)
  397. /**
  398. *@brief Performs parametric ReLU . \n
  399. *@par Inputs:
  400. * Two inputs, including:
  401. *@li x: A multi-dimensional Tensor of type float16 or float32.
  402. *@li weight: A Scalar or 1D Tensor of type float16 or float32, specifying the weight, the initial value of "a". The number of dimensions must be the same as the number of channels . \n
  403. *@par Outputs:
  404. *y: An activated Tensor. Has the same dimensions with "x" . \n
  405. *@par Third-party framework compatibility
  406. * Compatible with PyTorch and Caffe operator PReLU.
  407. */
  408. REG_OP(PRelu)
  409. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  410. .INPUT(weight, TensorType({DT_FLOAT, DT_FLOAT16}))
  411. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  412. .OP_END_FACTORY_REG(PRelu)
  413. /**
  414. *@brief Performs the backpropagation of PRelu for training scenarios . \n
  415. *@par Inputs:
  416. * Three inputs, including:
  417. *@li grads: Input gradient. Multi-dimensional Tensors are supported. The data type can be float16 or float32.
  418. *@li features: A multi-dimensional Tensor of type float16 or float32.
  419. *@li weights: A Scalar or 1D Tensor of type float16 or float32, specifying the weight. The number of dimensions must be the same as the number of channels . \n
  420. *@par Outputs:
  421. *@li dx: Reverse gradient of "features". Has the same dimensions and type as "features".
  422. *@li da: Reverse gradient of "weight". Has the same dimensions and type as "features" . \n
  423. *@par Third-party framework compatibility
  424. * Compatible with PyTorch operator PReluGrad.
  425. */
  426. REG_OP(PReluGrad)
  427. .INPUT(grads, TensorType({DT_FLOAT16, DT_FLOAT}))
  428. .INPUT(features, TensorType({DT_FLOAT16, DT_FLOAT}))
  429. .INPUT(weights, TensorType({DT_FLOAT16, DT_FLOAT}))
  430. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  431. .OUTPUT(da, TensorType({DT_FLOAT16, DT_FLOAT}))
  432. .OP_END_FACTORY_REG(PReluGrad)
  433. /**
  434. *@brief Activation function fused from sigmoid and ReLU, with soft saturation
  435. * on the left and no saturation on the right . \n
  436. *@par Inputs:
  437. *x: A float16, float32 or double, for the input data type . \n
  438. *@par Attributes:
  439. *alpha: A float32. Defines at which negative value the ELU saturates. Defaults to "1.0" . \n
  440. *@par Outputs:
  441. *y: A float16, float32 or double, for the normalized result . \n
  442. *@attention Constraints:
  443. *@li The input is of type float16 or float32 . \n
  444. *@par Multiple batches supported or not
  445. *Supported
  446. *@par Third-party framework compatibility
  447. *@li Compatible with Tensorflow's Elu operator
  448. *@li Compatible with Caffe's ELULayer operator
  449. *
  450. *@since V100R001C33
  451. */
  452. REG_OP(Elu)
  453. .INPUT(x, TensorType::FloatingDataType())
  454. .OUTPUT(y, TensorType::FloatingDataType())
  455. .ATTR(alpha, Float, 1.0)
  456. .OP_END_FACTORY_REG(Elu)
  457. /**
  458. *@brief Continuously Differentiable Exponential Linear Uints:
  459. * Perform the linear uint element-wise on the input tensor X using formula:
  460. * max(0, x) + min(0, alpha * (exp(x/alpha) - 1)). \n
  461. *@par Inputs:
  462. *x: A float16, float32, for the input data type . \n
  463. *@par Attributes:
  464. *@li alpha1: A float32. Defines at which negative value the ELU saturates. Defaults to "1.0" .
  465. *@li alpha2: A float32. Defines at which negative value the ELU saturates. Defaults to "1.0" .
  466. *@li alpha3: A float32. Defines at which positive value the ELU saturates. Defaults to "1.0" . \n
  467. *@par Outputs:
  468. *y: A float16, float32, for the normalized result . \n
  469. *@attention Constraints:
  470. *@li The input is of type float16 or float32 . \n
  471. *@par Multiple batches supported or not
  472. *Supported
  473. *@par Third-party framework compatibility
  474. *@li Compatible with ONNX's Celu operator
  475. */
  476. REG_OP(Celu)
  477. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  478. .OUTPUT(y, TensorType({DT_FLOAT,DT_FLOAT16}))
  479. .ATTR(alpha1, Float, 1.0)
  480. .ATTR(alpha2, Float, 1.0)
  481. .ATTR(alpha3, Float, 1.0)
  482. .OP_END_FACTORY_REG(Celu)
  483. /**
  484. *@brief Computes gradients for the exponential linear (Elu) operation.
  485. *
  486. *@par Inputs:
  487. *@li grads: A tensor. Must be one of the following types: float16, float32, float64.
  488. * The backpropagated gradients to the corresponding Elu operation.
  489. *@li activations: A tensor. Has the same type as "grads".
  490. * The outputs of the corresponding Elu operation.
  491. *
  492. *@par Outputs:
  493. * y: A tensor. Has the same type as "grads".
  494. *
  495. *@par Third-party framework compatibility
  496. *Compatible with the TensorFlow operator EluGrad.
  497. *
  498. */
  499. REG_OP(EluGrad)
  500. .INPUT(grads, TensorType::FloatingDataType())
  501. .INPUT(activations, TensorType::FloatingDataType())
  502. .OUTPUT(y, TensorType::FloatingDataType())
  503. .OP_END_FACTORY_REG(EluGrad)
  504. /**
  505. *@brief Computes the output as x if x > 0 and negative_slope * x if x <= 0 . \n
  506. *@par Inputs:
  507. * One input:
  508. * x: A Tensor. Must be one of the following types: float32, float16, double.
  509. *
  510. *@par Attributes:
  511. *negative_slope: A float32. Defaults to "0.0".
  512. *
  513. *@par Outputs:
  514. *y: A Tensor. Has the same type as "x".
  515. *@par Third-party framework compatibility
  516. * Compatible with the Caffe operator ReLU.
  517. */
  518. REG_OP(LeakyRelu)
  519. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE}))
  520. .ATTR(negative_slope, Float, 0.0)
  521. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE}))
  522. .OP_END_FACTORY_REG(LeakyRelu)
  523. /**
  524. *@brief Computes the output as gradients if features > 0 and negative_slope * gradients if features <= 0 . \n
  525. *@par Inputs:
  526. * Two inputs, including:
  527. * @li gradients: A Tensor. Must be one of the following types: float16, float32, double.
  528. * @li features: A Tensor. Has the same type as "gradients" . \n
  529. *@par Attributes:
  530. *negative_slope: A float32. Defaults to "0.0" . \n
  531. *@par Outputs:
  532. *backprops: A Tensor. Has the same type as "gradients" . \n
  533. *@par Third-party framework compatibility
  534. * Compatible with the TensorFlow operator LeakyReluGrad.
  535. */
  536. REG_OP(LeakyReluGrad)
  537. .INPUT(gradients, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  538. .INPUT(features, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  539. .ATTR(negative_slope, Float, 0.0)
  540. .OUTPUT(backprops, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  541. .OP_END_FACTORY_REG(LeakyReluGrad)
  542. /**
  543. *@brief Thresholds grad each element of the input Tensor . \n
  544. *@par Inputs:
  545. * @li gradients: A Tensor shape and dtype of input gradients. Support float16, int32.
  546. * @li features: A Tensor shape and dtype of input features. Support float16, int32 . \n
  547. *@par Attributes:
  548. *threshold: A float32 scale value to threshold at . \n
  549. *@par Outputs:
  550. *backprops: A Tensor of shape and dtype of output backprops, should be same shape and type as inputs . \n
  551. *@par Restrictions:
  552. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  553. */
  554. REG_OP(ThresholdGradV2D)
  555. .INPUT(gradients, TensorType({DT_INT32, DT_FLOAT16}))
  556. .INPUT(features, TensorType({DT_INT32, DT_FLOAT16}))
  557. .OUTPUT(backprops, TensorType({DT_INT32, DT_FLOAT16}))
  558. .REQUIRED_ATTR(threshold, Float)
  559. .OP_END_FACTORY_REG(ThresholdGradV2D)
  560. /**
  561. *@brief Thresholds each element of the input Tensor y = (x > threshold) ? x : value . \n
  562. *@par Inputs:
  563. *x: A Tensor dtype of real number . \n
  564. *@par Attributes:
  565. *@li threshold: A float32 scale value to threshold at.
  566. *@li value: A float32 scale value to replace with . \n
  567. *@par Outputs:
  568. *y: A Tensor of shape and dtype of output, should be same shape and type as input . \n
  569. *@par Restrictions:
  570. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  571. */
  572. REG_OP(ThresholdV2D)
  573. .INPUT(x, TensorType::RealNumberType())
  574. .OUTPUT(y, TensorType::RealNumberType())
  575. .REQUIRED_ATTR(threshold, Float)
  576. .REQUIRED_ATTR(value, Float)
  577. .OP_END_FACTORY_REG(ThresholdV2D)
  578. /**
  579. *@brief: Computes hyperbolic tangent of "x" element-wise . \n
  580. *@par Inputs:
  581. *One input:
  582. *x: A Tensor. Must be one of the following types: float16, float32 . \n
  583. *@par Outputs:
  584. *y: A Tensor. Has the same type as "x" . \n
  585. *@par Third-party framework compatibility
  586. * Compatible with TensorFlow operator Mish.
  587. */
  588. REG_OP(Mish)
  589. .INPUT(x, TensorType({ DT_FLOAT,DT_FLOAT16 }))
  590. .OUTPUT(y, TensorType({ DT_FLOAT,DT_FLOAT16 }))
  591. .OP_END_FACTORY_REG(Mish)
  592. /**
  593. * @brief: pytorch mish_grad operator.
  594. * @par Inputs:
  595. * three input, including:
  596. * @li grad: A Tensor. shape, datatype and format is same as x
  597. * @li x: A Tensor. Must be one of the following types: float16, float32
  598. * @li tanhx: A Tensor. shape, datatype and format is same as x
  599. * @par Outputs:
  600. * One output, including:
  601. * x_grad: A Tensor. shape, datatype and format is same as x
  602. */
  603. REG_OP(MishGrad)
  604. .INPUT(grad, TensorType({ DT_FLOAT,DT_FLOAT16 }))
  605. .INPUT(x, TensorType({ DT_FLOAT,DT_FLOAT16 }))
  606. .OPTIONAL_INPUT(tanhx, TensorType({ DT_FLOAT,DT_FLOAT16 }))
  607. .OUTPUT(x_grad, TensorType({ DT_FLOAT,DT_FLOAT16 }))
  608. .OP_END_FACTORY_REG(MishGrad)
  609. /**
  610. * @brief pytorch hardtanh_backward operator.
  611. *
  612. * @par Inputs:
  613. * Two inputs, including:
  614. * @li result, minimum tensor of the linear region range,
  615. * datatype: float16/float32, format:ND/5HD.
  616. * @li grad, maximum tensor of the linear region range,
  617. * datatype:float16/float32, format:ND/5HD. \n
  618. * @par Attributes:
  619. * Two attributes, including:
  620. * @li min_val, minimum value of the linear region range, datatype:float.
  621. * @li max_val, maximum value of the linear region range, datatype:float. \n
  622. * @par Outputs:
  623. * One output, including:
  624. * y, hardtanh_backward output tensor, datatype and format is same as
  625. * input result. \n
  626. * @attention Constraints:
  627. * This operator only supports dataType: float16/float32, format: ND/5HD. \n
  628. * @par Third-party framework compatibility
  629. * Compatible with the Pytorch operator HardtanhGrad.
  630. */
  631. REG_OP(HardtanhGrad)
  632. .INPUT(result, TensorType({ DT_FLOAT16, DT_FLOAT })) /* "First operand." */
  633. .INPUT(grad, TensorType({ DT_FLOAT16, DT_FLOAT })) /* "Second operand." */
  634. .OUTPUT(y, TensorType({ DT_FLOAT16, DT_FLOAT })) /* "Result, has same element type as two inputs" */
  635. .ATTR(min_val, Float, -1.0)
  636. .ATTR(max_val, Float, 1.0)
  637. .OP_END_FACTORY_REG(HardtanhGrad)
  638. /**
  639. * @brief Calculates the softplus loss function with attributes of beta and threshold. \n
  640. * @par Inputs:
  641. * One inputs, including:
  642. * x: A mutable Tensor. Must be one of the following types:
  643. * float16, float32. \n
  644. * @par Attributes:
  645. * @li beta: An optional float. Defaults to "1.0" \n
  646. * @li threshold: An optional float. Defaults to "20.0" \n
  647. * @par Outputs:
  648. * y: A mutable Tensor. Has the same type as "x" \n
  649. * @par Third-party framework compatibility
  650. * Compatible with the Pytorch operator Softplus.
  651. */
  652. REG_OP(SoftplusV2)
  653. .INPUT(x, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  654. .OUTPUT(y, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  655. .ATTR(beta, Float, 1.0)
  656. .ATTR(threshold, Float, 20.0)
  657. .OP_END_FACTORY_REG(SoftplusV2)
  658. /**
  659. * @brief Calculates the reversed outputs of the function "softplus_v2". \n
  660. * @par Inputs:
  661. * Two inputs, including:
  662. * @li input_gradients: A mutable Tensor. Must be one of the following types:
  663. * float16, float32.
  664. * @li input_features: A mutable Tensor of the same type as "input_gradients" \n
  665. * @par Attributes:
  666. * @li beta: An optional float. Defaults to "1.0" \n
  667. * @li threshold: An optional float. Defaults to "20.0" \n
  668. * @par Outputs:
  669. * output_backprops: A mutable Tensor. Has the same type as "input_gradients" \n
  670. * @par Third-party framework compatibility
  671. * Compatible with the Pytorch operator SoftplusGrad.
  672. */
  673. REG_OP(SoftplusV2Grad)
  674. .INPUT(input_gradients, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  675. .INPUT(input_features, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  676. .OUTPUT(output_backprops, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  677. .ATTR(beta, Float, 1.0)
  678. .ATTR(threshold, Float, 20.0)
  679. .OP_END_FACTORY_REG(SoftplusV2Grad)
  680. /**
  681. * @brief ThresholdedRelu takes one input data (Tensor) and produces one output data (Tensor)
  682. * where the rectified linear function, y = x for x > alpha, y = 0 otherwise, is applied to the tensor elementwise.
  683. *
  684. * @par Inputs:
  685. * one input including:
  686. * x: input A Tensor. Must be one of the following types: float32, float16
  687. *
  688. * @par Attributes:
  689. * alpha: An optional float. Defaults to 1.0. \n
  690. * @par Outputs:
  691. * one output including:
  692. * y:A Tensor of the same type as x
  693. *
  694. */
  695. REG_OP(ThresholdedRelu)
  696. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  697. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  698. .ATTR(alpha, Float, 1.0)
  699. .OP_END_FACTORY_REG(ThresholdedRelu)
  700. /**
  701. * @brief Calculate the hard shrinkage function. \n
  702. * @par Inputs:
  703. * One inputs, including:
  704. * input_x: A tensor. Must be one of the following types:
  705. * float16, float32. \n
  706. * @par Attributes:
  707. * lambd: An optional float. Defaults to 0.5. \n
  708. * @par Outputs:
  709. * output_y: A Tensor with the same dtype and shape of input_x's. \n
  710. * @par Third-party framework compatibility
  711. * Compatible with the Pytorch operator Hardshrink. \n
  712. */
  713. REG_OP(HardShrink)
  714. .INPUT(input_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  715. .OUTPUT(output_y, TensorType({DT_FLOAT16, DT_FLOAT}))
  716. .ATTR(lambd, Float, 0.5)
  717. .OP_END_FACTORY_REG(HardShrink)
  718. /**
  719. *@brief Calculate the hard shrink grad function. \n
  720. *
  721. * Computes the gradient for the HardShrink: if x > lambda or x < -lambda, x,otherwise 0
  722. *
  723. *@par Inputs:
  724. *Two inputs, including:
  725. * @li gradients: A tensor. Must be one of the following types:
  726. * float16, float32. \n
  727. * @li features: A tensor. Must be one of the following types:
  728. * float16, float32. \n
  729. *
  730. *@par Outputs:
  731. *backprops: A Tensor with the same type and shape of features's. \n
  732. *
  733. *@par Attributes:
  734. *lambd: An optional float.Defaults to 0.5. \n
  735. *
  736. *@par Third-party framework compatibility
  737. *Compatible with the Pytorch operator Hardshrink_backward. \n
  738. */
  739. REG_OP(HardShrinkGrad)
  740. .INPUT(gradients, TensorType({DT_FLOAT16, DT_FLOAT}))
  741. .INPUT(features, TensorType({DT_FLOAT16, DT_FLOAT}))
  742. .OUTPUT(backprops, TensorType({DT_FLOAT16, DT_FLOAT}))
  743. .ATTR(lambd, Float, 0.5)
  744. .OP_END_FACTORY_REG(HardShrinkGrad)
  745. /**
  746. * @brief Calculate the hard sigmoid function. \n
  747. * @par Inputs:
  748. * One inputs, including:
  749. * input_x: A tensor. Must be one of the following types:
  750. * float16, float32, int32. \n
  751. * @par Attributes:
  752. * @li alpha: An optional float. Defaults to 0.16666666. \n
  753. * @li beta: An optional float. Defaults to 0.5. \n
  754. * @par Outputs:
  755. * y: A Tensor with the same dtype and shape of input_x's. \n
  756. * @par Third-party framework compatibility
  757. * Compatible with the Pytorch operator Hardsigmoid. \n
  758. */
  759. REG_OP(HardSigmoid)
  760. .INPUT(input_x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  761. .OUTPUT(output_y, TensorType({DT_FLOAT, DT_FLOAT16}))
  762. .ATTR(alpha, Float, 0.16666666)
  763. .ATTR(beta, Float, 0.5)
  764. .OP_END_FACTORY_REG(HardSigmoid)
  765. /**
  766. * @brief Calculate the soft shrinkage function. \n
  767. * @par Inputs:
  768. * One inputs, including:
  769. * input_x: A tensor. Must be one of the following types:
  770. * float16, float32. \n
  771. * @par Attributes:
  772. * lambd: An optional float. Defaults to 0.5. \n
  773. * @par Outputs:
  774. * y: A Tensor with the same dtype and shape of input_x's. \n
  775. * @par Third-party framework compatibility
  776. * Compatible with the Pytorch operator Softshrink. \n
  777. */
  778. REG_OP(SoftShrink)
  779. .INPUT(input_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  780. .OUTPUT(output_y, TensorType({DT_FLOAT16, DT_FLOAT}))
  781. .ATTR(lambd, Float, 0.5)
  782. .OP_END_FACTORY_REG(SoftShrink)
  783. /**
  784. * @brief Calculate the reversed outputs of the function "soft_shrink". \n
  785. * @par Inputs:
  786. * Two inputs, including:
  787. * @li input_grad: A tensor. Must be one of the following types:
  788. * float16, float32. \n
  789. * @li input_x: A tensor of the same dtype as "input_grad". \n
  790. * @par Attributes:
  791. * lambd: An optional float. Defaults to 0.5. \n
  792. * @par Outputs:
  793. * y: A Tensor of the same dtype and shape as "input_graxd". \n
  794. * @par Third-party framework compatibility
  795. * Compatible with the Pytorch operator SoftShrinkGrad. \n
  796. */
  797. REG_OP(SoftShrinkGrad)
  798. .INPUT(input_grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  799. .INPUT(input_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  800. .OUTPUT(output_y, TensorType({DT_FLOAT16, DT_FLOAT}))
  801. .ATTR(lambd, Float, 0.5)
  802. .OP_END_FACTORY_REG(SoftShrinkGrad)
  803. /**
  804. *@brief Calculate the gradient of log simoid. \n
  805. *@par Inputs:
  806. *Two inputs, including:
  807. * @li grads: A tensor, gradient of previous layer. Must be one of the following types:
  808. * float16, float32. \n
  809. * @li features: A tensor, input of log sigmoid. Must be one of the following types:
  810. * float16, float32. \n
  811. *@par Outputs:
  812. *One outputs, including:
  813. * @li backprops: A tensor with the same type of and shape of grads. \n
  814. *@par Third-party framework compatibility
  815. *Compatible with the Pytorch operator LogSigmoidBackward. \n
  816. */
  817. REG_OP(LogSigmoidGrad)
  818. .INPUT(grads, TensorType({DT_FLOAT16, DT_FLOAT}))
  819. .INPUT(features, TensorType({DT_FLOAT16, DT_FLOAT}))
  820. .OUTPUT(backprops, TensorType({DT_FLOAT16, DT_FLOAT}))
  821. .OP_END_FACTORY_REG(LogSigmoidGrad)
  822. /**
  823. *@brief Calculate -ln(1+e^(-x)). \n
  824. *@par Inputs:
  825. *One inputs, including:
  826. * x: A tensor. Must be one of the following types:
  827. * float16, float32. \n
  828. *@par Outputs:
  829. *One outputs, including:
  830. * y: A tensor with the same type and shape of x's. \n
  831. *@par Third-party framework compatibility
  832. *Compatible with the Pytorch operator LogSigmoid. \n
  833. */
  834. REG_OP(LogSigmoid)
  835. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) /* "input:x" */
  836. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT})) /* "output:y" */
  837. .OP_END_FACTORY_REG(LogSigmoid)
  838. /**
  839. *@brief Calculate the backward outputs of the function "hard_sigmoid" \n
  840. *@par Inputs:
  841. *One inputs, including:
  842. * @li grads: A tensor. Must be one of the following types:
  843. * float16, float32. \n
  844. * @li input_x: A tensor. Must be one of the following types:
  845. * float16, float32. \n
  846. *@par Outputs:
  847. *One outputs, including:
  848. * y: A tensor with the same type and shape of x's. \n
  849. * @par Attributes:
  850. * @li alpha: An optional float. Defaults to 0.16666666. \n
  851. * @li beta: An optional float. Defaults to 0.5. \n
  852. *@par Third-party framework compatibility
  853. *Compatible with the Pytorch operator LogSigmoidGrad. \n
  854. */
  855. REG_OP(HardSigmoidGrad)
  856. .INPUT(grads, TensorType({DT_FLOAT, DT_FLOAT16}))
  857. .INPUT(input_x, TensorType({DT_FLOAT, DT_FLOAT16}))
  858. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  859. .ATTR(alpha, Float, 0.16666666)
  860. .ATTR(beta, Float, 0.5)
  861. .OP_END_FACTORY_REG(HardSigmoidGrad)
  862. /**
  863. * @brief Calculate the shrink function. \n
  864. * @par Inputs:
  865. * One inputs, including:
  866. * @li input_x: A tensor. Must be one of the following types:
  867. * float16, float32. \n
  868. * @par Attributes:
  869. * @li lambd: An optional float. Defaults to 0.5. \n
  870. * @li bias: An optional float. Defaults to 0.0. \n
  871. * @par Outputs:
  872. * y: A Tensor with the same dtype and shape of input_x's. \n
  873. * @par Third-party framework compatibility
  874. * Compatible with the ONNX operator Shrink. \n
  875. */
  876. REG_OP(Shrink)
  877. .INPUT(input_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  878. .OUTPUT(output_y, TensorType({DT_FLOAT16, DT_FLOAT}))
  879. .ATTR(lambd, Float, 0.5)
  880. .ATTR(bias, Float, 0.0)
  881. .OP_END_FACTORY_REG(Shrink)
  882. } // namespace ge
  883. #endif // OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_

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