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.

nn_calculation_ops.h 75 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
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
3 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
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
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 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
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
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  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 nn_calculation_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. * @brief Computes the gradients of depthwise convolution with respect to
  26. * the filter. \n
  27. * @par Inputs:
  28. * Three inputs include:
  29. * @li input: 4D origin shape of input tensor [N, C, H, W] or [N, H, W, C],
  30. * support float16.
  31. * @li filter_size: A 4D tensor of type int32, int64, with shape [H, W, C, K]
  32. * @li out_backprop: 4D tensor with shape [N, C, H, W] or [N, H, W, C].
  33. * Must be one of the following types: float16. \n
  34. * @par Attributes:
  35. * @li strides: A required list or tuple. The stride of the sliding window
  36. * for height and width of input "x" of the convolution.
  37. * Must be with shape [1, 1, stride_height, stride_width] or
  38. * [1, stride_height, stride_width, 1].
  39. * @li dilations: An optional list or tuple. The dilation factor for each
  40. * dimension of input "x".
  41. * If set to k > 1, there will be k-1 skipped cells between each filter element
  42. * on that dimension. Must be with shape [1, 1, dilation_height, dilation_width]
  43. * or [1, dilation_height, dilation_width, 1].
  44. * @li pads: A required list or tuple. Padding added to each dimension of the
  45. * input.
  46. * @li data_format: An optional string. Input data format, either "NHWC" or
  47. * "NCHW". \n
  48. * @par Outputs:
  49. * filter_grad: Gradient of the deep convolution relative to the filter with
  50. * shape [H, W, C, K]. Must be one of the following types: float16. \n
  51. * @attention Constraints:\n
  52. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  53. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  54. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  55. * [C1, Hf, Wf, K, Co, C0],
  56. * where K is fixed at 1, and Co and C0 are 16.\n
  57. * Output backprop is 4D with shape [N, C, Ho, Wo] or [N, Ho, Wo, C], but the
  58. * data is 5D with shape [N, C1, Ho, Wo, C0],
  59. * where C is the same as that of the feature map and C0 is 16.\n
  60. * Limited by Tiling and L1 / L0 buffer memory: 512 * ceil(Wo, 16) +
  61. * (480 * stride_h + 32 * filter_h) * ceil(Wi, 16) <= l1_size and Hf*Wf
  62. * <= l0b_size/512. \n
  63. * @par Third-party framework compatibility
  64. * @li Compatible with the TensorFlow operator DepthwiseConv2DBackpropFilter.
  65. * @li Compatible with the Caffe operator DepthwiseConv2DBackpropFilter.
  66. */
  67. REG_OP(DepthwiseConv2DBackpropFilter)
  68. .INPUT(input, TensorType({float16}))
  69. .INPUT(filter_size, TensorType({DT_INT32, DT_INT64}))
  70. .INPUT(out_backprop, TensorType({float16}))
  71. .OUTPUT(filter_grad, TensorType({float32}))
  72. .REQUIRED_ATTR(strides, ListInt)
  73. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  74. .REQUIRED_ATTR(pads, ListInt)
  75. .ATTR(data_format, String, "NHWC")
  76. .OP_END_FACTORY_REG(DepthwiseConv2DBackpropFilter)
  77. /**
  78. * @brief Computes the gradients of depthwise convolution with respect to
  79. * the filter . \n
  80. * @par Inputs:
  81. * Two inputs include: \n
  82. * @li input: 4D tensor with shape [N, C, H, W] or [N, H, W, C], of type float16
  83. * @li out_backprop: 4D tensor with shape [N, C, H, W] or [N, H, W, C],
  84. * of type float16
  85. * @par Attributes:
  86. * @li filter_size: A required list or tuple. Shape of filter.
  87. * @li strides: A required list or tuple. The stride of the sliding window for
  88. * height and width of input "x" of the convolution.
  89. * Must be with shape [1, 1, stride_height, stride_width] or [1, stride_height,
  90. * stride_width, 1].
  91. * @li dilations: An optional list or tuple. The dilation factor for each
  92. * dimension of input "x".
  93. * If set to k > 1, there will be k-1 skipped cells between each filter element
  94. * on that dimension. Must be with shape [1, 1, dilation_height, dilation_width]
  95. * or [1, dilation_height, dilation_width, 1].
  96. * @li pads: A required list or tuple. Padding added to each dimension of the
  97. * input.
  98. * @li data_format: An optional string. Input data format, either "NHWC" or
  99. * "NCHW" . \n
  100. * @par Outputs:
  101. * filter_grad: Gradient of the deep convolution relative to the filter with
  102. * shape [H, W, C, K]. Must be of type float32 . \n
  103. * @attention Constraints:\n
  104. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  105. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  106. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  107. * [C1, Hf, Wf, K, Co, C0],
  108. * where K is fixed at 1, and Co and C0 are 16.\n
  109. * Output backprop is 4D with shape [N, C, Ho, Wo] or [N, Ho, Wo, C], but the
  110. * data is 5D with shape [N, C1, Ho, Wo, C0],
  111. * where C is the same as that of the feature map and C0 is 16.\n
  112. * Limited by Tiling and L1 / L0 buffer memory: 512 * ceil(Wo, 16) + (480 *
  113. * stride_h + 32 * filter_h) * ceil(Wi, 16) <= l1_size and Hf*Wf <= l0b_size/512 . \n
  114. * @par Third-party framework compatibility
  115. * @li Compatible with the TensorFlow operator DepthwiseConv2DBackpropFilter.
  116. * @li Compatible with the Caffe operator DepthwiseConv2DBackpropFilter.
  117. *
  118. * @par Restrictions:
  119. * Warning: THIS FUNCTION IS DEPRECATED. Please use DepthwiseConv2DBackpropFilter
  120. * instead.
  121. */
  122. REG_OP(DepthwiseConv2DBackpropFilterD)
  123. .INPUT(input, TensorType({DT_FLOAT16, DT_FLOAT32, DT_BF16}))
  124. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT32, DT_BF16}))
  125. .OUTPUT(filter_grad, TensorType({DT_FLOAT32}))
  126. .REQUIRED_ATTR(filter_size, ListInt)
  127. .REQUIRED_ATTR(strides, ListInt)
  128. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  129. .REQUIRED_ATTR(pads, ListInt)
  130. .ATTR(data_format, String, "NHWC")
  131. .OP_END_FACTORY_REG(DepthwiseConv2DBackpropFilterD)
  132. /**
  133. * @brief Computes the gradients of depthwise convolution with respect to the
  134. * input. \n
  135. * @par Inputs:
  136. * Three inputs include: \n
  137. * @li input_size: 4D shape of input tensor [N, C, H, W] or [N, H, W, C],
  138. * support int32, int64.
  139. * @li filter: 4D filter tensor with shape of [H, W, C, K], support float16.
  140. * @li out_backprop: 4D tensor with shape [N, C, H, W] or [N, H, W, C].
  141. * Must be one of the following types: float16 . \n
  142. * @par Attributes:
  143. * @li strides: A required list or tuple of int32. The stride of the sliding
  144. * window for height and width of input "x" of the convolution.
  145. * Must be with shape [1, 1, stride_height, stride_width] or [1, stride_height,
  146. * stride_width, 1].
  147. * @li dilations: An optional list or tuple of int32. The dilation factor for
  148. * each dimension of input "x". Defaults to "[1, 1, 1, 1]".
  149. * If set to k > 1, there will be k-1 skipped cells between each filter element
  150. * on that dimension. Must be with shape [1, 1, dilation_height, dilation_width]
  151. * or [1, dilation_height, dilation_width, 1].
  152. * @li pads: A required list or tuple of int32. Padding added to each dimension
  153. * of the input.
  154. * @li data_format: An optional string. Input data format, either "NHWC" or
  155. * "NCHW". Defaults to "NHWC" . \n
  156. * @par Outputs:
  157. * input_grad: Gradient of the deep convolution relative to the input with shape
  158. * [N, C, H, W] or [N, H, W, C] Must be one of the following types:
  159. * float16, float32. \n
  160. * @attention Constraints:\n
  161. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  162. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  163. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  164. * [C1, Hf, Wf, K, Co, C0],
  165. * where K is fixed at 1, and Co and C0 are 16.\n
  166. * Output backprop is 4D with shape [N, C, Ho, Wo] or [N, Ho, Wo, C], but the
  167. * data is 5D with shape [N, C1, Ho, Wo, C0],
  168. * where C is the same as that of the feature map and C0 is 16.\n
  169. * Limited by Tiling: max_h_in_l1 >= C0, where max_h_in_l1 = (l1_size - Hf *
  170. * Wf * C0 * C0 * 2) / (2 * Wo *C0).\n
  171. * @par Third-party framework compatibility
  172. * @li Compatible with the TensorFlow operator DepthwiseConv2DBackpropInput.
  173. * @li Compatible with the Caffe operator DepthwiseConv2DBackpropInput.
  174. */
  175. REG_OP(DepthwiseConv2DBackpropInput)
  176. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  177. .INPUT(filter, TensorType({DT_FLOAT16}))
  178. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  179. .OUTPUT(input_grad, TensorType({DT_FLOAT16, DT_FLOAT32}))
  180. .REQUIRED_ATTR(strides, ListInt)
  181. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  182. .REQUIRED_ATTR(pads, ListInt)
  183. .ATTR(data_format, String, "NHWC")
  184. .OP_END_FACTORY_REG(DepthwiseConv2DBackpropInput)
  185. /**
  186. * @brief Computes the gradients of depthwise convolution with respect to the
  187. * input . \n
  188. * @par Inputs:
  189. * Two inputs include: \n
  190. * @li filter: A 4D tensor of type float16, with shape [H, W, C, K]
  191. * @li out_backprop: 4D tensor with shape [N, C, H, W] or [N, H, W, C], of
  192. * type float16
  193. * @par Attributes:
  194. * @li input_size: A required list or tuple. The origin shape of input.
  195. * @li strides: A required list or tuple. The stride of the sliding window for
  196. * height and width of input "x" of the convolution.
  197. * Must be with shape [1, 1, stride_height, stride_width] or [1, stride_height,
  198. * stride_width, 1].
  199. * @li dilations: An optional list or tuple. The dilation factor for each
  200. * dimension of input "x".
  201. * If set to k > 1, there will be k-1 skipped cells between each filter element
  202. * on that dimension. Must be with shape [1, 1, dilation_height, dilation_width]
  203. * or [1, dilation_height, dilation_width, 1].
  204. * @li pads: A required list or tuple. Padding added to each dimension of the
  205. * input.
  206. * @li data_format: An optional string. Input data format, either "NHWC" or
  207. * "NCHW" . \n
  208. * @par Outputs:
  209. * input_grad: Gradient of the deep convolution relative to the input with
  210. * shape [N, C, H, W] or [N, H, W, C]. Must be of type float16 . \n
  211. * @attention Constraints:\n
  212. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  213. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  214. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  215. * [C1, Hf, Wf, K, Co, C0],
  216. * where K is fixed at 1, and Co and C0 are 16.\n
  217. * Output backprop is 4D with shape [N, C, Ho, Wo] or [N, Ho, Wo, C], but the
  218. * data is 5D with shape [N, C1, Ho, Wo, C0],
  219. * where C is the same as that of the feature map and C0 is 16.\n
  220. * Limited by Tiling: max_h_in_l1 >= C0, where max_h_in_l1 = (l1_size - Hf *
  221. * Wf * C0 * C0 * 2) / (2 * Wo *C0).\n
  222. * @par Third-party framework compatibility
  223. * @li Compatible with the TensorFlow operator DepthwiseConv2DBackpropInput.
  224. * @li Compatible with the Caffe operator DepthwiseConv2DBackpropInput.
  225. *
  226. * @par Restrictions:
  227. * Warning: THIS FUNCTION IS DEPRECATED. Please use DepthwiseConv2DBackpropInput
  228. * instead.
  229. */
  230. REG_OP(DepthwiseConv2DBackpropInputD)
  231. .INPUT(filter, TensorType({DT_FLOAT16}))
  232. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  233. .OUTPUT(input_grad, TensorType({DT_FLOAT16, DT_FLOAT32}))
  234. .REQUIRED_ATTR(input_size, ListInt)
  235. .REQUIRED_ATTR(strides, ListInt)
  236. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  237. .REQUIRED_ATTR(pads, ListInt)
  238. .ATTR(data_format, String, "NHWC")
  239. .OP_END_FACTORY_REG(DepthwiseConv2DBackpropInputD)
  240. /**
  241. *@brief Computes a 2D deep convolution given a 4D input tensor and a filter
  242. * tensor . \n
  243. *@par Inputs:
  244. *Two required inputs and two optional inputs, including: \n
  245. * @li x: A 4D tensor of type float16 or int8 or int4, with shape [N, C, H, W] or [N, H, W, C]
  246. * @li filter: A 4D tensor of type float16 or int8 or int4, with shape [H, W, C, K]
  247. * @li bias: An optional tensor of type float16 or int32
  248. * @li offset_w: An optional float16 or int8 or int4, used for quantized inference
  249. * @par Attributes:
  250. * @li strides: A required list or tuple. The stride of the sliding window for
  251. * height and width of input "x" of the convolution.
  252. * Must be with shape [1, 1, stride_height, stride_width] or [1, stride_height,
  253. * stride_width, 1].
  254. * @li dilations: An optional list or tuple. The dilation factor for each
  255. * dimension of input "x".
  256. * If set to k > 1, there will be k-1 skipped cells between each filter element
  257. * on that dimension. Must be with shape [1, 1, dilation_height, dilation_width]
  258. * or [1, dilation_height, dilation_width, 1]. Defaults to "[1, 1, 1, 1]".
  259. * @li pads: A required list or tuple of int32. Padding added to each dimension of the
  260. * input.
  261. * @li data_format: An optional string. Input data format, either "NHWC" or
  262. * "NCHW". Defaults to "NHWC".
  263. * @li offset_x: An optional int. Input offset, used for quantized inference.
  264. * Defaults to 0 . \n
  265. * @par Outputs:
  266. * y: 4D tensor of type float16 or int32, with shape [N, C, H, W] or [N, H, W, C]
  267. * @attention Constraints:\n
  268. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  269. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  270. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  271. * [C1, Hf, Wf, K, Co, C0],
  272. * where K is fixed at 1, and Co and C0 are 16.\n
  273. * Limited by the size of L1 buffer memory: \n
  274. * (l1_size - filter_h*filter_w*BLOCK_SIZE*BLOCK_SIZE*data_size) // (Wi *
  275. * BLOCK_SIZE * data_size) >= (BLOCK_SIZE * strides_h + filter_h - strides_h).\n
  276. * @par Quantization supported or not
  277. * Yes
  278. * @par Third-party framework compatibility
  279. * @li Compatible with the TensorFlow operator DepthwiseConv2D.
  280. * @li Compatible with the Caffe operator DepthwiseConv2D.
  281. */
  282. REG_OP(DepthwiseConv2D)
  283. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8, DT_INT4}))
  284. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8, DT_INT4}))
  285. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT}))
  286. .OPTIONAL_INPUT(offset_w, TensorType({DT_FLOAT16, DT_INT8, DT_INT4}))
  287. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT}))
  288. .REQUIRED_ATTR(strides, ListInt)
  289. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  290. .REQUIRED_ATTR(pads, ListInt)
  291. .ATTR(data_format, String, "NHWC")
  292. .ATTR(offset_x, Int, 0)
  293. .OP_END_FACTORY_REG(DepthwiseConv2D)
  294. /**
  295. *@brief Performs the the backward operation for "BiasAdd" on the "bias" tensor.
  296. * It accumulates all the values from out_backprop into the feature
  297. * dimension. For NHWC data format, the feature dimension is the last.
  298. * For NCHW data format, the feature dimension is the third-to-last . \n
  299. *@par Inputs:
  300. * x: A Tensor of type NumberType . \n
  301. *@par Attributes:
  302. * data_format: Data format. Defaults to "NHWC" . \n
  303. *@par Outputs:
  304. * y: A Tensor.Has the same type as "x" . \n
  305. *@par Third-party framework compatibility
  306. * Compatible with the TensorFlow operator BiasAddGrad.
  307. */
  308. REG_OP(BiasAddGrad)
  309. .INPUT(x, TensorType::NumberType())
  310. .OUTPUT(y, TensorType::NumberType())
  311. .ATTR(data_format, String, "NHWC")
  312. .OP_END_FACTORY_REG(BiasAddGrad)
  313. /**
  314. *@brief Computes the gradients of convolution with respect to the input.
  315. * @par Inputs:
  316. * Three inputs:
  317. * @li input_size: A const Tensor of type int32. Currently does not support
  318. * data tensor. An integer vector representing the shape of input, where
  319. * input is a 4-D tensor [batch, height, width, channels]
  320. * or [batch, channels, height, width].
  321. * @li filter: A Tensor. Must be one of the following types: float16, float32,
  322. * float64. 4-D with shape
  323. * [filter_height, filter_width, in_channels, out_channels]
  324. * or [out_channels, filter_height, filter_width, in_channels]
  325. * or [out_channels, in_channel, filter_height, filter_width].
  326. * @li out_backprop: A Tensor. Must have the same type as filter.
  327. * 4-D with shape [batch, out_height, out_width, out_channels]
  328. * or [batch, out_channels, out_height, out_width].
  329. * Gradients with respect to the output of the convolution.
  330. *\n
  331. *\n
  332. * The following are the supported data types and data formats:\n
  333. *\n
  334. *\n
  335. | Tensor | out_bckprop | filter | y |\n
  336. |-----------|-------------|---------|--------|\n
  337. | Data Type | float16 | float16 | float16|\n
  338. | | float32 | float32 | float32|\n
  339. | | float64 | float64 | float64|\n
  340. | Format | NCHW | NCHW | NCHW |\n
  341. | | NHWC | HWCN | NHWC |\n
  342. *\n
  343. * For float32 and float64 type, the actual calculation on the chip is based
  344. * on float16.
  345. *\n
  346. *
  347. *@par Attributes:
  348. * Five attributes:
  349. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  350. * for H/W dimension. The index of H/W is same as data_format.
  351. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads
  352. * on feature map
  353. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  354. * dimension of input, defaults to [1,1,1,1].
  355. * @li groups: Number of blocked connections from input channels to output
  356. * channels.
  357. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  358. * "NHWC". Specify the data format of the input and output data.
  359. *\n
  360. *\n
  361. * The following value range restrictions must be met:\n
  362. *\n
  363. *\n
  364. | Name | Field | Scope |\n
  365. |------------------|----------|--------------|\n
  366. | input_size | H | [1, 200000] |\n
  367. | | W | [1, 4096] |\n
  368. | Filter | H | [1, 255] |\n
  369. | | W | [1, 255] |\n
  370. | out_backprop | H*strideH| [1, 200000] |\n
  371. | | W*strideW| [1, 4096] |\n
  372. | y(fmap) | H | [1, 200000] |\n
  373. | | W | [1, 4096] |\n
  374. | Stride | H | [1, 63] |\n
  375. | | W | [1, 63] |\n
  376. | Padding | Top | [0, 255] |\n
  377. | | Bottom | [0, 255] |\n
  378. | | Left | [0, 255] |\n
  379. | | Right | [0, 255] |\n
  380. | Dilation | H | [1, 255] |\n
  381. | | W | [1, 255] |\n
  382. *\n
  383. * In Ascend910, fmap or out_backprop's H and W not support 1 when\n
  384. * fmap_h + pad_top + pad_bottom != (filter_height - 1) * dilation_h + 1
  385. * and filter_width > fmap_width.
  386. * If filter_h = 1 and filter_w = 1, out_backprop_w * stride_h *
  387. * stride_w < 4096. \n
  388. *
  389. *@par Outputs:
  390. * y: A Tensor. Has the same type as filter,and has same format as input_size.
  391. *\n
  392. * out_backprop_height = (fmap_height + pad_top + pad_bottom -
  393. * (dilation_h * (filter_height - 1) + 1))
  394. * / stride_h + 1
  395. *\n
  396. * out_backprop_width = (fmap_width + pad_left + pad_right -
  397. * (dilation_w * (filter_width - 1) + 1))
  398. * / stride_w + 1
  399. *\n
  400. *
  401. *@par Third-party framework compatibility
  402. * Compatible with Tensorflow's conv2d_backprop_input
  403. */
  404. REG_OP(Conv2DBackpropInput)
  405. .INPUT(input_size, TensorType({DT_INT32}))
  406. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  407. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  408. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  409. .REQUIRED_ATTR(strides, ListInt)
  410. .REQUIRED_ATTR(pads, ListInt)
  411. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  412. .ATTR(groups, Int, 1)
  413. .ATTR(data_format, String, "NHWC")
  414. .OP_END_FACTORY_REG(Conv2DBackpropInput)
  415. /**
  416. *@brief Computes the gradients of convolution with respect to the input.
  417. * @par Inputs:
  418. * Two inputs:
  419. * @li filter: A Tensor. Types is float16.
  420. * 4-D with shape [filter_height, filter_width, in_channels, out_channels]
  421. * or [out_channels, filter_height, filter_width, in_channels]
  422. * or [out_channels, in_channel, filter_height, filter_width].
  423. * @li out_backprop: A Tensor. Must have the same type as filter.
  424. * 4-D with shape [batch, out_height, out_width, out_channels]
  425. * or [batch, out_channels, out_height, out_width].
  426. * Gradients with respect to the output of the convolution.
  427. *@par Attributes:
  428. * Six attributes:
  429. * @li input_size A Tensor of type int32. An integer vector representing the
  430. * shape of input, where input is a 4-D tensor [batch, height, width, channels]
  431. * or [batch, channels, height, width].
  432. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  433. * for H/W dimension. The index of H/W is same as data_format.
  434. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads on
  435. * feature map
  436. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  437. * dimension of input, defaults to [1,1,1,1].
  438. * @li groups: Number of blocked connections from input channels to output
  439. * channels.
  440. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  441. * "NHWC". Specify the data format of the input and output data.
  442. *@par Outputs:
  443. * y: A Tensor. Has the same type as filter,4-D tensor [batch, height, width,
  444. * channels] or [batch, channels, height, width].
  445. * @par Third-party framework compatibility
  446. * Compatible with Tensorflow's conv2d_backprop_input
  447. *@par Restrictions:
  448. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DBackpropInput instead.
  449. */
  450. REG_OP(Conv2DBackpropInputD)
  451. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8, DT_BF16}))
  452. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_INT8, DT_BF16}))
  453. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT32, DT_BF16}))
  454. .REQUIRED_ATTR(input_size, ListInt)
  455. .REQUIRED_ATTR(strides, ListInt)
  456. .REQUIRED_ATTR(pads, ListInt)
  457. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  458. .ATTR(groups, Int, 1)
  459. .ATTR(data_format, String, "NHWC")
  460. .OP_END_FACTORY_REG(Conv2DBackpropInputD)
  461. /**
  462. *@brief Computes the Deconvolution with respect to the input.
  463. * @par Inputs:
  464. * Two required inputs:
  465. * @li x: A Tensor of type float16 or int8. 4D with shape
  466. * [batch, out_channels, out_height, out_width]. Gradients with respect
  467. * to the output of the convolution.
  468. * @li filter: A Tensor. Must have the same type as "x".
  469. * 4D with shape [out_channels, in_channel, filter_height, filter_width].\n
  470. * Two optional inputs:
  471. * @li bias: An optional tensor. Must have the same type as "y".
  472. * @li offset_w: An optional 1D tensor for quantized deconvolution.
  473. * Type is int8. Reserved.
  474. *\n
  475. *\n
  476. * The following are the supported data types and data formats:\n
  477. *\n
  478. *\n
  479. | Tensor | x | filter | bias | y |\n
  480. |-----------|---------|---------|---------|--------|\n
  481. | Data Type | float16 | float16 | float16 | float16|\n
  482. | | int8 | int8 | int32 | int32 |\n
  483. | Format | NCHW | NCHW | ND | NCHW |\n
  484. *\n
  485. * For int8, a dequant or requant operator must be followed.
  486. *\n
  487. *
  488. *@par Attributes:
  489. * Six attributes:
  490. * @li strides: A tuple or list of 2 integers. The stride of the sliding window
  491. * for H/W dimension, defaults to [1,1].
  492. * @li pads: A tuple or list of 4 integers. The [top, bottom, left, right]
  493. * padding on the feature map, defaults to [0,0,0,0].
  494. * @li dilations: A tuple or list of 4 integers. The dilation factor for each
  495. * dimension of input, defaults to [1,1,1,1].
  496. * @li groups: Number of blocked connections from input channels to
  497. * output channels. Defaults to "1".
  498. * @li data_format: An optional string from: "NCHW". Defaults to "NCHW". \n
  499. * Specify the data format of the input and output data.
  500. * @li offset_x: An optional integer for quantized deconvolution.
  501. * The negative offset added to the input image for int8 type. Ensure offset_x
  502. * within the effective range of int8 [-128, 127]. Defaults to "0".
  503. *\n
  504. *\n
  505. * The following value range restrictions must be met:\n
  506. *\n
  507. *\n
  508. | Name | Field | Scope |\n
  509. |------------------|----------|--------------|\n
  510. | x (out_backprop) | H*strideH| [1, 200000] |\n
  511. | | W*strideW| [1, 4096] |\n
  512. | Filter | H | [1, 255] |\n
  513. | | W | [1, 255] |\n
  514. | y (fmap) | H | [1, 200000] |\n
  515. | | W | [1, 4096] |\n
  516. | Stride | H | [1, 63] |\n
  517. | | W | [1, 63] |\n
  518. | Padding | Top | [0, 255] |\n
  519. | | Bottom | [0, 255] |\n
  520. | | Left | [0, 255] |\n
  521. | | Right | [0, 255] |\n
  522. | Dilation | H | [1, 255] |\n
  523. | | W | [1, 255] |\n
  524. | Offset_x | | [-128, 127] |\n
  525. *\n
  526. * In Ascend910, fmap or out_backprop's H and W not support 1 when\n
  527. * fmap_h + pad_top + pad_bottom != (filter_height - 1) * dilation_h + 1
  528. * and filter_width > fmap_width
  529. * If filter_h = 1 and filter_w = 1,
  530. * out_backprop_w * stride_h * stride_w < 4096
  531. *\n
  532. *
  533. *@par Outputs:
  534. * y: A Tensor. 4D tensor with shape [batch, channels, height, width].
  535. *\n
  536. * out_backprop_height = (fmap_height + pad_top + pad_bottom -
  537. * (dilation_h * (filter_height - 1) + 1))
  538. * / stride_h + 1
  539. *\n
  540. * out_backprop_width = (fmap_width + pad_left + pad_right -
  541. * (dilation_w * (filter_width - 1) + 1))
  542. * / stride_w + 1
  543. *\n
  544. *
  545. * When type of x is float16, the type of y must be float16.
  546. * When type of x is int8, the type of y must be int32.
  547. */
  548. REG_OP(Deconvolution)
  549. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  550. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  551. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  552. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  553. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  554. .ATTR(strides, ListInt, {1, 1})
  555. .ATTR(pads, ListInt, {0, 0, 0, 0})
  556. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  557. .ATTR(groups, Int, 1)
  558. .ATTR(data_format, String, "NCHW")
  559. .ATTR(offset_x, Int, 0)
  560. .OP_END_FACTORY_REG(Deconvolution)
  561. /**
  562. *@brief Computes the gradients of convolution with respect to the filter
  563. *@par Inputs:
  564. * Three inputs:
  565. * @li x: A Tensor. Must be one of the following types: float16, float32,
  566. * float64. 4-D with shape [batch, in_height, in_width, in_channels] or
  567. * [batch, in_channels, in_height, in_width].
  568. * @li filter_size: A const Tensor of type int32. Currently does not support
  569. * data tensor. An integer vector representing the tensor shape of filter,
  570. * where filter is a 4-D tensor [filter_height, filter_width, in_channels,
  571. * out_channels] or [out_channels, filter_height, filter_width, in_channels]
  572. * or [out_channels, in_channel, filter_height, filter_width].
  573. * @li out_backprop: A Tensor. Must have the same type as x. 4-D with shape
  574. * [batch, out_height, out_width, out_channels] or [batch, out_channels,
  575. * out_height, out_width]. Gradients with respect to the output of the
  576. * convolution.
  577. *\n
  578. *\n
  579. * The following are the supported data types and data formats:\n
  580. *\n
  581. *\n
  582. | Tensor | x | out_backprop | y |\n
  583. |-----------|---------|--------------|---------|\n
  584. | Data Type | float16 | float16 | float16 |\n
  585. | | float32 | float32 | float32 |\n
  586. | | float64 | float64 | float64 |\n
  587. | Format | NCHW | NCHW | NCHW |\n
  588. | | NHWC | NHWC | HWCN |\n
  589. *\n
  590. * For float32 and float64 type of x and outbackprop, the actual calculation
  591. * on the chip is based on float16.
  592. *\n
  593. *
  594. *@par Attributes:
  595. * Five attributes:
  596. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  597. * for H/W dimension. The index of H/W is same as data_format.
  598. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads on
  599. * feature map.
  600. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  601. * dimension of input, defaults to [1,1,1,1].
  602. * @li groups: Number of blocked connections from input channels to output
  603. * channels.
  604. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  605. * "NHWC". Specify the data format of the input and output data.
  606. *\n
  607. *\n
  608. * The following value range restrictions must be met:\n
  609. *\n
  610. *\n
  611. | Name | Field | Scope |\n
  612. |------------------|----------|--------------|\n
  613. | x(fmap) | H | [1, 200000] |\n
  614. | | W | [1, 4096] |\n
  615. | Filter Size | H | [1, 255] |\n
  616. | | W | [1, 255] |\n
  617. | out_backprop | H | [1, 200000] |\n
  618. | | W | [1, 4096] |\n
  619. | y | H | [1, 200000] |\n
  620. | | W | [1, 4096] |\n
  621. | Stride | H | [1, 63] |\n
  622. | | W | [1, 63] |\n
  623. | Padding | Top | [0, 255] |\n
  624. | | Bottom | [0, 255] |\n
  625. | | Left | [0, 255] |\n
  626. | | Right | [0, 255] |\n
  627. | Dilation | H | [1, 255] |\n
  628. | | W | [1, 255] |\n
  629. *\n
  630. *@par Outputs:
  631. * y: A Tensor. Has the same type as x, has the same format as filter_size.
  632. *\n
  633. * out_backprop_height = (in_height + pad_top + pad_bottom -
  634. * (dilation_h * (filter_height - 1) + 1))
  635. * / stride_h + 1
  636. *\n
  637. * out_backprop_width = (in_width + pad_left + pad_right -
  638. * (dilation_w * (filter_width - 1) + 1))
  639. * / stride_w + 1
  640. *\n
  641. *
  642. *@par Third-party framework compatibility
  643. * Compatible with Tensorflow's conv2d_backprop_filter
  644. */
  645. REG_OP(Conv2DBackpropFilter)
  646. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  647. .INPUT(filter_size, TensorType({DT_INT32}))
  648. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  649. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  650. .REQUIRED_ATTR(strides, ListInt)
  651. .REQUIRED_ATTR(pads, ListInt)
  652. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  653. .ATTR(groups, Int, 1)
  654. .ATTR(data_format, String, "NHWC")
  655. .OP_END_FACTORY_REG(Conv2DBackpropFilter)
  656. /**
  657. *@brief Computes the gradients of convolution with respect to the filter.
  658. *@par Inputs:
  659. * Two inputs:
  660. * @li x: A Tensor. Type is float16.
  661. * 4-D with shape [batch, in_height, in_width, in_channels] or [batch,
  662. * in_channels, in_height, in_width].
  663. * @li out_backprop: A Tensor. Must have the same type as x. 4-D with shape
  664. * [batch, out_height, out_width, out_channels] or [batch, out_channels,
  665. * out_height, out_width]. Gradients with respect to the output of the
  666. * convolution.
  667. *@par Attributes:
  668. * Six attributes:
  669. * @li filter_size: A Tensor of type integers. An integer vector representing
  670. * the tensor shape of filter,
  671. * where filter is a 4-D tensor [filter_height, filter_width, in_channels,
  672. * out_channels] or [out_channels, filter_height, filter_width, in_channels]
  673. * or [out_channels, in_channel, filter_height, filter_width].
  674. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  675. * for H/W dimension. The index of H/W is same as data_format.
  676. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads on
  677. * feature map
  678. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  679. * dimension of input, defaults to [1,1,1,1].
  680. * @li groups: Number of blocked connections from input channels to output
  681. * channels.
  682. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  683. * "NHWC". Specify the data format of the input and output data.
  684. *@par Outputs:
  685. * y: A Tensor. Type is float32, a 4-D tensor [filter_height, filter_width,
  686. * in_channels, out_channels] or [out_channels, filter_height, filter_width,
  687. * in_channels] or [out_channels, in_channel, filter_height, filter_width].
  688. * Compatible with Tensorflow's conv2d_backprop_filter
  689. *@par Restrictions:
  690. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DBackpropFilter instead.
  691. */
  692. REG_OP(Conv2DBackpropFilterD)
  693. .INPUT(x, TensorType({DT_FLOAT16}))
  694. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  695. .OUTPUT(y, TensorType({DT_FLOAT}))
  696. .REQUIRED_ATTR(filter_size, ListInt)
  697. .REQUIRED_ATTR(strides, ListInt)
  698. .REQUIRED_ATTR(pads, ListInt)
  699. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  700. .ATTR(groups, Int, 1)
  701. .ATTR(data_format, String, "NHWC")
  702. .OP_END_FACTORY_REG(Conv2DBackpropFilterD)
  703. /**
  704. * @brief Computes a 2D convolution given 4D "x" and "filter" tensors.
  705. * @par Inputs:
  706. * @li x: A 4D tensor of input image. With the format "NHWC", the data is stored
  707. * in the order of: [batch, in_height, in_width, in_channels].
  708. * @li filter: A 4D tensor of learnable filters. Must have the same type as "x".
  709. * With the format "HWCN" , the data is stored in the order of: [filter_height,
  710. * filter_width, in_channels / groups, out_channels].
  711. * @li bias: An optional 1D tensor of additive biases to the filter outputs.
  712. * The data is stored in the order of: [out_channels].
  713. * @li offset_w: Reserved.
  714. *\n
  715. *\n
  716. * The following are the supported data types and data formats:
  717. *\n
  718. *\n
  719. | Tensor | x | filter | bias | y |\n
  720. | :-------: | :-----: | :-----: | :-----: | :-----: |\n
  721. | Data Type | float16 | float16 | float16 | float16 |\n
  722. | | float32 | float32 | float32 | float32 |\n
  723. | | int8 | int8 | int32 | int32 |\n
  724. | Format | NCHW | NCHW | ND | NCHW |\n
  725. | | NHWC | HWCN | ND | NHWC |\n
  726. *\n
  727. * For float32 type, the actual calculation on the chip is based on
  728. * float16.
  729. *\n
  730. *
  731. * @par Attributes:
  732. * @li strides: Required. A list of 4 integers. The stride of the sliding window
  733. * for each dimension of input. The dimension order is determined by the data
  734. * format of "x". The N and C dimensions must be set to 1.
  735. * @li pads: Required. A list of 4 integers. The number of pixels to add to each
  736. * (top, bottom, left, right) side of the input.
  737. * @li dilations: Optional. A list of 4 integers. The dilation factor for each
  738. * dimension of input. The dimension order is determined by the data format of
  739. * "x". The N and C dimensions must be set to 1. Defaults to [1, 1, 1, 1].
  740. * @li groups: Optional. An integer of type int32. The number of blocked
  741. * connections from input channels to output channels. In_channels and
  742. * out_channels must both be divisible by "groups". Defaults to 1.
  743. * @li offset_x: Optional. An integer of type int32. The negative offset added
  744. * to the input image for int8 type. Ensure that the output is within the
  745. * effective range. Defaults to 0.
  746. * @li data_format: Reserved.
  747. *\n
  748. *\n
  749. * The following value range restrictions must be met:
  750. *\n
  751. *\n
  752. | Name | Field | Scope |\n
  753. | :--------------: | :------: | :---------: |\n
  754. | Input Image Size | H | [1, 100000] |\n
  755. | | W | [1, 4096] |\n
  756. | Filter Size | H | [1, 255] |\n
  757. | | W | [1, 255] |\n
  758. | Stride | H | [1, 63] |\n
  759. | | W | [1, 63] |\n
  760. | Padding | Top | [0, 255] |\n
  761. | | Bottom | [0, 255] |\n
  762. | | Left | [0, 255] |\n
  763. | | Right | [0, 255] |\n
  764. | Dilation | H | [1, 255] |\n
  765. | | W | [1, 255] |\n
  766. | Offset_x | - | [-128, 127] |\n
  767. *\n
  768. * The W dimension of the input image supports cases exceeding 4096, but it may
  769. * cause compilation errors.
  770. *\n
  771. *
  772. *@par Outputs:
  773. * y: A 4D Tensor of output feature map. Has the same type as "x". With the
  774. * format "NHWC", the data is stored in the order of: [batch, out_height,
  775. * out_width, out_channels].
  776. *\n
  777. * out_height = (in_height + pad_top + pad_bottom -
  778. * (dilation_h * (filter_height - 1) + 1))
  779. * / stride_h + 1
  780. *\n
  781. * out_width = (in_width + pad_left + pad_right -
  782. * (dilation_w * (filter_width - 1) + 1))
  783. * / stride_w + 1
  784. *\n
  785. *
  786. * @par Quantization supported or not
  787. * Yes
  788. *
  789. * @par Third-party framework compatibility
  790. *@li Compatible with the TensorFlow operator "conv2d".
  791. *@li Compatible with the Caffe operator 2D "Convolution".
  792. */
  793. REG_OP(Conv2D)
  794. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_BF16}))
  795. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_BF16}))
  796. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  797. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  798. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_BF16}))
  799. .REQUIRED_ATTR(strides, ListInt)
  800. .REQUIRED_ATTR(pads, ListInt)
  801. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  802. .ATTR(groups, Int, 1)
  803. .ATTR(data_format, String, "NHWC")
  804. .ATTR(offset_x, Int, 0)
  805. .OP_END_FACTORY_REG(Conv2D)
  806. /**
  807. * @brief Computes a 2D convolution given 4D "x" and "filter_compress" tensors.
  808. * @par Inputs:
  809. * @li x: A 4D tensor of input images.
  810. * @li filter_compress: A 4D tensor of compressed filter data blocks.
  811. * @li compress_index: A 1D tensor of index for decompression.
  812. * @li bias: An optional 1D tensor of additive biases to the filter outputs.
  813. * The data is stored in the order of: [out_channels].
  814. * @li offset_w: Reserved.
  815. *\n
  816. *\n
  817. * The following are the supported data types and data formats:
  818. *\n
  819. *\n
  820. | Tensor | x | filter_compress | compress_index | bias | y |\n
  821. | :-------: | :-----: | :--------------: | :------------: | :-----: | :-----: |\n
  822. | Data Type | int8 | int8 | int8 | int32 | int32 |\n
  823. | Format | NCHW | NCHW | ND | ND | NCHW |\n
  824. | | NHWC | HWCN | | | NHWC |\n
  825. *\n
  826. * For float32 type, the actual calculation on the chip is based on
  827. * float16.
  828. *\n
  829. *
  830. * @par Attributes:
  831. * @li strides: Required. A list of 4 integers. The stride of the sliding window
  832. * for each dimension of input. The dimension order is determined by the data
  833. * format of "x". The N and C dimensions must be set to 1.
  834. *@li pads: Required. A list of 4 integers. The number of pixels to add to each
  835. * (top, bottom, left, right) side of the input.
  836. *@li dilations: Optional. A list of 4 integers. The dilation factor for each
  837. * dimension of input. The dimension order is determined by the data format of
  838. * "x". The N and C dimensions must be set to 1. Defaults to [1, 1, 1, 1].
  839. *@li groups: Optional. An integer of type int32. The number of blocked
  840. * connections from input channels to output channels. In_channels and
  841. * out_channels must both be divisible by "groups". Only support 1.
  842. *@li offset_x: Optional. An integer of type int32. The negative offset added
  843. * to the input image for int8 type. Ensure that the output is within the
  844. * effective range. Defaults to 0.
  845. *@li data_format: Reserved.
  846. * @li alg: compress algorithm, default weight_unzip.
  847. *
  848. *@par Outputs:
  849. * y: A 4D Tensor of output feature map. Has the same type as "x". With the
  850. * format "NHWC", the data is stored in the order of: [batch, out_height,
  851. * out_width, out_channels].
  852. *\n
  853. *
  854. *@par Restrictions:
  855. *Warning: THIS FUNCTION IS EXPERIMENTAL.
  856. */
  857. REG_OP(Conv2DCompress)
  858. .INPUT(x, TensorType({DT_INT8}))
  859. .INPUT(filter_compress, TensorType({DT_INT8}))
  860. .INPUT(compress_index, TensorType({DT_INT8}))
  861. .OPTIONAL_INPUT(bias, TensorType({DT_INT32}))
  862. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  863. .OUTPUT(y, TensorType({DT_INT32}))
  864. .REQUIRED_ATTR(strides, ListInt)
  865. .REQUIRED_ATTR(pads, ListInt)
  866. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  867. .ATTR(groups, Int, 1)
  868. .ATTR(data_format, String, "NHWC")
  869. .ATTR(offset_x, Int, 0)
  870. .ATTR(alg, String, "weight_unzip")
  871. .OP_END_FACTORY_REG(Conv2DCompress)
  872. /**
  873. *@brief Computes a 2D deformable convolution given 4D "x", "filter" and
  874. * "offsets" tensors.
  875. *@par Inputs:
  876. *@li x: A 4D tensor of input image. With the format "NHWC", the data is stored
  877. * in the order of: [batch, in_height, in_width, in_channels].
  878. *@li filter: A 4D tensor of learnable filters. Must have the same type as "x".
  879. * With the format "HWCN" , the data is stored in the order of: [filter_height,
  880. * filter_width, in_channels / groups, out_channels].
  881. *@li offsets: A 4D tensor of x-y coordinates offset and mask. With the format
  882. * "NHWC", the data is stored in the order of: [batch, out_height, out_width,
  883. * deformable_groups * filter_height * filter_width * 3].
  884. *@li bias: An optional 1D tensor of additive biases to the filter outputs.
  885. * The data is stored in the order of: [out_channels].
  886. *\n
  887. *\n
  888. * The following are the supported data types and data formats:
  889. *\n
  890. *\n
  891. | Tensor | x | filter | offsets | bias | y |\n
  892. | :-------: | :-----: | :-----: | :-----: | :-----: | :-----: |\n
  893. | Data Type | float16 | float16 | float16 | float16 | float16 |\n
  894. | | float32 | float32 | float32 | float32 | float32 |\n
  895. | Format | NCHW | NCHW | NCHW | ND | NCHW |\n
  896. | | NHWC | HWCN | NCHW | | NHWC |\n
  897. *\n
  898. * For float32 type, the actual convolution calculation part on the chip is
  899. * based on float16.
  900. *\n
  901. *
  902. *@par Attributes:
  903. *@li strides: Required. A list of 4 integers. The stride of the sliding window
  904. * for each dimension of input. The dimension order is interpreted according to
  905. * the data format of "x". The N and C dimensions must be set to 1.
  906. *@li pads: Required. A list of 4 integers. The number of pixels to add to each
  907. * (top, bottom, left, right) side of the input.
  908. *@li dilations: Optional. A list of 4 integers. The dilation factor for each
  909. * dimension of input. The dimension order is interpreted according to the data
  910. * format of "x". The N and C dimensions must be set to 1. Defaults to
  911. * [1, 1, 1, 1].
  912. *@li groups: Optional. An integer of type int32. The number of blocked
  913. * connections from input channels to output channels. In_channels and
  914. * out_channels must both be divisible by "groups". Defaults to 1.
  915. *@li data_format: Reserved.
  916. *@li deformable_groups: Optional. An integer of type int32. The number of
  917. * deformable group partitions. In_channels must be divisible by
  918. * "deformable_groups". Defaults to 1.
  919. *@li modulated: Optional. Specify version of DeformableConv2D, true means v2,
  920. * false means v1, currently only support v2.
  921. *\n
  922. *\n
  923. * The following value range restrictions must be met:
  924. *\n
  925. *\n
  926. | Name | Field | Scope |\n
  927. | :--------------: | :------: | :-------------------------: |\n
  928. | Input Image Size | H | [1, 100000 / filter_height] |\n
  929. | | W | [1, 4096 / filter_width] |\n
  930. | Filter Size | H | [1, 63] |\n
  931. | | W | [1, 63] |\n
  932. *\n
  933. *
  934. *@par Outputs:
  935. * y: A 4D Tensor of output feature map. Has the same type as "x". With the
  936. * format "NHWC", the data is stored in the order of: [batch, out_height,
  937. * out_width, out_channels].
  938. *\n
  939. * out_height = (in_height + pad_top + pad_bottom -
  940. * (dilation_h * (filter_height - 1) + 1))
  941. * / stride_h + 1
  942. *\n
  943. * out_width = (in_width + pad_left + pad_right -
  944. * (dilation_w * (filter_width - 1) + 1))
  945. * / stride_w + 1
  946. *\n
  947. *
  948. *@par Quantization supported or not
  949. *@li No
  950. *
  951. *@par Third-party framework compatibility
  952. *@li Compatible with the Mxnet operator "DeformableConvolution".
  953. *@li Compatible with the Paddlepaddle operator "deformable_conv".
  954. *@li Compatible with the Mmcv operator "deform_conv".
  955. */
  956. REG_OP(DeformableConv2D)
  957. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  958. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT}))
  959. .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT}))
  960. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT}))
  961. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  962. .REQUIRED_ATTR(strides, ListInt)
  963. .REQUIRED_ATTR(pads, ListInt)
  964. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  965. .ATTR(groups, Int, 1)
  966. .ATTR(data_format, String, "NHWC")
  967. .ATTR(deformable_groups, Int, 1)
  968. .ATTR(modulated, Bool, true)
  969. .OP_END_FACTORY_REG(DeformableConv2D)
  970. /**
  971. *@brief Computes a 3D convolution given 5D "x" and "filter" tensors.
  972. *@par Inputs:
  973. * @li x: A 5D tensor. Must be one of the following types: float16,
  974. * (Currently does not support int8). The format of x is NCDHW or NDHWC.
  975. * @li filter: A 5D tensor of the same type as "x".
  976. * (Currently does not support int8).
  977. * The format is NCDHW, NDHWC or DHWCN.
  978. * @li bias: Optional. An 1D tensor of the same type as "x".
  979. * @li offset_w: Optional. An 1D tensor for quantized deconvolution. Reserved. \n
  980. *@par Attributes:
  981. * @li strides: Required. A list of 5 integers. Specifies the stride of the
  982. * sliding window for each dimension of "x".
  983. * The N and C dimensions must be 1. Has the same format as "x".
  984. * @li pads: Required. A list of 6 integers.
  985. * Supports only padding along the D, H and W dimensions in sequence of head,
  986. * tail, top, bottom, left and right.
  987. * @li dilations: Optional. A list of 5 integers. Specifies the dilation
  988. * factor for each dimension of "x".
  989. * @li groups: Optional. Number of blocked connections from input channels
  990. * to output channels.
  991. * @li data_format: Optional. An string from: "NDHWC", "NCDHW".
  992. * Defaults to "NDHWC". Specify the data format of the input and output data.
  993. * The N, C and D dimensions must be 1. Has the same format as "x".
  994. * @li offset_x: Optional. An int. Input offset, used for quantized inference.
  995. * Defaults to 0. Reserved. \n
  996. *@par Outputs:
  997. * y: A Tensor. Has the same type and data format as "x". \n
  998. *@attention Constraints:
  999. * The image size after padding is greater than the filter size. \n
  1000. *@par Third-party framework compatibility
  1001. * @li Compatible with the TensorFlow operator conv3d.
  1002. * @li Compatible with the Caffe operator Convolution.
  1003. */
  1004. REG_OP(Conv3D)
  1005. .INPUT(x, TensorType({DT_FLOAT16}))
  1006. .INPUT(filter, TensorType({DT_FLOAT16}))
  1007. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1008. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1009. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1010. .REQUIRED_ATTR(strides, ListInt)
  1011. .REQUIRED_ATTR(pads, ListInt)
  1012. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1013. .ATTR(groups, Int, 1)
  1014. .ATTR(data_format, String, "NDHWC")
  1015. .ATTR(offset_x, Int, 0)
  1016. .OP_END_FACTORY_REG(Conv3D)
  1017. /**
  1018. *@brief Computes the gradients of convolution 3d with respect to the input.
  1019. *@par Inputs:
  1020. * @li input_size: A Tensor of type int32, int64. An integer vector
  1021. * representing the shape of input, where input is a 5-D tensor
  1022. * [batch, depth, height, width, channels] or
  1023. * [batch, channels, depth, height, width].
  1024. * @li filter: A Tensor. Must be one of the following types: float16, float32.
  1025. * Currently does not support double.
  1026. * @li out_backprop: A Tensor. Must have the same type as filter.
  1027. * 5-D with shape [batch, depth, out_height, out_width, out_channels]
  1028. * or [batch, out_channels, depth, out_height, out_width]. Gradients with
  1029. * respect to the output of the convolution. \n
  1030. *@par Attributes:
  1031. * @li strides: Required. A list of 5 integers. Specifies the stride of the
  1032. * sliding window for each dimension of "out_backprop".
  1033. * The N and C dimensions must be 1. Has the same format as "out_backprop".
  1034. * @li pads: Required. A list of 6 integers.
  1035. * Supports only padding along the D, H and W dimensions in sequence of head,
  1036. * tail, top, bottom, left and right.
  1037. * @li dilations: Optional. A tuple/list of 5 integers, The dilation factor
  1038. * for each dimension of the input.
  1039. * The N, C and D dimensions must be 1. Has the same format as "out_backprop".
  1040. * @li groups: Optional. Number of blocked connections from input channels
  1041. * to output channels.
  1042. * @li data_format: Optional. An string from: "NDHWC", "NCDHW".
  1043. * Defaults to "NDHWC". Specify the data format of the input and output data. \n
  1044. *@par Outputs:
  1045. * y: A Tensor. Has the same type as filter,and has same format as
  1046. * "input_size". \n
  1047. *@par Third-party framework compatibility
  1048. * Compatible with Tensorflow's conv3d_backprop_input
  1049. */
  1050. REG_OP(Conv3DBackpropInput)
  1051. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1052. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1053. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1054. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1055. .REQUIRED_ATTR(strides, ListInt)
  1056. .REQUIRED_ATTR(pads, ListInt)
  1057. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1058. .ATTR(groups, Int, 1)
  1059. .ATTR(data_format, String, "NDHWC")
  1060. .OP_END_FACTORY_REG(Conv3DBackpropInput)
  1061. /**
  1062. *@brief Computes the gradients of convolution 3d with respect to the input.
  1063. *@par Inputs:
  1064. * @li filter: A Tensor whose type is float16. The format of filter is NCDHW,
  1065. * NDHWC or DHWCN.
  1066. * @li out_backprop: A Tensor. Must have the same type as filter. The format is
  1067. * NDHWC or NCDHW. \n
  1068. *@par Attributes:
  1069. * @li input_size: Required. A tuple/list of type int32, int64. An integer vector
  1070. * representing the shape of input, where input is a 5-D tensor
  1071. * [batch, depth, height, width, channels] or
  1072. * [batch, channels, depth, height, width].
  1073. * @li strides: Required. A list of 5 integers. Specifies the stride of the sliding window
  1074. * for each dimension of "out_backprop".
  1075. * The N and C dimensions must be 1. Has the same format as "out_backprop".
  1076. * @li pads: Required. A list of 6 integers. Supports only padding along the D, H and W
  1077. * dimensions in sequence of head, tail, top, bottom, left and right.
  1078. * @li dilations: Optional. A tuple/list of 5 integers, The dilation factor for each
  1079. * dimension of input.
  1080. * The N, C and D dimensions must be 1. Has the same format as "out_backprop".
  1081. * @li groups: Optional. Number of blocked connections from input channels to output
  1082. * channels.
  1083. * @li data_format: Optional. An string from: "NDHWC", "NCDHW".
  1084. * Defaults to "NDHWC". Specify the data format of the input and output data. \n
  1085. *@par Outputs:
  1086. * y: A Tensor. Has the same type and data format as "out_backprop". \n
  1087. *@par Third-party framework compatibility
  1088. * Compatible with Tensorflow's conv3d_backprop_input. \n
  1089. *@par Restrictions:
  1090. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropInput instead.
  1091. */
  1092. REG_OP(Conv3DBackpropInputD)
  1093. .INPUT(filter, TensorType({DT_FLOAT16}))
  1094. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  1095. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1096. .REQUIRED_ATTR(input_size, ListInt)
  1097. .REQUIRED_ATTR(strides, ListInt)
  1098. .REQUIRED_ATTR(pads, ListInt)
  1099. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1100. .ATTR(groups, Int, 1)
  1101. .ATTR(data_format, String, "NDHWC")
  1102. .OP_END_FACTORY_REG(Conv3DBackpropInputD)
  1103. /**
  1104. *@brief Applies a multi-layer long short-term memory (LSTM) RNN to an input sequence . \n
  1105. *@par Inputs:
  1106. * @li x: A Tensor dtype of float16.
  1107. * @li cont: A Tensor dtype of float16, float32.
  1108. * @li w_x: A Tensor dtype of float16.
  1109. * @li bias: A Tensor dtype of int16, int32, float16, float32.
  1110. * @li w_h: A Tensor dtype of float16.
  1111. * @li x_static: A optinal Tensor dtype of float16.
  1112. * @li h_0: A optinal Tensor dtype of float16, float32.
  1113. * @li c_0: A optinal Tensor dtype of float16, float32.
  1114. * @li w_x_static: A optinal Tensor dtype of float16 . \n
  1115. *@par Attributes:
  1116. *@li num_output: A Scalar of output size dtype of int.
  1117. *@li expose_hidden: A Scalar(bool) of features hidden . \n
  1118. *@par Outputs:
  1119. *@li h: A Tensor dtype of float16, float32.
  1120. * @li h_t: A optinal Tensor dtype of float16, float32. The hidden state at time t.
  1121. * @li c_t: A optinal Tensor dtype of float16, float32. The cell state at time t . \n
  1122. *@par Third-party framework compatibility:
  1123. * Compatible with the Caffe operator LSTM.
  1124. */
  1125. REG_OP(LSTM)
  1126. .INPUT(x, TensorType({DT_FLOAT16}))
  1127. .INPUT(cont, TensorType({DT_FLOAT32,DT_FLOAT16}))
  1128. .INPUT(w_x, TensorType({DT_FLOAT16}))
  1129. .INPUT(bias, TensorType({DT_FLOAT16,DT_FLOAT32,DT_INT16,DT_INT32}))
  1130. .INPUT(w_h, TensorType({DT_FLOAT16}))
  1131. .OPTIONAL_INPUT(x_static, TensorType({DT_FLOAT16}))
  1132. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1133. .OPTIONAL_INPUT(c_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1134. .OPTIONAL_INPUT(w_x_static, TensorType({DT_FLOAT16}))
  1135. .OUTPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1136. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1137. .OUTPUT(c_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1138. .ATTR(num_output, Int, 0)
  1139. .ATTR(expose_hidden, Bool, false)
  1140. .OP_END_FACTORY_REG(LSTM)
  1141. /**
  1142. *@brief Computes the gradients of convolution3D with respect to the filter
  1143. *@par Inputs:
  1144. * @li x: A Tensor. Must be one of the following types: float16, float32,
  1145. * double. Currently does not support double.
  1146. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1147. * or [batch, in_channels, in_depth, in_height, in_width].
  1148. * @li filter_size: A Tensor of type int32. An integer vector representing the
  1149. * tensor shape of filter, where filter is a 5-D tensor
  1150. * [filter_depth, filter_height, filter_width, in_channels, out_channels]
  1151. * [out_channels, in_channels, filter_depth, filter_height, filter_width]
  1152. * or [out_channels, filter_depth, filter_height, filter_width, in_channels].
  1153. * @li out_backprop: A Tensor. Must have the same type as x.
  1154. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1155. * or [batch, out_channels, out_depth, out_height, out_width].
  1156. * Gradients with respect to the output of the convolution. \n
  1157. *@par Attributes:
  1158. * @li strides: Required. A tuple/list of 5 integers. Specifies the stride
  1159. * of the sliding window for each dimension of "x". The N and C dimensions
  1160. * must be 1. Has the same format as "x".
  1161. * @li pads: Required. A tuple/list of 6 integers, [front, back, top, bottom,
  1162. * left, right] pads on feature map.
  1163. * @li dilations: Optional. A tuple/list of 5 integers, The dilation factor
  1164. * for each dimension of input.
  1165. * The N, C and D dimensions must be 1. Has the same format as "x".
  1166. * @li groups: Optional. Number of blocked connections from input channels
  1167. * to output channels.
  1168. * @li data_format: Optional. An string from: "NDHWC", "NCDHW".
  1169. * Defaults to "NDHWC". Specify the data format of the input and output data. \n
  1170. *@par Outputs:
  1171. * y: A Tensor that has the same type as "x" and the format is NDHWC, NCDHW
  1172. * or DHWCN. \n
  1173. *@par Third-party framework compatibility
  1174. * Compatible with Tensorflow's conv3d_backprop_filter
  1175. */
  1176. REG_OP(Conv3DBackpropFilter)
  1177. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1178. .INPUT(filter_size, TensorType({DT_INT32}))
  1179. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1180. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1181. .REQUIRED_ATTR(strides, ListInt)
  1182. .REQUIRED_ATTR(pads, ListInt)
  1183. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1184. .ATTR(groups, Int, 1)
  1185. .ATTR(data_format, String, "NDHWC")
  1186. .OP_END_FACTORY_REG(Conv3DBackpropFilter)
  1187. /**
  1188. *@brief Computes the gradients of convolution with respect to the filter.
  1189. *@par Inputs:
  1190. * @li x: A Tensor of type float16.
  1191. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1192. * or [batch, in_channels, in_depth, in_height, in_width].
  1193. * @li out_backprop: A Tensor. Must have the same type as x.
  1194. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1195. * or [batch, out_channels, out_depth, out_height, out_width].
  1196. * Gradients with respect to the output of the convolution. \n
  1197. *@par Attributes:
  1198. * @li filter_size: Required. A tuple/list of type integers. An integer vector
  1199. * representing the tensor shape of filter, where filter is a 5-D tensor
  1200. * [filter_depth, filter_height, filter_width, in_channels, out_channels],
  1201. * [out_channels, filter_depth, filter_height, filter_width, in_channels]
  1202. * or [out_channels, in_channels, filter_depth, filter_height, filter_width].
  1203. * @li strides: Required. A tuple/list of 5 integers. Specifies the stride of the sliding
  1204. * window for each dimension of "x".
  1205. * The N and C dimensions must be 1. Has the same format as "x".
  1206. * @li pads: Required. A tuple/list of 6 integers, [front, back, top, bottom, left, right]
  1207. * pads on feature map.
  1208. * @li dilations: Optional. A tuple/list of 5 integers, The dilation factor for each
  1209. * dimension of input.
  1210. * The N, C and D dimensions must be 1. Has the same format as "x".
  1211. * @li groups: Optional. Number of blocked connections from input channels to output
  1212. * channels.
  1213. * @li data_format: Optional. An optional string from: "NDHWC", "NCDHW".
  1214. * Defaults to "NDHWC". Specify the data format of the input and output data. \n
  1215. *@par Outputs:
  1216. * y: A Tensor of type float32 and the format is NDHWC, NCDHW or DHWCN. \n
  1217. *@par Third-party framework compatibility
  1218. * Compatible with Tensorflow's conv3d_backprop_filter. \n
  1219. *@par Restrictions:
  1220. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropFilter instead.
  1221. */
  1222. REG_OP(Conv3DBackpropFilterD)
  1223. .INPUT(x, TensorType({DT_FLOAT16}))
  1224. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  1225. .OUTPUT(y, TensorType({DT_FLOAT}))
  1226. .REQUIRED_ATTR(filter_size, ListInt)
  1227. .REQUIRED_ATTR(strides, ListInt)
  1228. .REQUIRED_ATTR(pads, ListInt)
  1229. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1230. .ATTR(groups, Int, 1)
  1231. .ATTR(data_format, String, "NDHWC")
  1232. .OP_END_FACTORY_REG(Conv3DBackpropFilterD)
  1233. /**
  1234. *@brief Computes the transpose of convolution 3d with respect to the input.
  1235. *@par Inputs:
  1236. * @li input_size: A Tensor of type int32, int64. An integer vector
  1237. * representing the shape of input.
  1238. * @li x: A Tensor of type float16, currently does not support int8. The format
  1239. * is NDHWC or NCDHW.
  1240. * @li filter: A Tensor of type float16, currently does not support int8.
  1241. * The format is NDHWC, NCDHW or DHWCN.
  1242. * @li bias: Optional. An optional 1D tensor of the same type as "x". Reserved.
  1243. * @li offset_w: Optional. An optional 1D tensor for quantized deconvolution.
  1244. * Reserved. \n
  1245. *@par Attributes:
  1246. * @li strides: Required. A tuple/list of 5 integers. Specifies the stride of
  1247. * the sliding window for each dimension of "x".
  1248. * The N and C dimensions must be 1. Has the same format as "x".
  1249. * @li pads: Required. A tuple/list of 6 integers.
  1250. * @li dilations: Optional. A tuple/list of 5 integers,
  1251. * The dilation factor for each dimension of input.
  1252. * The N, C and D dimensions must be 1. Has the same format as "x".
  1253. * @li groups: Optional. Number of blocked connections from input channels to
  1254. * output channels.
  1255. * @li data_format: Optional. An string from: "NDHWC", "NCDHW".
  1256. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1257. * @li output_padding: Optional. The size will be added in the output shape.
  1258. * @li offset_x: Optional. Input offset_x value. Reserved. \n
  1259. *@par Outputs:
  1260. * y: A Tensor. Has the same type and format as "x".
  1261. */
  1262. REG_OP(Conv3DTranspose)
  1263. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1264. .INPUT(x, TensorType({DT_FLOAT16}))
  1265. .INPUT(filter, TensorType({DT_FLOAT16}))
  1266. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1267. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1268. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1269. .REQUIRED_ATTR(strides, ListInt)
  1270. .REQUIRED_ATTR(pads, ListInt)
  1271. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1272. .ATTR(groups, Int, 1)
  1273. .ATTR(data_format, String, "NDHWC")
  1274. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1275. .ATTR(offset_x, Int, 0)
  1276. .OP_END_FACTORY_REG(Conv3DTranspose)
  1277. /**
  1278. *@brief Computes the transpose of convolution 3d with respect to the input.
  1279. *@par Inputs:
  1280. * @li x: A Tensor of type float16, currently does not support int8.
  1281. * The format is NDHWC or NCDHW.
  1282. * @li filter: A Tensor of type float16, currently does not support int8.
  1283. * The format is NDHWC, NCDHW or DHWCN.
  1284. * @li bias: Optional. An 1D tensor of the same type as "x". Reserved.
  1285. * @li offset_w: Optional. An 1D tensor for quantized deconvolution. Reserved. \n
  1286. *@par Attributes:
  1287. * @li input_size: Required. A tuple/list of type int32.
  1288. * An integer vector representing the shape of input.
  1289. * @li strides: Required. A tuple/list of 5 integers.
  1290. * Specifies the stride of the sliding window for each dimension of "x".
  1291. * The N and C dimensions must be 1. Has the same format as "x".
  1292. * @li pads: Required. A tuple/list of 6 integers.
  1293. * @li dilations: Optional. A tuple/list of 5 integers, The dilation factor for each
  1294. * dimension of input.
  1295. * The N, C and D dimensions must be 1. Has the same format as "x".
  1296. * @li groups: Optional. Number of blocked connections from input channels to output
  1297. * channels.
  1298. * @li data_format: Optional. An optional string from: "NDHWC", "NCDHW".
  1299. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1300. * @li output_padding: Optional. The size will be added in the output shape.
  1301. * @li offset_x: Optional. Input offset_x value. Reserved. \n
  1302. *@par Outputs:
  1303. * y: A Tensor. Has the same type and format as "x". \n
  1304. *@par Restrictions:
  1305. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DTranspose instead.
  1306. */
  1307. REG_OP(Conv3DTransposeD)
  1308. .INPUT(x, TensorType({DT_FLOAT16}))
  1309. .INPUT(filter, TensorType({DT_FLOAT16}))
  1310. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1311. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1312. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1313. .REQUIRED_ATTR(input_size, ListInt)
  1314. .REQUIRED_ATTR(strides, ListInt)
  1315. .REQUIRED_ATTR(pads, ListInt)
  1316. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1317. .ATTR(groups, Int, 1)
  1318. .ATTR(data_format, String, "NDHWC")
  1319. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1320. .ATTR(offset_x, Int, 0)
  1321. .OP_END_FACTORY_REG(Conv3DTransposeD)
  1322. /**
  1323. *@brief Computes the transpose of convolution 2d with respect to the input.
  1324. *@par Inputs:
  1325. * Five inputs:
  1326. * @li input_size: A Tensor of type int32 or int64. An integer vector
  1327. * representing the shape of input, where input is a 4-D tensor
  1328. * [batch, height, width, channels] or [batch, channels, height, width].
  1329. * @li x: A Tensor of type float16, int8. 4-D with shape [batch, out_height,
  1330. * out_width, out_channels] or [batch, out_channels, out_height, out_width].
  1331. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1332. * 4-D with shape [filter_height, filter_width, in_channels, out_channels]
  1333. * or [out_channels, filter_height, filter_width, in_channels]
  1334. * or [out_channels, in_channel, filter_height, filter_width].
  1335. * @li bias: An optional 1D tensor of type float16, float32, int32.
  1336. * Format is "ND".
  1337. * @li offset_w: An optional 1D tensor for quantized inference. Reserved.
  1338. *\n
  1339. *\n
  1340. * The following are the supported data types and data formats:\n
  1341. *\n
  1342. *\n
  1343. | Tensor | x | filter | bias | y |\n
  1344. |-----------|---------|---------|---------|--------|\n
  1345. | Data Type | float16 | float16 | float16 | float16|\n
  1346. | | int8 | int8 | int32 | int32 |\n
  1347. | Format | NCHW | NCHW | ND | NCHW |\n
  1348. | | NHWC | HWCN | | NHWC |\n
  1349. *\n
  1350. * For int8, a dequant or requant operator must be followed.
  1351. *\n
  1352. *
  1353. *@par Required Attributes:
  1354. * @li strides: A required tuple/list of 4 integers. The stride of the sliding
  1355. * window for H/W dimension. The index of H/W is same as data_format.
  1356. * @li pads: A required tuple/list of 4 integers, [top, bottom, left, right]
  1357. * pads on feature map.
  1358. *@par Attributes:
  1359. * Five attributes:
  1360. * @li groups: Number of blocked connections from input channels to output
  1361. * channels.
  1362. * Defaults to "1".
  1363. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  1364. * dimension of input. Must be [1, 1, 1, 1].
  1365. * @li data_format: An optional string from: "NHWC", "NCHW".
  1366. * Defaults to "NHWC". Specify the data format of the input and output data.
  1367. * @li output_padding: The size will be added in the output shape. Defaults
  1368. * to [0, 0, 0, 0].
  1369. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1370. * The negative offset added to the input image for int8 type. Ensure offset_x
  1371. * within the effective range of int8 [-128, 127]. Defaults to "0".
  1372. *\n
  1373. *\n
  1374. * The following value range restrictions must be met:\n
  1375. *\n
  1376. *\n
  1377. | Name | Field | Scope |\n
  1378. |------------------|----------|--------------|\n
  1379. | input_size | H | [1, 200000] |\n
  1380. | | W | [1, 4096] |\n
  1381. | x (out_backprop) | H*strideH| [1, 200000] |\n
  1382. | | W*strideW| [1, 4096] |\n
  1383. | filter | H | [1, 255] |\n
  1384. | | W | [1, 255] |\n
  1385. | y (fmap) | H | [1, 200000] |\n
  1386. | | W | [1, 4096] |\n
  1387. | Stride | H | [1, 63] |\n
  1388. | | W | [1, 63] |\n
  1389. | Padding | Top | [0, 255] |\n
  1390. | | Bottom | [0, 255] |\n
  1391. | | Left | [0, 255] |\n
  1392. | | Right | [0, 255] |\n
  1393. | Dilation | H | [1, 255] |\n
  1394. | | W | [1, 255] |\n
  1395. | Offset_x | | [-128, 127] |\n
  1396. *\n
  1397. * In Ascend910, fmap or out_backprop's H and W not support 1 when\n
  1398. * fmap_h + pad_top + pad_bottom != (filter_height - 1) * dilation_h + 1
  1399. * and filter_width > fmap_width.
  1400. * If filter_h = 1 and filter_w = 1, out_backprop_w * stride_h * stride_w
  1401. * < 4096. \n
  1402. *
  1403. *@par Outputs:
  1404. * y: A Tensor. A Tensor of type float16, int32, float32, and has
  1405. * same format as input_size.
  1406. *\n
  1407. * out_backprop_height = (fmap_height + pad_top + pad_bottom -
  1408. * (dilation_h * (filter_height - 1) + 1))
  1409. * / stride_h + 1
  1410. *\n
  1411. * out_backprop_width = (fmap_width + pad_left + pad_right -
  1412. * (dilation_w * (filter_width - 1) + 1))
  1413. * / stride_w + 1
  1414. *\n
  1415. *
  1416. */
  1417. REG_OP(Conv2DTranspose)
  1418. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1419. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1420. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1421. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT32}))
  1422. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1423. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT32}))
  1424. .REQUIRED_ATTR(strides, ListInt)
  1425. .REQUIRED_ATTR(pads, ListInt)
  1426. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1427. .ATTR(groups, Int, 1)
  1428. .ATTR(data_format, String, "NHWC")
  1429. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1430. .ATTR(offset_x, Int, 0)
  1431. .OP_END_FACTORY_REG(Conv2DTranspose)
  1432. /**
  1433. *@brief Computes the transpose of convolution 2d with respect to the input.
  1434. * @par Inputs:
  1435. * Four inputs:
  1436. * @li x: A Tensor of type float16, int8.
  1437. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1438. * @li bias: An optional 1D tensor of the same type as "x".
  1439. * @li offset_w: An optional 1D tensor for quantized inference. Type is int8. Reserved.
  1440. *@par Required Attributes:
  1441. * @li input_size: A Tensor of type int32 or int64. An integer vector representing the
  1442. * shape of input.
  1443. * @li strides: A required list or tuple. The stride of the sliding window for
  1444. * height and width for H/W dimension.
  1445. * @li pads: A required list or tuple of int32. Padding added to each dimension
  1446. * of the input.
  1447. *@par Attributes:
  1448. * Five attributes:
  1449. * @li groups: Number of blocked connections from input channels to output channels.
  1450. * Defaults to "1".
  1451. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1452. * of input. Must be [1, 1, 1, 1].
  1453. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC".
  1454. * Specify the data format of the input and output data.
  1455. * @li output_padding: The size will be added in the output shape. Defaults
  1456. * to [0, 0, 0, 0].
  1457. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1458. * Defaults to "0".
  1459. *@par Outputs:
  1460. * y: A Tensor. Has the same type as "filter".
  1461. *@par Restrictions:
  1462. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DTranspose instead.
  1463. */
  1464. REG_OP(Conv2DTransposeD)
  1465. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1466. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1467. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT32}))
  1468. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1469. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT32}))
  1470. .REQUIRED_ATTR(input_size, ListInt)
  1471. .REQUIRED_ATTR(strides, ListInt)
  1472. .REQUIRED_ATTR(pads, ListInt)
  1473. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1474. .ATTR(groups, Int, 1)
  1475. .ATTR(data_format, String, "NHWC")
  1476. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1477. .ATTR(offset_x, Int, 0)
  1478. .OP_END_FACTORY_REG(Conv2DTransposeD)
  1479. /**
  1480. *@brief Computes the deformed convolution output with the expected input
  1481. * @par Inputs:
  1482. * Two inputs:
  1483. * @li x: A Tensor of type float16,float32
  1484. * @li offsets: A Tensor of type float16,float32.Deformation offset parameter.
  1485. *@par Attributes:
  1486. * @li strides: A tuple/list of 4 integers.The stride of the sliding window for
  1487. * height and width for H/W dimension.
  1488. * @li pads: A tuple/list of 4 integers.Padding added to H/W dimension
  1489. * of the input.
  1490. * @li ksize: A tuple/list of 2 integers.kernel size.
  1491. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1492. * of input. Defaults to [1, 1, 1, 1]
  1493. * @li data_format: An optional string from: "NCHW", "NHWC". Defaults to "NCHW". Specify the data format of the input x.
  1494. * @li deformable_groups: Specify the c-axis grouping number of input x.
  1495. * @li modulated: Specify version of DeformableConv2D, true means v2, false means v1
  1496. *@par Outputs:
  1497. * y: A Tensor. A Tensor of type float16, float32.
  1498. */
  1499. REG_OP(DeformableOffsets)
  1500. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1501. .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT}))
  1502. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1503. .REQUIRED_ATTR(strides, ListInt)
  1504. .REQUIRED_ATTR(pads, ListInt)
  1505. .REQUIRED_ATTR(ksize, ListInt)
  1506. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1507. .ATTR(data_format, String, "NCHW")
  1508. .ATTR(deformable_groups, Int, 1)
  1509. .ATTR(modulated, Bool, true)
  1510. .OP_END_FACTORY_REG(DeformableOffsets)
  1511. /**
  1512. *@brief Computes the gradients of DeformableOffsets with respect to input and offsets
  1513. * @par Inputs:
  1514. * Three inputs:
  1515. * @li grad: A Tensor of type float16,float32. gradients with respect to DeformableOffsets output
  1516. * @li x: A Tensor of type float16,float32.
  1517. * @li offsets: A Tensor of type float16,float32.Deformation offset parameter.
  1518. *@par Attributes:
  1519. * @li strides: A tuple/list of 4 integers.The stride of the sliding window for
  1520. * height and width for H/W dimension.
  1521. * @li pads: A tuple/list of 4 integers.Padding added to H/W dimension
  1522. * of the input.
  1523. * @li ksize: A tuple/list of 2 integers.kernel size.
  1524. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1525. * of input. Defaults to [1, 1, 1, 1]
  1526. * @li data_format: An optional string from: "NCHW", "NHWC". Defaults to "NCHW". Specify the data format of the input x.
  1527. * @li deformable_groups: Specify the c-axis grouping number of input x.
  1528. * @li modulated: Specify version of DeformableConv2D, true means v2, false means v1.
  1529. *@par Outputs:
  1530. * @li grad_x: A Tensor of type float16, float32. Gradients with respect to input_x
  1531. * @li grad_offsets: A Tensor of type float16, float32. Gradients with respect to input_offsets
  1532. */
  1533. REG_OP(DeformableOffsetsGrad)
  1534. .INPUT(grad, TensorType({DT_FLOAT16, DT_FLOAT}))
  1535. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1536. .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT}))
  1537. .OUTPUT(grad_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1538. .OUTPUT(grad_offsets, TensorType({DT_FLOAT16, DT_FLOAT}))
  1539. .REQUIRED_ATTR(strides, ListInt)
  1540. .REQUIRED_ATTR(pads, ListInt)
  1541. .REQUIRED_ATTR(ksize, ListInt)
  1542. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1543. .ATTR(data_format, String, "NCHW")
  1544. .ATTR(deformable_groups, Int, 1)
  1545. .ATTR(modulated, Bool, true)
  1546. .OP_END_FACTORY_REG(DeformableOffsetsGrad)
  1547. /**
  1548. *@brief Computes the deformed dilation output with the expected input
  1549. * @par Inputs:
  1550. * One inputs:
  1551. * x: A Tensor of type int8, float16, float32
  1552. *@par Attributes:
  1553. * @li dilations: A tuple/list of integers.
  1554. * @li padding_value: default value filling in blank
  1555. * @li pads: A tuple/list of integers.
  1556. *@par Outputs:
  1557. * y: A Tensor. A Tensor of type int8, float16, float32.
  1558. */
  1559. REG_OP(Dilation)
  1560. .INPUT(x, TensorType({DT_INT8, DT_FLOAT16, DT_FLOAT}))
  1561. .OUTPUT(y, TensorType({DT_INT8, DT_FLOAT16, DT_FLOAT}))
  1562. .REQUIRED_ATTR(dilations, ListInt)
  1563. .ATTR(pads, ListInt, {})
  1564. .ATTR(padding_value, Float, 0.0)
  1565. .OP_END_FACTORY_REG(Dilation)
  1566. /**
  1567. *@brief Computes the post-cube processing output with the expected input
  1568. * @par Inputs:
  1569. * Ten inputs:
  1570. * x1: A Tensor of type float16, bfloat16, float32, int32
  1571. * x2: A Tensor of type float16, int8, int4
  1572. * quant_scale_0: A Tensor of type uint64
  1573. * relu_weight_0: A Tensor of type float32
  1574. * clip_value_0: A Tensor of type float16, int8, int4
  1575. * quant_scale_1: A Tensor of type uint64
  1576. * relu_weight_1: A Tensor of type float32
  1577. * clip_value_1: A Tensor of type float16
  1578. * anti_quant_scale: A Tensor of type float16
  1579. * anti_quant_offset: A Tensor of type int8, int4
  1580. *@par Attributes:
  1581. * @li fusion_op_list: A list of String.
  1582. * @li unit_list: A list of String
  1583. * @li eltwise_mode: An optional string from "ADD", "SUB" and "".
  1584. *@par Outputs:
  1585. * output: A Tensor. A Tensor of type float16, bfloat16, float32, int32, int8, int4.
  1586. */
  1587. REG_OP(FixPipe)
  1588. .INPUT(x1, TensorType({DT_FLOAT16, DT_BF16, DT_FLOAT, DT_INT32}))
  1589. .OPTIONAL_INPUT(x2, TensorType({DT_FLOAT16, DT_INT8, DT_INT4}))
  1590. .OPTIONAL_INPUT(quant_scale_0, TensorType({DT_UINT64}))
  1591. .OPTIONAL_INPUT(relu_weight_0, TensorType({DT_FLOAT}))
  1592. .OPTIONAL_INPUT(clip_value_0, TensorType({DT_FLOAT16, DT_INT8, DT_INT4}))
  1593. .OPTIONAL_INPUT(quant_scale_1, TensorType({DT_UINT64}))
  1594. .OPTIONAL_INPUT(relu_weight_1, TensorType({DT_FLOAT}))
  1595. .OPTIONAL_INPUT(clip_value_1, TensorType({DT_FLOAT16}))
  1596. .OPTIONAL_INPUT(anti_quant_scale, TensorType({DT_FLOAT16}))
  1597. .OPTIONAL_INPUT(anti_quant_offset, TensorType({DT_INT8, DT_INT4}))
  1598. .OUTPUT(output, TensorType({DT_FLOAT16, DT_BF16, DT_FLOAT, DT_INT32, DT_INT8, DT_INT4}))
  1599. .REQUIRED_ATTR(fusion_op_list, ListString)
  1600. .REQUIRED_ATTR(unit_list, ListString)
  1601. .ATTR(eltwise_mode, String, "")
  1602. .OP_END_FACTORY_REG(FixPipe)
  1603. /**
  1604. * @brief Solves a batch of isotonic regression problems. \n
  1605. * @par Inputs:
  1606. * @li input: A Tensor. \n
  1607. * @par Attributes:
  1608. * @li output_dtype: The data type of output. \n
  1609. * @par Outputs:
  1610. * @li output: A Tensor. A Tensor of type float16, float32, double.
  1611. * @li segments: A Tensor. A Tensor of type int32 \n
  1612. */
  1613. REG_OP(IsotonicRegression)
  1614. .INPUT(input, TensorType::RealNumberType())
  1615. .OUTPUT(output, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1616. .OUTPUT(segments, TensorType({DT_INT32}))
  1617. .ATTR(output_dtype, Type, DT_FLOAT)
  1618. .OP_END_FACTORY_REG(IsotonicRegression)
  1619. } // namespace ge
  1620. #endif // OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_

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