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