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 63 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
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
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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  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: \n
  29. * @li input: 4D origin shape of input tensor [N, C, H, W] or [N, H, W, C],
  30. * support float16, float32, double
  31. * @li filter_size: A 4D tensor of type int32, 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, float32, double . \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, float32,
  51. * double . \n
  52. * @attention Constraints:\n
  53. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  54. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  55. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  56. * [C1, Hf, Wf, K, Co, C0],
  57. * where K is fixed at 1, and Co and C0 are 16.\n
  58. * Output backprop is 4D with shape [N, C, Ho, Wo] or [N, Ho, Wo, C], but the
  59. * data is 5D with shape [N, C1, Ho, Wo, C0],
  60. * where C is the same as that of the feature map and C0 is 16.\n
  61. * Limited by Tiling and L1 / L0 buffer memory: 512 * ceil(Wo, 16) + (480 *
  62. * stride_h + 32 * filter_h) * ceil(Wi, 16) <= l1_size and Hf*Wf <= 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({float16}))
  124. .INPUT(out_backprop, TensorType({float16}))
  125. .OUTPUT(filter_grad, TensorType({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 window for
  144. * 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 each
  148. * 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 of the
  153. * 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: float16 . \n
  159. * @attention Constraints:\n
  160. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  161. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  162. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  163. * [C1, Hf, Wf, K, Co, C0],
  164. * where K is fixed at 1, and Co and C0 are 16.\n
  165. * Output backprop is 4D with shape [N, C, Ho, Wo] or [N, Ho, Wo, C], but the
  166. * data is 5D with shape [N, C1, Ho, Wo, C0],
  167. * where C is the same as that of the feature map and C0 is 16.\n
  168. * Limited by Tiling: max_h_in_l1 >= C0, where max_h_in_l1 = (l1_size - Hf *
  169. * Wf * C0 * C0 * 2) / (2 * Wo *C0).\n
  170. * @par Third-party framework compatibility
  171. * @li Compatible with the TensorFlow operator DepthwiseConv2DBackpropInput.
  172. * @li Compatible with the Caffe operator DepthwiseConv2DBackpropInput.
  173. */
  174. REG_OP(DepthwiseConv2DBackpropInput)
  175. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  176. .INPUT(filter, TensorType({DT_FLOAT16}))
  177. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  178. .OUTPUT(input_grad, TensorType({DT_FLOAT16}))
  179. .REQUIRED_ATTR(strides, ListInt)
  180. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  181. .REQUIRED_ATTR(pads, ListInt)
  182. .ATTR(data_format, String, "NHWC")
  183. .OP_END_FACTORY_REG(DepthwiseConv2DBackpropInput)
  184. /**
  185. * @brief Computes the gradients of depthwise convolution with respect to the
  186. * input . \n
  187. * @par Inputs:
  188. * Two inputs include: \n
  189. * @li filter: A 4D tensor of type float16, with shape [H, W, C, K]
  190. * @li out_backprop: 4D tensor with shape [N, C, H, W] or [N, H, W, C], of
  191. * type float16
  192. * @par Attributes:
  193. * @li input_size: A required list or tuple. The origin shape of input.
  194. * @li strides: A required list or tuple. The stride of the sliding window for
  195. * height and width of input "x" of the convolution.
  196. * Must be with shape [1, 1, stride_height, stride_width] or [1, stride_height,
  197. * stride_width, 1].
  198. * @li dilations: An optional list or tuple. The dilation factor for each
  199. * dimension of input "x".
  200. * If set to k > 1, there will be k-1 skipped cells between each filter element
  201. * on that dimension. Must be with shape [1, 1, dilation_height, dilation_width]
  202. * or [1, dilation_height, dilation_width, 1].
  203. * @li pads: A required list or tuple. Padding added to each dimension of the
  204. * input.
  205. * @li data_format: An optional string. Input data format, either "NHWC" or
  206. * "NCHW" . \n
  207. * @par Outputs:
  208. * input_grad: Gradient of the deep convolution relative to the input with
  209. * shape [N, C, H, W] or [N, H, W, C]. Must be of type float16 . \n
  210. * @attention Constraints:\n
  211. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  212. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  213. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  214. * [C1, Hf, Wf, K, Co, C0],
  215. * where K is fixed at 1, and Co and C0 are 16.\n
  216. * Output backprop is 4D with shape [N, C, Ho, Wo] or [N, Ho, Wo, C], but the
  217. * data is 5D with shape [N, C1, Ho, Wo, C0],
  218. * where C is the same as that of the feature map and C0 is 16.\n
  219. * Limited by Tiling: max_h_in_l1 >= C0, where max_h_in_l1 = (l1_size - Hf *
  220. * Wf * C0 * C0 * 2) / (2 * Wo *C0).\n
  221. * @par Third-party framework compatibility
  222. * @li Compatible with the TensorFlow operator DepthwiseConv2DBackpropInput.
  223. * @li Compatible with the Caffe operator DepthwiseConv2DBackpropInput.
  224. *
  225. * @par Restrictions:
  226. * Warning: THIS FUNCTION IS DEPRECATED. Please use DepthwiseConv2DBackpropInput
  227. * instead.
  228. */
  229. REG_OP(DepthwiseConv2DBackpropInputD)
  230. .INPUT(filter, TensorType({DT_FLOAT16}))
  231. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  232. .OUTPUT(input_grad, TensorType({DT_FLOAT16}))
  233. .REQUIRED_ATTR(input_size, ListInt)
  234. .REQUIRED_ATTR(strides, ListInt)
  235. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  236. .REQUIRED_ATTR(pads, ListInt)
  237. .ATTR(data_format, String, "NHWC")
  238. .OP_END_FACTORY_REG(DepthwiseConv2DBackpropInputD)
  239. /**
  240. *@brief Computes a 2D deep convolution given a 4D input tensor and a filter
  241. * tensor . \n
  242. *@par Inputs:
  243. *Two required inputs and two optional inputs, including: \n
  244. * @li x: A 4D tensor of type float16 or int8, with shape [N, C, H, W] or [N, H, W, C]
  245. * @li filter: A 4D tensor of type float16 or int8, with shape [H, W, C, K]
  246. * @li bias: An optional tensor of type float16 or int32
  247. * @li offset_w: An optional float16 or int8, used for quantized inference
  248. * @par Attributes:
  249. * @li strides: A required list or tuple. The stride of the sliding window for
  250. * height and width of input "x" of the convolution.
  251. * Must be with shape [1, 1, stride_height, stride_width] or [1, stride_height,
  252. * stride_width, 1].
  253. * @li dilations: An optional list or tuple. The dilation factor for each
  254. * dimension of input "x".
  255. * If set to k > 1, there will be k-1 skipped cells between each filter element
  256. * on that dimension. Must be with shape [1, 1, dilation_height, dilation_width]
  257. * or [1, dilation_height, dilation_width, 1]. Defaults to "[1, 1, 1, 1]".
  258. * @li pads: A required list or tuple of int32. Padding added to each dimension of the
  259. * input.
  260. * @li data_format: An optional string. Input data format, either "NHWC" or
  261. * "NCHW". Defaults to "NHWC".
  262. * @li offset_x: An optional int. Input offset, used for quantized inference.
  263. * Defaults to 0 . \n
  264. * @par Outputs:
  265. * y: 4D tensor of type float16 or int32, with shape [N, C, H, W] or [N, H, W, C]
  266. * @attention Constraints:\n
  267. * The feature map is 4D with shape [N, C, Hi, Wi] or [N, Hi, Wi, C], but
  268. * the data is 5D with shape [N, C1, Hi, Wi, C0], where C0 is 16.\n
  269. * The filter is 4D with shape [Hf, Wf, C, K], but the data is 6D with shape
  270. * [C1, Hf, Wf, K, Co, C0],
  271. * where K is fixed at 1, and Co and C0 are 16.\n
  272. * Limited by the size of L1 buffer memory: \n
  273. * (l1_size - filter_h*filter_w*BLOCK_SIZE*BLOCK_SIZE*data_size) // (Wi *
  274. * BLOCK_SIZE * data_size) >= (BLOCK_SIZE * strides_h + filter_h - strides_h).\n
  275. * @par Quantization supported or not
  276. * Yes
  277. * @par Third-party framework compatibility
  278. * @li Compatible with the TensorFlow operator DepthwiseConv2D.
  279. * @li Compatible with the Caffe operator DepthwiseConv2D.
  280. */
  281. REG_OP(DepthwiseConv2D)
  282. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  283. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  284. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  285. .OPTIONAL_INPUT(offset_w, TensorType({DT_FLOAT16, DT_INT8}))
  286. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  287. .REQUIRED_ATTR(strides, ListInt)
  288. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  289. .REQUIRED_ATTR(pads, ListInt)
  290. .ATTR(data_format, String, "NHWC")
  291. .ATTR(offset_x, Int, 0)
  292. .OP_END_FACTORY_REG(DepthwiseConv2D)
  293. /**
  294. *@brief Performs the the backward operation for "BiasAdd" on the "bias" tensor.
  295. * It accumulates all the values from out_backprop into the feature
  296. * dimension. For NHWC data format, the feature dimension is the last.
  297. * For NCHW data format, the feature dimension is the third-to-last . \n
  298. *@par Inputs:
  299. *x: A Tensor of type NumberType . \n
  300. *@par Attributes:
  301. *data_format: Data format. Defaults to "NHWC" . \n
  302. *@par Outputs:
  303. *y: A Tensor.Has the same type as "x" . \n
  304. *@par Third-party framework compatibility
  305. * Compatible with the TensorFlow operator BiasAddGrad.
  306. */
  307. REG_OP(BiasAddGrad)
  308. .INPUT(x, TensorType::NumberType())
  309. .OUTPUT(y, TensorType::NumberType())
  310. .ATTR(data_format, String, "NHWC")
  311. .OP_END_FACTORY_REG(BiasAddGrad)
  312. /**
  313. *@brief Computes the gradients of convolution with respect to the input.
  314. *@par Inputs:
  315. * Three inputs:
  316. * @li input_size: A const Tensor of type int32. Currently does not support
  317. * data tensor. An integer vector representing the shape of input, where
  318. * input is a 4-D tensor [batch, height, width, channels]
  319. * or [batch, channels, height, width].
  320. * @li filter: A Tensor. Must be one of the following types: float16, float32,
  321. * float64. 4-D with shape
  322. * [filter_height, filter_width, in_channels, out_channels]
  323. * or [out_channels, filter_height, filter_width, in_channels]
  324. * or [out_channels, in_channel, filter_height, filter_width].
  325. * @li out_backprop: A Tensor. Must have the same type as filter.
  326. * 4-D with shape [batch, out_height, out_width, out_channels]
  327. * or [batch, out_channels, out_height, out_width].
  328. * Gradients with respect to the output of the convolution.
  329. *@par Attributes:
  330. * Five attributes:
  331. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  332. * for H/W dimension. The index of H/W is same as data_format.
  333. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads
  334. * on feature map
  335. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  336. * dimension of input, defaults to [1,1,1,1].
  337. * @li groups: Number of blocked connections from input channels to output
  338. * channels.
  339. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  340. * "NHWC". Specify the data format of the input and output data.
  341. *@par Outputs:
  342. * y: A Tensor. Has the same type as filter,and has same format as input_size.
  343. *@par Third-party framework compatibility
  344. * Compatible with Tensorflow's conv2d_backprop_input
  345. */
  346. REG_OP(Conv2DBackpropInput)
  347. .INPUT(input_size, TensorType({DT_INT32}))
  348. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  349. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  350. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  351. .REQUIRED_ATTR(strides, ListInt)
  352. .REQUIRED_ATTR(pads, ListInt)
  353. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  354. .ATTR(groups, Int, 1)
  355. .ATTR(data_format, String, "NHWC")
  356. .OP_END_FACTORY_REG(Conv2DBackpropInput)
  357. /**
  358. *@brief Computes the gradients of convolution with respect to the input.
  359. *@par Inputs:
  360. * Two inputs:
  361. * @li filter: A Tensor. Types is float16.
  362. * 4-D with shape [filter_height, filter_width, in_channels, out_channels]
  363. * or [out_channels, filter_height, filter_width, in_channels]
  364. * or [out_channels, in_channel, filter_height, filter_width].
  365. * @li out_backprop: A Tensor. Must have the same type as filter.
  366. * 4-D with shape [batch, out_height, out_width, out_channels]
  367. * or [batch, out_channels, out_height, out_width].
  368. * Gradients with respect to the output of the convolution.
  369. *@par Attributes:
  370. * Six attributes:
  371. * @li input_size A Tensor of type int32. An integer vector representing the
  372. * shape of input, where input is a 4-D tensor [batch, height, width, channels]
  373. * or [batch, channels, height, width].
  374. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  375. * for H/W dimension. The index of H/W is same as data_format.
  376. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads on
  377. * feature map
  378. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  379. * dimension of input, defaults to [1,1,1,1].
  380. * @li groups: Number of blocked connections from input channels to output
  381. * channels.
  382. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  383. * "NHWC". Specify the data format of the input and output data.
  384. *@par Outputs:
  385. * y: A Tensor. Has the same type as filter,4-D tensor [batch, height, width,
  386. * channels] or [batch, channels, height, width].
  387. *@par Third-party framework compatibility
  388. * Compatible with Tensorflow's conv2d_backprop_input
  389. *@par Restrictions:
  390. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DBackpropInput instead.
  391. */
  392. REG_OP(Conv2DBackpropInputD)
  393. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  394. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_INT8}))
  395. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  396. .REQUIRED_ATTR(input_size, ListInt)
  397. .REQUIRED_ATTR(strides, ListInt)
  398. .REQUIRED_ATTR(pads, ListInt)
  399. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  400. .ATTR(groups, Int, 1)
  401. .ATTR(data_format, String, "NHWC")
  402. .OP_END_FACTORY_REG(Conv2DBackpropInputD)
  403. /**
  404. *@brief Computes the Deconvolution with respect to the input.
  405. *@par Inputs:
  406. * Three inputs:
  407. * @li x: A Tensor of type float16 or int8. 4D with shape
  408. * [batch, out_channels, out_height, out_width]. Gradients with respect
  409. * to the output of the convolution.
  410. * @li filter: A Tensor. Must have the same type as "x".
  411. * 4D with shape [out_channels, in_channel, filter_height, filter_width].\n
  412. * Two optional inputs:
  413. * @li bias: An optional tensor. Must have the same type as "y".
  414. * @li offset_w: An optional 1D tensor for quantized deconvolution.
  415. * Type is int8. Reserved.\n
  416. *@par Attributes:
  417. * Six attributes:
  418. * @li strides: A tuple or list of 2 integers. The stride of the sliding window
  419. * for H/W dimension, defaults to [1,1].
  420. * @li pads: A tuple or list of 4 integers. The [top, bottom, left, right]
  421. * padding on the feature map, defaults to [0,0,0,0].
  422. * @li dilations: A tuple or list of 4 integers. The dilation factor for each
  423. * dimension of input, defaults to [1,1,1,1].
  424. * @li groups: Number of blocked connections from input channels to
  425. output channels. Defaults to "1".
  426. * @li data_format: An optional string from: "NCHW". Defaults to "NCHW". \n
  427. Specify the data format of the input and output data.
  428. * @li offset_x: An optional integer for quantized deconvolution.
  429. * Defaults to "0".
  430. *@par Outputs:
  431. * y: A Tensor. 4D tensor with shape [batch, channels, height, width].
  432. * When type of x is float16, the type of y must be float16.
  433. * When type of x is int8, the type of y must be int32.
  434. */
  435. REG_OP(Deconvolution)
  436. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  437. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  438. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  439. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  440. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  441. .ATTR(strides, ListInt, {1, 1})
  442. .ATTR(pads, ListInt, {0, 0, 0, 0})
  443. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  444. .ATTR(groups, Int, 1)
  445. .ATTR(data_format, String, "NCHW")
  446. .ATTR(offset_x, Int, 0)
  447. .OP_END_FACTORY_REG(Deconvolution)
  448. /**
  449. *@brief Computes the gradients of convolution with respect to the filter
  450. *@par Inputs:
  451. * Three inputs:
  452. * @li x: A Tensor. Must be one of the following types: float16, float32,
  453. * float64.4-D with shape [batch, in_height, in_width, in_channels] or
  454. * [batch, in_channels, in_height, in_width].
  455. * @li filter_size: A const Tensor of type int32. Currently does not support
  456. * data tensor. An integer vector representing the tensor shape of filter,
  457. * where filter is a 4-D tensor [filter_height, filter_width, in_channels,
  458. * out_channels] or [out_channels, filter_height, filter_width, in_channels]
  459. * or [out_channels, in_channel, filter_height, filter_width].
  460. * @li out_backprop: A Tensor. Must have the same type as x. 4-D with shape
  461. * [batch, out_height, out_width, out_channels] or [batch, out_channels,
  462. * out_height, out_width]. Gradients with respect to the output of the
  463. * convolution.
  464. *@par Attributes:
  465. * Five attributes:
  466. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  467. * for H/W dimension. The index of H/W is same as data_format.
  468. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads on
  469. * feature map.
  470. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  471. * dimension of input, defaults to [1,1,1,1].
  472. * @li groups: Number of blocked connections from input channels to output
  473. * channels.
  474. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  475. * "NHWC". Specify the data format of the input and output data.
  476. *@par Outputs:
  477. * y: A Tensor. Has the same type as x, has the same format as filter_size.
  478. *@par Third-party framework compatibility
  479. * Compatible with Tensorflow's conv2d_backprop_filter
  480. */
  481. REG_OP(Conv2DBackpropFilter)
  482. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  483. .INPUT(filter_size, TensorType({DT_INT32}))
  484. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  485. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  486. .REQUIRED_ATTR(strides, ListInt)
  487. .REQUIRED_ATTR(pads, ListInt)
  488. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  489. .ATTR(groups, Int, 1)
  490. .ATTR(data_format, String, "NHWC")
  491. .OP_END_FACTORY_REG(Conv2DBackpropFilter)
  492. /**
  493. *@brief Computes the gradients of convolution with respect to the filter.
  494. *@par Inputs:
  495. * Two inputs:
  496. * @li x: A Tensor. Type is float16.
  497. * 4-D with shape [batch, in_height, in_width, in_channels] or [batch,
  498. * in_channels, in_height, in_width].
  499. * @li out_backprop: A Tensor. Must have the same type as x. 4-D with shape
  500. * [batch, out_height, out_width, out_channels] or [batch, out_channels,
  501. * out_height, out_width]. Gradients with respect to the output of the
  502. * convolution.
  503. *@par Attributes:
  504. * Six attributes:
  505. * @li filter_size: A Tensor of type integers. An integer vector representing
  506. * the tensor shape of filter,
  507. * where filter is a 4-D tensor [filter_height, filter_width, in_channels,
  508. * out_channels] or [out_channels, filter_height, filter_width, in_channels]
  509. * or [out_channels, in_channel, filter_height, filter_width].
  510. * @li strides: A tuple/list of 4 integers. The stride of the sliding window
  511. * for H/W dimension. The index of H/W is same as data_format.
  512. * @li pads: A tuple/list of 4 integers, [top, bottom, left, right] pads on
  513. * feature map
  514. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  515. * dimension of input, defaults to [1,1,1,1].
  516. * @li groups: Number of blocked connections from input channels to output
  517. * channels.
  518. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to
  519. * "NHWC". Specify the data format of the input and output data.
  520. *@par Outputs:
  521. * y: A Tensor. Type is float32, a 4-D tensor [filter_height, filter_width,
  522. * in_channels, out_channels] or [out_channels, filter_height, filter_width,
  523. * in_channels] or [out_channels, in_channel, filter_height, filter_width].
  524. * Compatible with Tensorflow's conv2d_backprop_filter
  525. *@par Restrictions:
  526. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DBackpropFilter instead.
  527. */
  528. REG_OP(Conv2DBackpropFilterD)
  529. .INPUT(x, TensorType({DT_FLOAT16}))
  530. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  531. .OUTPUT(y, TensorType({DT_FLOAT}))
  532. .REQUIRED_ATTR(filter_size, ListInt)
  533. .REQUIRED_ATTR(strides, ListInt)
  534. .REQUIRED_ATTR(pads, ListInt)
  535. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  536. .ATTR(groups, Int, 1)
  537. .ATTR(data_format, String, "NHWC")
  538. .OP_END_FACTORY_REG(Conv2DBackpropFilterD)
  539. /**
  540. *@brief Computes a 2D convolution given 4D "x" and "filter" tensors.
  541. *@par Inputs:
  542. *@li x: A 4D tensor of input images. With "NHWC" format, the shape is
  543. * [batch, in_height, in_width, in_channels].
  544. *@li filter: A 4D tensor of filters. Has the same type as "x". With "HWCN"
  545. * format, the shape is [filter_height, filter_width, in_channels,
  546. * out_channels].
  547. *@li bias: An optional 1D tensor. Shape is [out_channels].
  548. *@li offset_w: An optional 1D tensor for quantized convolution. Shape is
  549. * [out_channels]. Not supported.
  550. *\n
  551. *\n
  552. * Note that there is a strict data type mapping between the input and output
  553. * tensors:
  554. *@verbatim
  555. |Tensor | x | filter | bias | offset_w | y
  556. -----------|---------|---------|---------|----------|--------
  557. |Data Type | float16 | float16 | float16 | _ | float16
  558. | |---------|---------|---------|----------|--------
  559. | | float32 | float32 | float32 | _ | float32
  560. | |---------|---------|---------|----------|--------
  561. | | int8 | int8 | int32 | int8 | int32
  562. -----------|---------|---------|---------|----------|--------
  563. |Format | NCHW | NCHW | ND | ND | NCHW
  564. | | NHWC | HWCN | | | NHWC
  565. @endverbatim
  566. * Type float32 is allowed only in mixed precision (float32->float16) scenarios.
  567. * Mixed precision is enabled by default.
  568. * \n
  569. *
  570. *@par Attributes:
  571. *@li strides: Required. A list of 4 integers. Specifying the strides of the
  572. * convolution along the height and width. The dimension order is determined
  573. * by the data format of "x". By default the N and C dimensions are set to 1.
  574. *@li pads: Required. A list of 4 integers. Specifying the top, bottom, left
  575. * and right padding.
  576. * @li dilations: Optional. A list of 4 integers. Specifying the dilation rate
  577. * to use for dilated convolution. Has the same dimension order and value as
  578. * "strides". Dilation > 1 is not supported for quantized convolution. Defaults
  579. * to [1, 1, 1, 1].
  580. * @li groups: Optional. An integer of type int32, for the number of blocked
  581. * connections from input channels to output channels. Input channels and output
  582. * channels must both be divisible by "groups". "x" in_channels must be equal to
  583. * "filter" in_channels * groups. Defaults to 1.
  584. * @li offset_x: Optional. An integer of type int32, for quantized convolution.
  585. * Defaults to 0.
  586. * @li data_format: Reserved and optional. A string from: "NHWC" and "NCHW".
  587. * Specifying the data format of the input and output images. Defaults to
  588. * "NHWC".
  589. *\n
  590. *\n
  591. * The following value range restrictions must be met:
  592. *@verbatim
  593. |Name | Field | Scope
  594. ------------------|----------|----------
  595. |Input Image Size | H | [1, 100000]
  596. | | W | [1, 4096]
  597. ------------------|----------|----------
  598. |Filter Size | H | [1, 255]
  599. | | W | [1, 255]
  600. ------------------|----------|----------
  601. |Stride | H | [1, 63]
  602. | | W | [1, 63]
  603. ------------------|----------|----------
  604. |Padding | top | [0, 255]
  605. | | bottom | [0, 255]
  606. | | left | [0, 255]
  607. | | right | [0, 255]
  608. ------------------|----------|----------
  609. |Dilation | H | [1, 255]
  610. | | W | [1, 255]
  611. @endverbatim
  612. *
  613. *@par Outputs:
  614. *@li y: A 4D Tensor of output images. Has the same type and format as "x". With
  615. * "NHWC" format, the shape is [batch, out_height, out_width, out_channels].
  616. *\n
  617. * out_height = (in_height + top_pad + bottom_pad -
  618. * dilation_h * (filter_height - 1) - 1)
  619. * / stride_h + 1
  620. *\n
  621. * out_width = (in_width + left_pad + right_pad -
  622. * dilation_w * (filter_width - 1) - 1)
  623. * / stride_w + 1
  624. *
  625. *@attention Constraints:
  626. *@li The following restrictions on the output must be met:
  627. *@verbatim
  628. | Output | Restrictions
  629. -------------------|---------------------------
  630. | W dimension == 1 | H*W(input) == H*W(filter)
  631. | H dimension == 1 |
  632. -------------------|---------------------------
  633. | W dimension == 1 | Not supported
  634. | H dimension != 1 |
  635. @endverbatim
  636. * "H * W (input)" indicates the image size after padding and "H * W (filter)"
  637. * indicates the filter size after dilation.
  638. *\n
  639. *
  640. *@par Quantization supported or not
  641. *@li Yes
  642. *
  643. *@par Third-party framework compatibility
  644. *@li Compatible with the TensorFlow operator "conv2d".
  645. *@li Compatible with the Caffe operator 2D "Convolution".
  646. */
  647. REG_OP(Conv2D)
  648. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  649. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  650. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  651. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  652. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  653. .REQUIRED_ATTR(strides, ListInt)
  654. .REQUIRED_ATTR(pads, ListInt)
  655. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  656. .ATTR(groups, Int, 1)
  657. .ATTR(data_format, String, "NHWC")
  658. .ATTR(offset_x, Int, 0)
  659. .OP_END_FACTORY_REG(Conv2D)
  660. /**
  661. *@brief Computes a 2D convolution given 4D "x" and "filter_compress" tensors.
  662. *@par Inputs:
  663. * @li x: A 4D tensor of input images.
  664. * @li filter_compress: A 4D tensor of compressed filters.
  665. * @li compress_index: A 1D Tensor dtype of int8.
  666. * @li bias: An optional 1D tensor.
  667. * @li offset_w: An optional 1D tensor for quantized convolution. Reserved.
  668. *
  669. * The input and output tensor attributes are listed as follows:
  670. * @verbatim
  671. |Tensor | x | filter_compress | bias | offset_w | y
  672. -----------|---------|---------|---------|----------|--------
  673. |Data Type | float16 | float16 | float16 | _ | float16
  674. | |---------|---------|---------|----------|--------
  675. | | float32 | float32 | float32 | _ | float32
  676. | |---------|---------|---------|----------|--------
  677. | | int8 | int8 | int32 | int8 | int32
  678. -----------|---------|---------|---------|----------|--------
  679. |Format | NCHW | NCHW | ND | ND | NCHW
  680. | | NHWC | HWCN | | | NHWC
  681. @endverbatim
  682. * Type float32 is allowed only in mixed precision (float32->float16) scenarios.
  683. * Mixed precision is enabled by default.
  684. * \n
  685. *
  686. *@par Attributes:
  687. *@li strides: Required. A list of 4 integers. Specifying the strides of the
  688. * convolution along the height and width. The dimension order is determined
  689. * by the data format of "x". By default the N and C dimensions are set to 1.
  690. * @li pads: A list of 4 integers. Specifying the top, bottom, left and right
  691. * padding.
  692. * @li dilations: A list of 4 integers. Specifying the dilation rate to use
  693. * for dilated convolution. Has the same dimension order and value as "strides".
  694. * @li groups: Number of blocked connections from input channels to output
  695. * channels. Input channels and output channels must both be divisible by
  696. * "groups".Type is int32.
  697. * @li offset_x: An optional integer for quantized convolution. Type is int32.
  698. * Defaults to "0".
  699. * @li data_format: An optional string from: "NHWC", "NCHW". Specifying the
  700. * data format of the input and output images. Type is string.
  701. * Defaults to "NHWC". Reserved . \n
  702. *@par Outputs:
  703. * @li y: A 4D Tensor of output images . \n
  704. *@par Restrictions:
  705. *Warning: THIS FUNCTION IS DEPRECATED.
  706. */
  707. REG_OP(Conv2DCompress)
  708. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  709. .INPUT(filter_compress, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  710. .INPUT(compress_index, TensorType({DT_INT8}))
  711. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  712. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  713. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  714. .REQUIRED_ATTR(strides, ListInt)
  715. .REQUIRED_ATTR(pads, ListInt)
  716. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  717. .ATTR(groups, Int, 1)
  718. .ATTR(data_format, String, "NHWC")
  719. .ATTR(offset_x, Int, 0)
  720. .OP_END_FACTORY_REG(Conv2DCompress)
  721. /**
  722. *@brief Computes a 2D convolution given 4D "x", "filter" and "offsets"
  723. * tensors.
  724. *@par Inputs:
  725. * @li x: A 4D tensor of input images. With shape of
  726. * [batch, in_height, in_width, in_channels] when format is "NHWC".
  727. * @li filter: A 4D tensor of filters. Must have the same type as "x". With
  728. * shape of [filter_height, filter_width, in_channels, out_channels] when format
  729. * is "HWCN".
  730. * @li offsets: A 4D tensor of offsets. With shape of
  731. * [batch, deformable_groups * filter_height * filter_width * 3, in_height,
  732. * in_width] when format is "NCHW".
  733. * @li bias: An optional 1D tensor. Shape is [out_channels].
  734. *
  735. * The input and output tensor attributes are listed as follows:
  736. * @verbatim
  737. |Tensor | x | filter | offsets | bias | y
  738. -----------|---------|---------|---------|----------|--------
  739. |Data Type | float16 | float16 | float16 | float16 | float16
  740. -----------|---------|---------|---------|----------|--------
  741. |Format | NCHW | NCHW | NCHW | ND | NCHW
  742. | | NHWC | HWCN | | | NHWC
  743. @endverbatim
  744. * It should be noted that the data types must correspond to each other, but
  745. * the format does not need to.
  746. *@par Attributes:
  747. * @li strides: Required. A list of 4 integers. Specifying the strides of the
  748. * convolution along the height and width. The dimension order is determined
  749. * by the data format of "x". By default the N and C dimensions are set to 1.
  750. * @li pads: Required. A list of 4 integers. Specifying the top, bottom, left
  751. * and right padding.
  752. * @li dilations: Optional. A list of 4 integers. Specifying the dilation rate
  753. * to use for dilated convolution. Has the same dimension order and value as
  754. * "strides".
  755. * @li groups: Optional. Number of blocked connections from input channels to
  756. * output channels. Input channels and output channels must both be divisible
  757. * by "groups".Type is int32.
  758. * @li data_format: Optional. An optional string from: "NHWC", "NCHW". Specifying the
  759. * data format of the input and output images. Type is string. Defaults to
  760. * "NHWC". Reserved.
  761. * @li deformable_groups: Optional. Cut the c chanel of input X into deformable_groups,
  762. * each share a different offsets. Input channels must be divisible by
  763. * "deformable_groups". Type is int32.
  764. *@par Outputs:
  765. * @li y: A 4D Tensor of output images. Must have the same type and format as
  766. * "x". With shape of [batch, out_channels, out_height, out_width] when format
  767. * is "NHWC".
  768. * @li output_height = (in_height + top_pad + botton_pad -
  769. * dilation_h * (filter_height - 1) -1) / stride_h + 1
  770. * @li output_width = (in_width + left_pad + right_pad -
  771. * dilation_w * (filter_width - 1) -1) / stride_w + 1
  772. *@attention
  773. * @li The parameter scope is listed as follows:
  774. * @verbatim
  775. |Name | Field | Scope
  776. ------------------|--------------|----------------------------------------
  777. |Input Image Size | H dimension | 1 <= in_height * filter_height <= 4096
  778. | | W dimension | 1 <= in_width * filter_width <=4096
  779. ------------------|--------------|----------------------------------------
  780. |Filter Size | H dimension | [1, 255]
  781. | | W dimension | [1, 255]
  782. ------------------|--------------|----------------------------------------
  783. |offsets Size | C dimension | offsets_c = deformable_groups *
  784. | | | filter_width * filter_height * 3
  785. | | H dimension | the same as output H dimension
  786. | | W dimension | the same as output W dimension
  787. ------------------|--------------|----------------------------------------
  788. |Stride Size | H dimension | [1, 63]
  789. | | W dimension | [1, 63]
  790. ------------------|--------------|----------------------------------------
  791. |Padding Size | top side | [0, 255]
  792. | | bottom side | [0, 255]
  793. | | left side | [0, 255]
  794. | | right side | [0, 255]
  795. ------------------|--------------|----------------------------------------
  796. |Dilation Size | H dimension | [1, 255]
  797. | | W dimension | [1, 255]
  798. @endverbatim
  799. * @li There are restrictions for certain scenarios:
  800. * @verbatim
  801. | Output | Restrictions
  802. -------------------|---------------------------
  803. | W dimension == 1 | HxW(input) == HxW(filter)
  804. | H dimension == 1 |
  805. -------------------|---------------------------
  806. | W dimension == 1 | Not supported
  807. | H dimension != 1 |
  808. @endverbatim
  809. * As shown above, "HxW(input)" indicates the image size after padding and
  810. * "HxW(filter)" indicates the filter size after dilation.
  811. *@par Quantization supported or not
  812. *@li Yes
  813. *
  814. *@par Third-party framework compatibility
  815. *@li Compatible with the TensorFlow operator "conv2d".
  816. *@li Compatible with the Caffe operator 2D "Convolution".
  817. */
  818. REG_OP(DeformableConv2D)
  819. .INPUT(x, TensorType({DT_FLOAT16}))
  820. .INPUT(filter, TensorType({DT_FLOAT16}))
  821. .INPUT(offsets, TensorType({DT_FLOAT16}))
  822. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  823. .OUTPUT(y, TensorType({DT_FLOAT16}))
  824. .REQUIRED_ATTR(strides, ListInt)
  825. .REQUIRED_ATTR(pads, ListInt)
  826. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  827. .ATTR(groups, Int, 1)
  828. .ATTR(data_format, String, "NHWC")
  829. .ATTR(deformable_groups, Int, 1)
  830. .OP_END_FACTORY_REG(DeformableConv2D)
  831. /**
  832. *@brief Computes a 3D convolution given 5D "x" and "filter" tensors.
  833. *@par Inputs:
  834. * @li x: A 5D tensor. Must be one of the following types: float16,
  835. * (Currently does not support int8). The format of x is NCDHW or NDHWC.
  836. * @li filter: A 5D tensor of the same type as "x".
  837. * (Currently does not support int8).
  838. * The format is NCDHW, NDHWC or DHWCN . \n
  839. *@par Optional input:
  840. * @li bias: An optional 1D tensor of the same type as "x".
  841. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  842. *@par Required Attributes:
  843. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  844. * for each dimension of "x".
  845. * The N and C dimensions must be 1. Has the same format as "x".
  846. * @li pads: A list of 6 integers.
  847. * Supports only padding along the D, H and W dimensions in sequence of head,
  848. * tail, top, bottom, left and right . \n
  849. *@par Attributes:
  850. * @li groups: Number of blocked connections from input channels to output
  851. * channels. Reserved.
  852. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  853. * Defaults to "NDHWC". Specify the data format of the input and output data.
  854. * @li dilations: A list of 5 integers. Specifies the dilation factor for each
  855. * dimension of "x", now only support [1,1,1,1,1]
  856. * The N and C dimensions must be 1. Has the same format as "x".
  857. * @li offset_x: An optional int. Input offset, used for quantized inference.
  858. * Defaults to 0. Reserved . \n
  859. *@par Outputs:
  860. *y: A Tensor. Has the same type and data format as "x". \n
  861. *@attention Constraints:
  862. *The image size after padding is greater than the filter size . \n
  863. *@par Third-party framework compatibility
  864. * @li Compatible with the TensorFlow operator conv3d.
  865. * @li Compatible with the Caffe operator Convolution.
  866. */
  867. REG_OP(Conv3D)
  868. .INPUT(x, TensorType({DT_FLOAT16}))
  869. .INPUT(filter, TensorType({DT_FLOAT16}))
  870. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  871. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  872. .OUTPUT(y, TensorType({DT_FLOAT16}))
  873. .REQUIRED_ATTR(strides, ListInt)
  874. .REQUIRED_ATTR(pads, ListInt)
  875. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  876. .ATTR(groups, Int, 1)
  877. .ATTR(data_format, String, "NDHWC")
  878. .ATTR(offset_x, Int, 0)
  879. .OP_END_FACTORY_REG(Conv3D)
  880. /**
  881. *@brief Computes the gradients of convolution 3d with respect to the input.
  882. *@par Inputs:
  883. * Three inputs:
  884. * @li input_size: A Tensor of type int32, int64. An integer vector representing
  885. * the shape of input, where input is a 5-D tensor
  886. * [batch, depth, height, width, channels] or
  887. * [batch, channels, depth, height, width].
  888. * @li filter: A Tensor. Must be one of the following types: float16, float32.
  889. * Currently does not support double.
  890. * @li out_backprop: A Tensor. Must have the same type as filter.
  891. * 5-D with shape [batch, depth, out_height, out_width, out_channels]
  892. * or [batch, out_channels, depth, out_height, out_width]. Gradients with
  893. * respect to the output of the convolution . \n
  894. *@par Required Attributes:
  895. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  896. * for each dimension of "x".
  897. * The N and C dimensions must be 1. Has the same format as "x".
  898. * @li pads: A list of 6 integers.
  899. * Supports only padding along the D, H and W dimensions in sequence of head,
  900. * tail, top, bottom, left and right . \n
  901. *@par Attributes:
  902. * Three attributes:
  903. * @li groups: Number of blocked connections from input channels to output
  904. * channels. Reserved.
  905. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  906. * Defaults to "NDHWC". Specify the data format of the input and output data.
  907. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  908. * dimension of the input, now only support [1,1,1,1,1]
  909. *@par Outputs:
  910. * y: A Tensor. Has the same type as filter,and has same format as input_size
  911. *@par Third-party framework compatibility
  912. * Compatible with Tensorflow's conv3d_backprop_input
  913. */
  914. REG_OP(Conv3DBackpropInput)
  915. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  916. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  917. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  918. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  919. .REQUIRED_ATTR(strides, ListInt)
  920. .REQUIRED_ATTR(pads, ListInt)
  921. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  922. .ATTR(groups, Int, 1)
  923. .ATTR(data_format, String, "NDHWC")
  924. .OP_END_FACTORY_REG(Conv3DBackpropInput)
  925. /**
  926. *@brief Computes the gradients of convolution 3d with respect to the input.
  927. *@par Inputs:
  928. * Two inputs:
  929. * @li filter: A Tensor whose type is float16. The format of filter is NCDHW,
  930. * NDHWC or DHWCN.
  931. * @li out_backprop: A Tensor. Must have the same type as filter. The format is
  932. * NDHWC or NCDHW. \n
  933. *@par Required Attributes:
  934. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  935. * for each dimension of "x".
  936. * The N and C dimensions must be 1. Has the same format as "x".
  937. * @li pads: A list of 6 integers. Supports only padding along the D, H and W
  938. * dimensions in sequence of head, tail, top, bottom, left and right.
  939. * @li input_size: A tuple/list of type int32, int64. An integer vector
  940. * representing the shape of input, where input is a 5-D tensor
  941. * [batch, depth, height, width, channels] or
  942. * [batch, channels, depth, height, width] . \n
  943. *@par Attributes:
  944. * Three attributes:
  945. * @li groups: Number of blocked connections from input channels to output
  946. * channels. Reserved.
  947. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  948. * Defaults to "NDHWC". Specify the data format of the input and output data.
  949. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  950. * dimension of input, now only support [1,1,1,1,1]
  951. *@par Outputs:
  952. * y: A Tensor. Has the same type and data format as out_backprop.
  953. *@par Third-party framework compatibility
  954. * Compatible with Tensorflow's conv3d_backprop_input
  955. *@par Restrictions:
  956. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropInput instead.
  957. */
  958. REG_OP(Conv3DBackpropInputD)
  959. .INPUT(filter, TensorType({DT_FLOAT16}))
  960. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  961. .OUTPUT(y, TensorType({DT_FLOAT16}))
  962. .REQUIRED_ATTR(input_size, ListInt)
  963. .REQUIRED_ATTR(strides, ListInt)
  964. .REQUIRED_ATTR(pads, ListInt)
  965. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  966. .ATTR(groups, Int, 1)
  967. .ATTR(data_format, String, "NDHWC")
  968. .OP_END_FACTORY_REG(Conv3DBackpropInputD)
  969. /**
  970. *@brief Applies a multi-layer long short-term memory (LSTM) RNN to an input sequence . \n
  971. *@par Inputs:
  972. * @li x: A Tensor dtype of float16.
  973. * @li cont: A Tensor dtype of float16, float32.
  974. * @li w_x: A Tensor dtype of float16.
  975. * @li bias: A Tensor dtype of int16, int32, float16, float32.
  976. * @li w_h: A Tensor dtype of float16.
  977. * @li x_static: A optinal Tensor dtype of float16.
  978. * @li h_0: A optinal Tensor dtype of float16, float32.
  979. * @li c_0: A optinal Tensor dtype of float16, float32.
  980. * @li w_x_static: A optinal Tensor dtype of float16 . \n
  981. *@par Attributes:
  982. *@li num_output: A Scalar of output size dtype of int.
  983. *@li expose_hidden: A Scalar(bool) of features hidden . \n
  984. *@par Outputs:
  985. *@li h: A Tensor dtype of float16, float32.
  986. * @li h_t: A optinal Tensor dtype of float16, float32. The hidden state at time t.
  987. * @li c_t: A optinal Tensor dtype of float16, float32. The cell state at time t . \n
  988. *@par Third-party framework compatibility:
  989. * Compatible with the Pytorch operator adds.
  990. *@par Restrictions:
  991. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  992. */
  993. REG_OP(LSTM)
  994. .INPUT(x, TensorType({DT_FLOAT16}))
  995. .INPUT(cont, TensorType({DT_FLOAT32,DT_FLOAT16}))
  996. .INPUT(w_x, TensorType({DT_FLOAT16}))
  997. .INPUT(bias, TensorType({DT_FLOAT16,DT_FLOAT32,DT_INT16,DT_INT32}))
  998. .INPUT(w_h, TensorType({DT_FLOAT16}))
  999. .OPTIONAL_INPUT(x_static, TensorType({DT_FLOAT16}))
  1000. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1001. .OPTIONAL_INPUT(c_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1002. .OPTIONAL_INPUT(w_x_static, TensorType({DT_FLOAT16}))
  1003. .OUTPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1004. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1005. .OUTPUT(c_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1006. .ATTR(num_output, Int, 0)
  1007. .ATTR(expose_hidden, Bool, false)
  1008. .OP_END_FACTORY_REG(LSTM)
  1009. /**
  1010. *@brief Computes the gradients of convolution3D with respect to the filter
  1011. *@par Inputs:
  1012. * Three inputs:
  1013. * @li x: A Tensor. Must be one of the following types: float16, float32.
  1014. * Currently does not support double.
  1015. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1016. * or [batch, in_channels, in_depth, in_height, in_width].
  1017. * @li filter_size: A Tensor of type int32. An integer vector representing the
  1018. * tensor shape of filter, where filter is a 5-D tensor
  1019. * [filter_depth, filter_height, filter_width, in_channels, out_channels]
  1020. * [out_channels, in_channels, filter_depth, filter_height, filter_width]
  1021. * or [out_channels, filter_depth, filter_height, filter_width, in_channels].
  1022. * @li out_backprop: A Tensor. Must have the same type as x.
  1023. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1024. * or [batch, out_channels, out_depth, out_height, out_width].
  1025. * Gradients with respect to the output of the convolution. \n
  1026. *@par Required Attributes:
  1027. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1028. * window for each dimension of "x". The N and C dimensions must be 1.
  1029. * Has the same format as "x".
  1030. * @li pads: A tuple/list of 6 integers, [front, back, top, bottom, left, right]
  1031. * pads on feature map . \n
  1032. *@par Attributes:
  1033. * Three attributes:
  1034. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1035. * dimension of input, now only support [1,1,1,1,1].
  1036. * @li groups: Number of blocked connections from input channels to output
  1037. * channels. Reserved.
  1038. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1039. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1040. *@par Outputs:
  1041. * y: A Tensor that has the same type as x
  1042. * and the format is NDHWC, NCDHW or DHWCN.
  1043. *@par Third-party framework compatibility
  1044. * Compatible with Tensorflow's conv3d_backprop_filter
  1045. */
  1046. REG_OP(Conv3DBackpropFilter)
  1047. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1048. .INPUT(filter_size, TensorType({DT_INT32}))
  1049. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1050. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1051. .REQUIRED_ATTR(strides, ListInt)
  1052. .REQUIRED_ATTR(pads, ListInt)
  1053. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1054. .ATTR(groups, Int, 1)
  1055. .ATTR(data_format, String, "NDHWC")
  1056. .OP_END_FACTORY_REG(Conv3DBackpropFilter)
  1057. /**
  1058. *@brief Computes the gradients of convolution with respect to the filter.
  1059. *@par Inputs:
  1060. * Two inputs:
  1061. * @li x: A Tensor of type float16.
  1062. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1063. * or [batch, in_channels, in_depth, in_height, in_width].
  1064. * @li out_backprop: A Tensor. Must have the same type as x.
  1065. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1066. * or [batch, out_channels, out_depth, out_height, out_width].
  1067. * Gradients with respect to the output of the convolution. \n
  1068. *@par Required Attributes:
  1069. * @li filter_size: A tuple/list of type integers. An integer vector
  1070. * representing the tensor shape of filter, where filter is a 5-D tensor
  1071. * [filter_depth, filter_height, filter_width, in_channels, out_channels],
  1072. * [out_channels, filter_depth, filter_height, filter_width, in_channels]
  1073. * or [out_channels, in_channels, filter_depth, filter_height, filter_width].
  1074. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1075. * window for each dimension of "x".
  1076. * The N and C dimensions must be 1. Has the same format as "x".
  1077. * @li pads: A tuple/list of 6 integers, [front, back, top, bottom, left, right]
  1078. * pads on feature map. \n
  1079. *@par Attributes:
  1080. * Three attributes:
  1081. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1082. * dimension of input, now only support [1,1,1,1,1].
  1083. * @li groups: Number of blocked connections from input channels to output
  1084. * channels. Reserved.
  1085. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1086. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1087. *@par Outputs:
  1088. * y: A Tensor of type float32 and the format is NDHWC, NCDHW or DHWCN.
  1089. *@par Third-party framework compatibility
  1090. * Compatible with Tensorflow's conv3d_backprop_filter
  1091. *@par Restrictions:
  1092. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropFilter instead.
  1093. */
  1094. REG_OP(Conv3DBackpropFilterD)
  1095. .INPUT(x, TensorType({DT_FLOAT16}))
  1096. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  1097. .OUTPUT(y, TensorType({DT_FLOAT}))
  1098. .REQUIRED_ATTR(filter_size, ListInt)
  1099. .REQUIRED_ATTR(strides, ListInt)
  1100. .REQUIRED_ATTR(pads, ListInt)
  1101. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1102. .ATTR(groups, Int, 1)
  1103. .ATTR(data_format, String, "NDHWC")
  1104. .OP_END_FACTORY_REG(Conv3DBackpropFilterD)
  1105. /**
  1106. *@brief Computes the transpose of convolution 3d with respect to the input.
  1107. *@par Inputs:
  1108. * Three inputs:
  1109. * @li input_size: A Tensor of type int32. An integer vector representing the
  1110. * shape of input.
  1111. * @li x: A Tensor of type float16, currently does not support int8. The format
  1112. * is NDHWC or NCDHW.
  1113. * @li filter: A Tensor of type float16, currently does not support int8.
  1114. * The format is NDHWC, NCDHW or DHWCN.
  1115. *@par Optional input:
  1116. * Two optional inputs
  1117. * @li bias: An optional 1D tensor of the same type as "x". Reserved.
  1118. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  1119. *@par Required Attributes:
  1120. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1121. * window for each dimension of "x".
  1122. * The N and C dimensions must be 1. Has the same format as "x".
  1123. * @li pads: A tuple/list of 6 integers
  1124. *@par Attributes:
  1125. * Five attributes:
  1126. * @li groups: Number of blocked connections from input channels to output
  1127. * channels. Reserved.
  1128. * @li dilations: A tuple/list of 5 integers,
  1129. * The dilation factor for each dimension of input, now only support [1,1,1,1,1]
  1130. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1131. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1132. * @li output_padding: The size will be added in the output shape.
  1133. * @li offset_x: Input offset_x value. Reserved.
  1134. *@par Outputs:
  1135. * y: A Tensor. Has the same type and format as x.
  1136. */
  1137. REG_OP(Conv3DTranspose)
  1138. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1139. .INPUT(x, TensorType({DT_FLOAT16}))
  1140. .INPUT(filter, TensorType({DT_FLOAT16}))
  1141. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  1142. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1143. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1144. .REQUIRED_ATTR(strides, ListInt)
  1145. .REQUIRED_ATTR(pads, ListInt)
  1146. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1147. .ATTR(groups, Int, 1)
  1148. .ATTR(data_format, String, "NDHWC")
  1149. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1150. .ATTR(offset_x, Int, 0)
  1151. .OP_END_FACTORY_REG(Conv3DTranspose)
  1152. /**
  1153. *@brief Computes the transpose of convolution 3d with respect to the input.
  1154. *@par Inputs:
  1155. * @li x: A Tensor of type float16, currently does not support int8.
  1156. * The format is NDHWC or NCDHW.
  1157. * @li filter: A Tensor of type float16, currently does not support int8.
  1158. * The format is NDHWC, NCDHW or DHWCN.
  1159. *@par Optional inputs:
  1160. * @li bias: An optional 1D tensor of the same type as "x". Reserved.
  1161. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  1162. *@par Required Attributes:
  1163. * @li input_size: A tuple/list of type int32.
  1164. * An integer vector representing the shape of input
  1165. * @li strides: A tuple/list of 5 integers.
  1166. * Specifies the stride of the sliding window for each dimension of "x".
  1167. * The N and C dimensions must be 1. Has the same format as "x".
  1168. * @li pads: A tuple/list of 6 integers . \n
  1169. *@par Attributes:
  1170. * Five attributes:
  1171. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1172. * dimension of input, now only support [1,1,1,1,1]
  1173. * @li groups: Number of blocked connections from input channels to output
  1174. * channels. Reserved.
  1175. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1176. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1177. * @li output_padding: The size will be added in the output shape.
  1178. * @li offset_x: Input offset_x value. Reserved.
  1179. *@par Outputs:
  1180. * y: A Tensor. Has the same type and format as x.
  1181. *@par Restrictions:
  1182. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DTranspose instead.
  1183. */
  1184. REG_OP(Conv3DTransposeD)
  1185. .INPUT(x, TensorType({DT_FLOAT16}))
  1186. .INPUT(filter, TensorType({DT_FLOAT16}))
  1187. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  1188. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1189. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1190. .REQUIRED_ATTR(input_size, ListInt)
  1191. .REQUIRED_ATTR(strides, ListInt)
  1192. .REQUIRED_ATTR(pads, ListInt)
  1193. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1194. .ATTR(groups, Int, 1)
  1195. .ATTR(data_format, String, "NDHWC")
  1196. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1197. .ATTR(offset_x, Int, 0)
  1198. .OP_END_FACTORY_REG(Conv3DTransposeD)
  1199. /**
  1200. *@brief Computes the transpose of convolution 2d with respect to the input.
  1201. *@par Inputs:
  1202. * Five inputs:
  1203. * @li input_size: A Tensor of type int32 or int64. An integer vector
  1204. * representing the shape of input, where input is a 4-D tensor
  1205. * [batch, height, width, channels] or [batch, channels, height, width].
  1206. * @li x: A Tensor of type float16, int8. 4-D with shape [batch, out_height,
  1207. * out_width, out_channels] or [batch, out_channels, out_height, out_width].
  1208. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1209. * 4-D with shape [filter_height, filter_width, in_channels, out_channels]
  1210. * or [out_channels, filter_height, filter_width, in_channels]
  1211. * or [out_channels, in_channel, filter_height, filter_width].
  1212. * @li bias: An optional 1D tensor of type float16 or int32. Format is "ND".
  1213. * @li offset_w: An optional 1D tensor for quantized inference. Reserved.
  1214. *@par Required Attributes:
  1215. * @li strides: A required tuple/list of 4 integers. The stride of the sliding
  1216. * window for H/W dimension. The index of H/W is same as data_format.
  1217. * @li pads: A required tuple/list of 4 integers, [top, bottom, left, right]
  1218. * pads on feature map.
  1219. *@par Attributes:
  1220. * Five attributes:
  1221. * @li groups: Number of blocked connections from input channels to output
  1222. * channels.
  1223. * Defaults to "1".
  1224. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  1225. * dimension of input. Must be [1, 1, 1, 1].
  1226. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC".
  1227. * Specify the data format of the input and output data.
  1228. * @li output_padding: The size will be added in the output shape. Defaults
  1229. * to [0, 0, 0, 0].
  1230. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1231. * Defaults to "0".
  1232. *@par Outputs:
  1233. * y: A Tensor. A Tensor of type float16 or int32, and has same format as
  1234. * input_size.
  1235. */
  1236. REG_OP(Conv2DTranspose)
  1237. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1238. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1239. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1240. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  1241. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1242. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  1243. .REQUIRED_ATTR(strides, ListInt)
  1244. .REQUIRED_ATTR(pads, ListInt)
  1245. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1246. .ATTR(groups, Int, 1)
  1247. .ATTR(data_format, String, "NHWC")
  1248. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1249. .ATTR(offset_x, Int, 0)
  1250. .OP_END_FACTORY_REG(Conv2DTranspose)
  1251. /**
  1252. *@brief Computes the transpose of convolution 2d with respect to the input.
  1253. *@par Inputs:
  1254. * Four inputs:
  1255. * @li x: A Tensor of type float16, int8.
  1256. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1257. * @li bias: An optional 1D tensor of the same type as "x".
  1258. * @li offset_w: An optional 1D tensor for quantized inference. Type is int8. Reserved.
  1259. *@par Required Attributes:
  1260. * @li input_size: A Tensor of type int32 or int64. An integer vector representing the
  1261. * shape of input.
  1262. * @li strides: A required list or tuple. The stride of the sliding window for
  1263. * height and width for H/W dimension.
  1264. * @li pads: A required list or tuple of int32. Padding added to each dimension
  1265. * of the input.
  1266. *@par Attributes:
  1267. * Five attributes:
  1268. * @li groups: Number of blocked connections from input channels to output channels.
  1269. * Defaults to "1".
  1270. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1271. * of input. Must be [1, 1, 1, 1].
  1272. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC".
  1273. * Specify the data format of the input and output data.
  1274. * @li output_padding: The size will be added in the output shape. Defaults
  1275. * to [0, 0, 0, 0].
  1276. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1277. * Defaults to "0".
  1278. *@par Outputs:
  1279. * y: A Tensor. Has the same type as "filter".
  1280. *@par Restrictions:
  1281. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DTranspose instead.
  1282. */
  1283. REG_OP(Conv2DTransposeD)
  1284. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1285. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1286. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  1287. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1288. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  1289. .REQUIRED_ATTR(input_size, ListInt)
  1290. .REQUIRED_ATTR(strides, ListInt)
  1291. .REQUIRED_ATTR(pads, ListInt)
  1292. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1293. .ATTR(groups, Int, 1)
  1294. .ATTR(data_format, String, "NHWC")
  1295. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1296. .ATTR(offset_x, Int, 0)
  1297. .OP_END_FACTORY_REG(Conv2DTransposeD)
  1298. /**
  1299. *@brief In the deformable convolution operator, the original input FeatureMap is expanded to a ksize_y * H * ksize_x *W
  1300. *FeatureMap by bilinear interpolation according to the offset offset.
  1301. *@par Inputs:
  1302. * Four inputs:
  1303. * @li x: A Tensor of type float16
  1304. * @li offsets: A Tensor of type float16,float32.Deformation offset parameter.
  1305. *@par Required Attributes:
  1306. * @li strides: A tuple/list of 2 integers.The stride of the sliding window for
  1307. * height and width for H/W dimension.
  1308. * @li pads: A tuple/list of 4 integers.Padding added to each dimension
  1309. * of the input.
  1310. * @li ksize: A tuple/list of 2 integers.kernel size.
  1311. *@par Attributes:
  1312. * Three attributes:
  1313. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1314. * of input. Defaults to [0, 0, 0, 0]
  1315. * @li data_format: An optional string from: "NCHW", "NHWC". Defaults to "NCHW". Specify the data format of the input x.
  1316. * @li deformable_groups: Specify the c-axis grouping number of input x.
  1317. *@par Outputs:
  1318. * y: A Tensor. A Tensor of type float16.
  1319. */
  1320. REG_OP(DeformableOffsets)
  1321. .INPUT(x, TensorType({DT_FLOAT16}))
  1322. .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1323. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1324. .REQUIRED_ATTR(strides, ListInt)
  1325. .REQUIRED_ATTR(pads, ListInt)
  1326. .REQUIRED_ATTR(ksize, ListInt)
  1327. .ATTR(dilations, ListInt, {0, 0, 0, 0})
  1328. .ATTR(data_format, String, "NCHW")
  1329. .ATTR(deformable_groups, Int, 1)
  1330. .OP_END_FACTORY_REG(DeformableOffsets)
  1331. } // namespace ge
  1332. #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两部分组成,详细的架构图如下所示