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
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*!
  17. * \file 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 image. With the format "NHWC", the data is stored
  543. * in the order of: [batch, in_height, in_width, in_channels].
  544. *@li filter: A 4D tensor of learnable filters. Must have the same type as "x".
  545. * With the format "HWCN" , the data is stored in the order of: [filter_height,
  546. * filter_width, in_channels / groups, out_channels].
  547. *@li bias: An optional 1D tensor of additive biases to the filter outputs.
  548. * The data is stored in the order of: [out_channels].
  549. *@li offset_w: Reserved.
  550. *\n
  551. *\n
  552. * The following are the supported data types and data formats:
  553. *@verbatim
  554. | Tensor | x | filter | bias | y
  555. ------------|---------|---------|---------|--------
  556. | Data Type | float16 | float16 | float16 | float16
  557. | |---------|---------|---------|--------
  558. | | float32 | float32 | float32 | float32
  559. | |---------|---------|---------|--------
  560. | | int8 | int8 | int32 | int32
  561. ------------|---------|---------|---------|--------
  562. | Format | NCHW | NCHW | ND | NCHW
  563. | | NHWC | HWCN | | NHWC
  564. @endverbatim
  565. * For float32 type, the actual calculation on the chip is based on
  566. * float16. For int8, a dequant or requant operator must be followed.
  567. *\n
  568. *
  569. *@par Attributes:
  570. *@li strides: Required. A list of 4 integers. The stride of the sliding window
  571. * for each dimension of input. The dimension order is determined by the data
  572. * format of "x". The N and C dimensions must be set to 1.
  573. *@li pads: Required. A list of 4 integers. The number of pixels to add to each
  574. * (top, bottom, left, right) side of the input.
  575. *@li dilations: Optional. A list of 4 integers. The dilation factor for each
  576. * dimension of input. The dimension order is determined by the data format of
  577. * "x". The N and C dimensions must be set to 1. The H and W dimensions must be
  578. * set to 1 for int8 type. Defaults to [1, 1, 1, 1].
  579. *@li groups: Optional. An integer of type int32. The number of blocked
  580. * connections from input channels to output channels. In_channels and
  581. * out_channels must both be divisible by "groups". Defaults to 1.
  582. *@li offset_x: Optional. An integer of type int32. The negative offset added
  583. * to the input image for int8 type. Ensure that the output is within the
  584. * effective range. Defaults to 0.
  585. *@li data_format: Reserved.
  586. *\n
  587. *\n
  588. * The following value range restrictions must be met:
  589. *@verbatim
  590. | Name | Field | Scope
  591. -------------------|----------|--------------
  592. | Input Image Size | H | [1, 100000]
  593. | | W | [1, 4096]
  594. -------------------|----------|--------------
  595. | Filter Size | H | [1, 255]
  596. | | W | [1, 255]
  597. -------------------|----------|--------------
  598. | Stride | H | [1, 63]
  599. | | W | [1, 63]
  600. -------------------|----------|--------------
  601. | Padding | Top | [0, 255]
  602. | | Bottom | [0, 255]
  603. | | Left | [0, 255]
  604. | | Right | [0, 255]
  605. -------------------|----------|--------------
  606. | Dilation | H | [1, 255]
  607. | | W | [1, 255]
  608. -------------------|----------|--------------
  609. | Offset_x | | [-128, 127]
  610. @endverbatim
  611. *\n
  612. *
  613. *@par Outputs:
  614. *@li y: A 4D Tensor of output feature map. Has the same type as "x". With the
  615. * format "NHWC", the data is stored in the order of: [batch, out_height,
  616. * out_width, out_channels].
  617. *\n
  618. * out_height = (in_height + pad_top + pad_bottom -
  619. * (dilation_h * (filter_height - 1) + 1))
  620. * / stride_h + 1
  621. *\n
  622. * out_width = (in_width + pad_left + pad_right -
  623. * (dilation_w * (filter_width - 1) + 1))
  624. * / stride_w + 1
  625. *
  626. *@attention Constraints:
  627. *@li The following restrictions on the output must be met:
  628. *@verbatim
  629. | Output | Restrictions
  630. ----------|--------------------------------
  631. | H == 1 | H * W(input) == H * W(filter)
  632. | W == 1 |
  633. ----------|--------------------------------
  634. | H != 1 | W(input) == W(filter)
  635. | W == 1 | Only for Ascend310 Hi3796V300CS
  636. @endverbatim
  637. * "H * W (input)" indicates the image size after padding and "H * W (filter)"
  638. * indicates the filter size after dilation."W(input)" and W(filter) indicate
  639. * the same rule on the W dimension.
  640. *\n
  641. *
  642. *@par Quantization supported or not
  643. *@li Yes
  644. *
  645. *@par Third-party framework compatibility
  646. *@li Compatible with the TensorFlow operator "conv2d".
  647. *@li Compatible with the Caffe operator 2D "Convolution".
  648. */
  649. REG_OP(Conv2D)
  650. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  651. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  652. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  653. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  654. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  655. .REQUIRED_ATTR(strides, ListInt)
  656. .REQUIRED_ATTR(pads, ListInt)
  657. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  658. .ATTR(groups, Int, 1)
  659. .ATTR(data_format, String, "NHWC")
  660. .ATTR(offset_x, Int, 0)
  661. .OP_END_FACTORY_REG(Conv2D)
  662. /**
  663. *@brief Computes a 2D convolution given 4D "x" and "filter_compress" tensors.
  664. *@par Inputs:
  665. * @li x: A 4D tensor of input images.
  666. * @li filter_compress: A 4D tensor of compressed filters.
  667. * @li compress_index: A 1D Tensor dtype of int8.
  668. * @li bias: An optional 1D tensor.
  669. * @li offset_w: An optional 1D tensor for quantized convolution. Reserved.
  670. *
  671. * The input and output tensor attributes are listed as follows:
  672. * @verbatim
  673. |Tensor | x | filter_compress | bias | offset_w | y
  674. -----------|---------|---------|---------|----------|--------
  675. |Data Type | float16 | float16 | float16 | _ | float16
  676. | |---------|---------|---------|----------|--------
  677. | | float32 | float32 | float32 | _ | float32
  678. | |---------|---------|---------|----------|--------
  679. | | int8 | int8 | int32 | int8 | int32
  680. -----------|---------|---------|---------|----------|--------
  681. |Format | NCHW | NCHW | ND | ND | NCHW
  682. | | NHWC | NHWC | | | NHWC
  683. | | | HWCN | | |
  684. @endverbatim
  685. * It should be noted that the data types must correspond to each other, but the
  686. * format does not need to . \n
  687. *@par Attributes:
  688. * @li strides: A list of 4 integers. Specifying the strides of the
  689. * convolution along the height and width. The dimension order is determined
  690. * by the data format of "x". By default the N and C dimensions are set to 1.
  691. * @li pads: A list of 4 integers. Specifying the top, bottom, left and right
  692. * padding.
  693. * @li dilations: A list of 4 integers. Specifying the dilation rate to use
  694. * for dilated convolution. Has the same dimension order and value as "strides".
  695. * @li groups: Number of blocked connections from input channels to output
  696. * channels. Input channels and output channels must both be divisible by
  697. * "groups".Type is int32.
  698. * @li offset_x: An optional integer for quantized convolution. Type is int32.
  699. * Defaults to "0".
  700. * @li data_format: An optional string from: "NHWC", "NCHW". Specifying the
  701. * data format of the input and output images. Type is string.
  702. * Defaults to "NHWC". Reserved . \n
  703. *@par Outputs:
  704. * @li y: A 4D Tensor of output images . \n
  705. *@par Restrictions:
  706. *Warning: THIS FUNCTION IS DEPRECATED.
  707. */
  708. REG_OP(Conv2DCompress)
  709. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  710. .INPUT(filter_compress, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8}))
  711. .INPUT(compress_index, TensorType({DT_INT8}))
  712. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  713. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  714. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  715. .REQUIRED_ATTR(strides, ListInt)
  716. .REQUIRED_ATTR(pads, ListInt)
  717. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  718. .ATTR(groups, Int, 1)
  719. .ATTR(data_format, String, "NHWC")
  720. .ATTR(offset_x, Int, 0)
  721. .OP_END_FACTORY_REG(Conv2DCompress)
  722. /**
  723. *@brief Computes a 2D deformable convolution given 4D "x", "filter" and
  724. * "offsets" tensors.
  725. *@par Inputs:
  726. *@li x: A 4D tensor of input image. With the format "NHWC", the data is stored
  727. * in the order of: [batch, in_height, in_width, in_channels].
  728. *@li filter: A 4D tensor of learnable filters. Must have the same type as "x".
  729. * With the format "HWCN" , the data is stored in the order of: [filter_height,
  730. * filter_width, in_channels / groups, out_channels].
  731. *@li offsets: A 4D tensor of x-y coordinates offset and mask. With the format
  732. * "NHWC", the data is stored in the order of: [batch, out_height, out_width,
  733. * deformable_groups * filter_height * filter_width * 3].
  734. *@li bias: An optional 1D tensor of additive biases to the filter outputs.
  735. * The data is stored in the order of: [out_channels].
  736. *\n
  737. *\n
  738. * The following are the supported data types and data formats:
  739. *@verbatim
  740. | Tensor | x | filter | offsets | bias | y
  741. ------------|---------|---------|---------|----------|--------
  742. | Data Type | float16 | float16 | float16 | float16 | float16
  743. ------------|---------|---------|---------|----------|--------
  744. | Format | NCHW | NCHW | NCHW | ND | NCHW
  745. | | NHWC | HWCN | NHWC | | NHWC
  746. @endverbatim
  747. *\n
  748. *
  749. *@par Attributes:
  750. *@li strides: Required. A list of 4 integers. The stride of the sliding window
  751. * for each dimension of input. The dimension order is interpreted according to
  752. * the value of data_format. The N and C dimensions must be set to 1.
  753. *@li pads: Required. A list of 4 integers. The number of pixels to add to each
  754. * (top, bottom, left, right) side of the input.
  755. *@li dilations: Optional. A list of 4 integers. The dilation factor for each
  756. * dimension of input. The dimension order is interpreted according to the value
  757. * of data_format The N and C dimensions must be set to 1. Defaults to
  758. * [1, 1, 1, 1].
  759. *@li groups: Optional. An integer of type int32. The number of blocked
  760. * connections from input channels to output channels. In_channels and
  761. * out_channels must both be divisible by "groups". Defaults to 1.
  762. *@li data_format: Optional. An optional string from: "NHWC", "NCHW". Specify
  763. * the data format of the input and output data. Defaults to "NHWC".
  764. *@li deformable_groups: Optional. An integer of type int32. The number of
  765. * deformable group partitions. In_channels must be divisible by
  766. * "deformable_groups". Defaults to 1.
  767. *\n
  768. *\n
  769. * The following value range restrictions must be met:
  770. *@verbatim
  771. | Name | Field | Scope
  772. --------------------|--------|----------------------------
  773. | Input Image Size | H | [1, 100000 / H(filter)]
  774. | | W | [1, 4096 / W(filter)]
  775. --------------------|--------|----------------------------
  776. | Filter Size | H | [1, 255]
  777. | | W | [1, 255]
  778. --------------------|--------|----------------------------
  779. | Stride | H | [1, 63]
  780. | | W | [1, 63]
  781. --------------------|--------|----------------------------
  782. | Padding | Top | [0, 255]
  783. | | Bottom | [0, 255]
  784. | | Left | [0, 255]
  785. | | Right | [0, 255]
  786. ------------ -------|--------|----------------------------
  787. | Dilation | H | [1, 255]
  788. | | W | [1, 255]
  789. @endverbatim
  790. * "W(input)" indicate the image width after padding and W(filter) indicates the
  791. * filter width after dilation.
  792. *\n
  793. *
  794. *@par Outputs:
  795. *@li y: A 4D Tensor of output feature map. Has the same type as "x". With the
  796. * format "NHWC", the data is stored in the order of: [batch, out_height,
  797. * out_width, out_channels].
  798. *\n
  799. * out_height = (in_height + pad_top + pad_bottom -
  800. * (dilation_h * (filter_height - 1) + 1))
  801. * / stride_h + 1
  802. *\n
  803. * out_width = (in_width + pad_left + pad_right -
  804. * (dilation_w * (filter_width - 1) + 1))
  805. * / stride_w + 1
  806. *
  807. *@attention Constraints:
  808. *@li The following restrictions on the output must be met:
  809. *@verbatim
  810. | Output | Restrictions
  811. ----------|--------------------------------
  812. | H == 1 | H * W(input) == H * W(filter)
  813. | W == 1 |
  814. ----------|--------------------------------
  815. | H != 1 | W(input) == W(filter)
  816. | W == 1 | Only for Ascend310 Hi3796V300CS
  817. @endverbatim
  818. * "H * W(input)" indicates the image size after padding and "H * W(filter)"
  819. * indicates the filter size after dilation. "W(input)" and W(filter) indicate
  820. * the same rule on the W dimension.
  821. *
  822. *@par Quantization supported or not
  823. *@li No
  824. *
  825. *@par Third-party framework compatibility
  826. *@li Compatible with the Mxnet operator "DeformableConvolution".
  827. *@li Compatible with the Paddlepaddle operator "deformable_conv".
  828. *@li Compatible with the Mmcv operator "deform_conv".
  829. */
  830. REG_OP(DeformableConv2D)
  831. .INPUT(x, TensorType({DT_FLOAT16}))
  832. .INPUT(filter, TensorType({DT_FLOAT16}))
  833. .INPUT(offsets, TensorType({DT_FLOAT16}))
  834. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  835. .OUTPUT(y, TensorType({DT_FLOAT16}))
  836. .REQUIRED_ATTR(strides, ListInt)
  837. .REQUIRED_ATTR(pads, ListInt)
  838. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  839. .ATTR(groups, Int, 1)
  840. .ATTR(data_format, String, "NHWC")
  841. .ATTR(deformable_groups, Int, 1)
  842. .OP_END_FACTORY_REG(DeformableConv2D)
  843. /**
  844. *@brief Computes a 3D convolution given 5D "x" and "filter" tensors.
  845. *@par Inputs:
  846. * @li x: A 5D tensor. Must be one of the following types: float16,
  847. * (Currently does not support int8). The format of x is NCDHW or NDHWC.
  848. * @li filter: A 5D tensor of the same type as "x".
  849. * (Currently does not support int8).
  850. * The format is NCDHW, NDHWC or DHWCN . \n
  851. *@par Optional input:
  852. * @li bias: An optional 1D tensor of the same type as "x".
  853. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  854. *@par Required Attributes:
  855. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  856. * for each dimension of "x".
  857. * The N and C dimensions must be 1. Has the same format as "x".
  858. * @li pads: A list of 6 integers.
  859. * Supports only padding along the D, H and W dimensions in sequence of head,
  860. * tail, top, bottom, left and right . \n
  861. *@par Attributes:
  862. * @li groups: Number of blocked connections from input channels to output
  863. * channels. Reserved.
  864. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  865. * Defaults to "NDHWC". Specify the data format of the input and output data.
  866. * @li dilations: A list of 5 integers. Specifies the dilation factor for each
  867. * dimension of "x", now only support [1,1,1,1,1]
  868. * The N and C dimensions must be 1. Has the same format as "x".
  869. * @li offset_x: An optional int. Input offset, used for quantized inference.
  870. * Defaults to 0. Reserved . \n
  871. *@par Outputs:
  872. *y: A Tensor. Has the same type and data format as "x". \n
  873. *@attention Constraints:
  874. *The image size after padding is greater than the filter size . \n
  875. *@par Third-party framework compatibility
  876. * @li Compatible with the TensorFlow operator conv3d.
  877. * @li Compatible with the Caffe operator Convolution.
  878. */
  879. REG_OP(Conv3D)
  880. .INPUT(x, TensorType({DT_FLOAT16}))
  881. .INPUT(filter, TensorType({DT_FLOAT16}))
  882. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  883. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  884. .OUTPUT(y, TensorType({DT_FLOAT16}))
  885. .REQUIRED_ATTR(strides, ListInt)
  886. .REQUIRED_ATTR(pads, ListInt)
  887. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  888. .ATTR(groups, Int, 1)
  889. .ATTR(data_format, String, "NDHWC")
  890. .ATTR(offset_x, Int, 0)
  891. .OP_END_FACTORY_REG(Conv3D)
  892. /**
  893. *@brief Computes the gradients of convolution 3d with respect to the input.
  894. *@par Inputs:
  895. * Three inputs:
  896. * @li input_size: A Tensor of type int32, int64. An integer vector representing
  897. * the shape of input, where input is a 5-D tensor
  898. * [batch, depth, height, width, channels] or
  899. * [batch, channels, depth, height, width].
  900. * @li filter: A Tensor. Must be one of the following types: float16, float32.
  901. * Currently does not support double.
  902. * @li out_backprop: A Tensor. Must have the same type as filter.
  903. * 5-D with shape [batch, depth, out_height, out_width, out_channels]
  904. * or [batch, out_channels, depth, out_height, out_width]. Gradients with
  905. * respect to the output of the convolution . \n
  906. *@par Required Attributes:
  907. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  908. * for each dimension of "x".
  909. * The N and C dimensions must be 1. Has the same format as "x".
  910. * @li pads: A list of 6 integers.
  911. * Supports only padding along the D, H and W dimensions in sequence of head,
  912. * tail, top, bottom, left and right . \n
  913. *@par Attributes:
  914. * Three attributes:
  915. * @li groups: Number of blocked connections from input channels to output
  916. * channels. Reserved.
  917. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  918. * Defaults to "NDHWC". Specify the data format of the input and output data.
  919. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  920. * dimension of the input, now only support [1,1,1,1,1]
  921. *@par Outputs:
  922. * y: A Tensor. Has the same type as filter,and has same format as input_size
  923. *@par Third-party framework compatibility
  924. * Compatible with Tensorflow's conv3d_backprop_input
  925. */
  926. REG_OP(Conv3DBackpropInput)
  927. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  928. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  929. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  930. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  931. .REQUIRED_ATTR(strides, ListInt)
  932. .REQUIRED_ATTR(pads, ListInt)
  933. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  934. .ATTR(groups, Int, 1)
  935. .ATTR(data_format, String, "NDHWC")
  936. .OP_END_FACTORY_REG(Conv3DBackpropInput)
  937. /**
  938. *@brief Computes the gradients of convolution 3d with respect to the input.
  939. *@par Inputs:
  940. * Two inputs:
  941. * @li filter: A Tensor whose type is float16. The format of filter is NCDHW,
  942. * NDHWC or DHWCN.
  943. * @li out_backprop: A Tensor. Must have the same type as filter. The format is
  944. * NDHWC or NCDHW. \n
  945. *@par Required Attributes:
  946. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  947. * for each dimension of "x".
  948. * The N and C dimensions must be 1. Has the same format as "x".
  949. * @li pads: A list of 6 integers. Supports only padding along the D, H and W
  950. * dimensions in sequence of head, tail, top, bottom, left and right.
  951. * @li input_size: A tuple/list of type int32, int64. An integer vector
  952. * representing the shape of input, where input is a 5-D tensor
  953. * [batch, depth, height, width, channels] or
  954. * [batch, channels, depth, height, width] . \n
  955. *@par Attributes:
  956. * Three attributes:
  957. * @li groups: Number of blocked connections from input channels to output
  958. * channels. Reserved.
  959. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  960. * Defaults to "NDHWC". Specify the data format of the input and output data.
  961. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  962. * dimension of input, now only support [1,1,1,1,1]
  963. *@par Outputs:
  964. * y: A Tensor. Has the same type and data format as out_backprop.
  965. *@par Third-party framework compatibility
  966. * Compatible with Tensorflow's conv3d_backprop_input
  967. *@par Restrictions:
  968. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropInput instead.
  969. */
  970. REG_OP(Conv3DBackpropInputD)
  971. .INPUT(filter, TensorType({DT_FLOAT16}))
  972. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  973. .OUTPUT(y, TensorType({DT_FLOAT16}))
  974. .REQUIRED_ATTR(input_size, ListInt)
  975. .REQUIRED_ATTR(strides, ListInt)
  976. .REQUIRED_ATTR(pads, ListInt)
  977. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  978. .ATTR(groups, Int, 1)
  979. .ATTR(data_format, String, "NDHWC")
  980. .OP_END_FACTORY_REG(Conv3DBackpropInputD)
  981. /**
  982. *@brief Applies a multi-layer long short-term memory (LSTM) RNN to an input sequence . \n
  983. *@par Inputs:
  984. * @li x: A Tensor dtype of float16.
  985. * @li cont: A Tensor dtype of float16, float32.
  986. * @li w_x: A Tensor dtype of float16.
  987. * @li bias: A Tensor dtype of int16, int32, float16, float32.
  988. * @li w_h: A Tensor dtype of float16.
  989. * @li x_static: A optinal Tensor dtype of float16.
  990. * @li h_0: A optinal Tensor dtype of float16, float32.
  991. * @li c_0: A optinal Tensor dtype of float16, float32.
  992. * @li w_x_static: A optinal Tensor dtype of float16 . \n
  993. *@par Attributes:
  994. *@li num_output: A Scalar of output size dtype of int.
  995. *@li expose_hidden: A Scalar(bool) of features hidden . \n
  996. *@par Outputs:
  997. *@li h: A Tensor dtype of float16, float32.
  998. * @li h_t: A optinal Tensor dtype of float16, float32. The hidden state at time t.
  999. * @li c_t: A optinal Tensor dtype of float16, float32. The cell state at time t . \n
  1000. *@par Third-party framework compatibility:
  1001. * Compatible with the Pytorch operator adds.
  1002. *@par Restrictions:
  1003. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1004. */
  1005. REG_OP(LSTM)
  1006. .INPUT(x, TensorType({DT_FLOAT16}))
  1007. .INPUT(cont, TensorType({DT_FLOAT32,DT_FLOAT16}))
  1008. .INPUT(w_x, TensorType({DT_FLOAT16}))
  1009. .INPUT(bias, TensorType({DT_FLOAT16,DT_FLOAT32,DT_INT16,DT_INT32}))
  1010. .INPUT(w_h, TensorType({DT_FLOAT16}))
  1011. .OPTIONAL_INPUT(x_static, TensorType({DT_FLOAT16}))
  1012. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1013. .OPTIONAL_INPUT(c_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1014. .OPTIONAL_INPUT(w_x_static, TensorType({DT_FLOAT16}))
  1015. .OUTPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1016. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1017. .OUTPUT(c_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1018. .ATTR(num_output, Int, 0)
  1019. .ATTR(expose_hidden, Bool, false)
  1020. .OP_END_FACTORY_REG(LSTM)
  1021. /**
  1022. *@brief Computes the gradients of convolution3D with respect to the filter
  1023. *@par Inputs:
  1024. * Three inputs:
  1025. * @li x: A Tensor. Must be one of the following types: float16, float32.
  1026. * Currently does not support double.
  1027. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1028. * or [batch, in_channels, in_depth, in_height, in_width].
  1029. * @li filter_size: A Tensor of type int32. An integer vector representing the
  1030. * tensor shape of filter, where filter is a 5-D tensor
  1031. * [filter_depth, filter_height, filter_width, in_channels, out_channels]
  1032. * [out_channels, in_channels, filter_depth, filter_height, filter_width]
  1033. * or [out_channels, filter_depth, filter_height, filter_width, in_channels].
  1034. * @li out_backprop: A Tensor. Must have the same type as x.
  1035. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1036. * or [batch, out_channels, out_depth, out_height, out_width].
  1037. * Gradients with respect to the output of the convolution. \n
  1038. *@par Required Attributes:
  1039. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1040. * window for each dimension of "x". The N and C dimensions must be 1.
  1041. * Has the same format as "x".
  1042. * @li pads: A tuple/list of 6 integers, [front, back, top, bottom, left, right]
  1043. * pads on feature map . \n
  1044. *@par Attributes:
  1045. * Three attributes:
  1046. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1047. * dimension of input, now only support [1,1,1,1,1].
  1048. * @li groups: Number of blocked connections from input channels to output
  1049. * channels. Reserved.
  1050. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1051. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1052. *@par Outputs:
  1053. * y: A Tensor that has the same type as x
  1054. * and the format is NDHWC, NCDHW or DHWCN.
  1055. *@par Third-party framework compatibility
  1056. * Compatible with Tensorflow's conv3d_backprop_filter
  1057. */
  1058. REG_OP(Conv3DBackpropFilter)
  1059. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1060. .INPUT(filter_size, TensorType({DT_INT32}))
  1061. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1062. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1063. .REQUIRED_ATTR(strides, ListInt)
  1064. .REQUIRED_ATTR(pads, ListInt)
  1065. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1066. .ATTR(groups, Int, 1)
  1067. .ATTR(data_format, String, "NDHWC")
  1068. .OP_END_FACTORY_REG(Conv3DBackpropFilter)
  1069. /**
  1070. *@brief Computes the gradients of convolution with respect to the filter.
  1071. *@par Inputs:
  1072. * Two inputs:
  1073. * @li x: A Tensor of type float16.
  1074. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1075. * or [batch, in_channels, in_depth, in_height, in_width].
  1076. * @li out_backprop: A Tensor. Must have the same type as x.
  1077. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1078. * or [batch, out_channels, out_depth, out_height, out_width].
  1079. * Gradients with respect to the output of the convolution. \n
  1080. *@par Required Attributes:
  1081. * @li filter_size: A tuple/list of type integers. An integer vector
  1082. * representing the tensor shape of filter, where filter is a 5-D tensor
  1083. * [filter_depth, filter_height, filter_width, in_channels, out_channels],
  1084. * [out_channels, filter_depth, filter_height, filter_width, in_channels]
  1085. * or [out_channels, in_channels, filter_depth, filter_height, filter_width].
  1086. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1087. * window for each dimension of "x".
  1088. * The N and C dimensions must be 1. Has the same format as "x".
  1089. * @li pads: A tuple/list of 6 integers, [front, back, top, bottom, left, right]
  1090. * pads on feature map. \n
  1091. *@par Attributes:
  1092. * Three attributes:
  1093. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1094. * dimension of input, now only support [1,1,1,1,1].
  1095. * @li groups: Number of blocked connections from input channels to output
  1096. * channels. Reserved.
  1097. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1098. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1099. *@par Outputs:
  1100. * y: A Tensor of type float32 and the format is NDHWC, NCDHW or DHWCN.
  1101. *@par Third-party framework compatibility
  1102. * Compatible with Tensorflow's conv3d_backprop_filter
  1103. *@par Restrictions:
  1104. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropFilter instead.
  1105. */
  1106. REG_OP(Conv3DBackpropFilterD)
  1107. .INPUT(x, TensorType({DT_FLOAT16}))
  1108. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  1109. .OUTPUT(y, TensorType({DT_FLOAT}))
  1110. .REQUIRED_ATTR(filter_size, ListInt)
  1111. .REQUIRED_ATTR(strides, ListInt)
  1112. .REQUIRED_ATTR(pads, ListInt)
  1113. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1114. .ATTR(groups, Int, 1)
  1115. .ATTR(data_format, String, "NDHWC")
  1116. .OP_END_FACTORY_REG(Conv3DBackpropFilterD)
  1117. /**
  1118. *@brief Computes the transpose of convolution 3d with respect to the input.
  1119. *@par Inputs:
  1120. * Three inputs:
  1121. * @li input_size: A Tensor of type int32. An integer vector representing the
  1122. * shape of input.
  1123. * @li x: A Tensor of type float16, currently does not support int8. The format
  1124. * is NDHWC or NCDHW.
  1125. * @li filter: A Tensor of type float16, currently does not support int8.
  1126. * The format is NDHWC, NCDHW or DHWCN.
  1127. *@par Optional input:
  1128. * Two optional inputs
  1129. * @li bias: An optional 1D tensor of the same type as "x". Reserved.
  1130. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  1131. *@par Required Attributes:
  1132. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1133. * window for each dimension of "x".
  1134. * The N and C dimensions must be 1. Has the same format as "x".
  1135. * @li pads: A tuple/list of 6 integers
  1136. *@par Attributes:
  1137. * Five attributes:
  1138. * @li groups: Number of blocked connections from input channels to output
  1139. * channels. Reserved.
  1140. * @li dilations: A tuple/list of 5 integers,
  1141. * The dilation factor for each dimension of input, now only support [1,1,1,1,1]
  1142. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1143. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1144. * @li output_padding: The size will be added in the output shape.
  1145. * @li offset_x: Input offset_x value. Reserved.
  1146. *@par Outputs:
  1147. * y: A Tensor. Has the same type and format as x.
  1148. */
  1149. REG_OP(Conv3DTranspose)
  1150. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1151. .INPUT(x, TensorType({DT_FLOAT16}))
  1152. .INPUT(filter, TensorType({DT_FLOAT16}))
  1153. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  1154. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1155. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1156. .REQUIRED_ATTR(strides, ListInt)
  1157. .REQUIRED_ATTR(pads, ListInt)
  1158. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1159. .ATTR(groups, Int, 1)
  1160. .ATTR(data_format, String, "NDHWC")
  1161. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1162. .ATTR(offset_x, Int, 0)
  1163. .OP_END_FACTORY_REG(Conv3DTranspose)
  1164. /**
  1165. *@brief Computes the transpose of convolution 3d with respect to the input.
  1166. *@par Inputs:
  1167. * @li x: A Tensor of type float16, currently does not support int8.
  1168. * The format is NDHWC or NCDHW.
  1169. * @li filter: A Tensor of type float16, currently does not support int8.
  1170. * The format is NDHWC, NCDHW or DHWCN.
  1171. *@par Optional inputs:
  1172. * @li bias: An optional 1D tensor of the same type as "x". Reserved.
  1173. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  1174. *@par Required Attributes:
  1175. * @li input_size: A tuple/list of type int32.
  1176. * An integer vector representing the shape of input
  1177. * @li strides: A tuple/list of 5 integers.
  1178. * Specifies the stride of the sliding window for each dimension of "x".
  1179. * The N and C dimensions must be 1. Has the same format as "x".
  1180. * @li pads: A tuple/list of 6 integers . \n
  1181. *@par Attributes:
  1182. * Five attributes:
  1183. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1184. * dimension of input, now only support [1,1,1,1,1]
  1185. * @li groups: Number of blocked connections from input channels to output
  1186. * channels. Reserved.
  1187. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1188. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1189. * @li output_padding: The size will be added in the output shape.
  1190. * @li offset_x: Input offset_x value. Reserved.
  1191. *@par Outputs:
  1192. * y: A Tensor. Has the same type and format as x.
  1193. *@par Restrictions:
  1194. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DTranspose instead.
  1195. */
  1196. REG_OP(Conv3DTransposeD)
  1197. .INPUT(x, TensorType({DT_FLOAT16}))
  1198. .INPUT(filter, TensorType({DT_FLOAT16}))
  1199. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  1200. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1201. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1202. .REQUIRED_ATTR(input_size, ListInt)
  1203. .REQUIRED_ATTR(strides, ListInt)
  1204. .REQUIRED_ATTR(pads, ListInt)
  1205. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1206. .ATTR(groups, Int, 1)
  1207. .ATTR(data_format, String, "NDHWC")
  1208. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1209. .ATTR(offset_x, Int, 0)
  1210. .OP_END_FACTORY_REG(Conv3DTransposeD)
  1211. /**
  1212. *@brief Computes the transpose of convolution 2d with respect to the input.
  1213. *@par Inputs:
  1214. * Five inputs:
  1215. * @li input_size: A Tensor of type int32 or int64. An integer vector
  1216. * representing the shape of input, where input is a 4-D tensor
  1217. * [batch, height, width, channels] or [batch, channels, height, width].
  1218. * @li x: A Tensor of type float16, int8. 4-D with shape [batch, out_height,
  1219. * out_width, out_channels] or [batch, out_channels, out_height, out_width].
  1220. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1221. * 4-D with shape [filter_height, filter_width, in_channels, out_channels]
  1222. * or [out_channels, filter_height, filter_width, in_channels]
  1223. * or [out_channels, in_channel, filter_height, filter_width].
  1224. * @li bias: An optional 1D tensor of type float16 or int32. Format is "ND".
  1225. * @li offset_w: An optional 1D tensor for quantized inference. Reserved.
  1226. *@par Required Attributes:
  1227. * @li strides: A required tuple/list of 4 integers. The stride of the sliding
  1228. * window for H/W dimension. The index of H/W is same as data_format.
  1229. * @li pads: A required tuple/list of 4 integers, [top, bottom, left, right]
  1230. * pads on feature map.
  1231. *@par Attributes:
  1232. * Five attributes:
  1233. * @li groups: Number of blocked connections from input channels to output
  1234. * channels.
  1235. * Defaults to "1".
  1236. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  1237. * dimension of input. Must be [1, 1, 1, 1].
  1238. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC".
  1239. * Specify the data format of the input and output data.
  1240. * @li output_padding: The size will be added in the output shape. Defaults
  1241. * to [0, 0, 0, 0].
  1242. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1243. * Defaults to "0".
  1244. *@par Outputs:
  1245. * y: A Tensor. A Tensor of type float16 or int32, and has same format as
  1246. * input_size.
  1247. */
  1248. REG_OP(Conv2DTranspose)
  1249. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1250. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1251. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1252. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  1253. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1254. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  1255. .REQUIRED_ATTR(strides, ListInt)
  1256. .REQUIRED_ATTR(pads, ListInt)
  1257. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1258. .ATTR(groups, Int, 1)
  1259. .ATTR(data_format, String, "NHWC")
  1260. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1261. .ATTR(offset_x, Int, 0)
  1262. .OP_END_FACTORY_REG(Conv2DTranspose)
  1263. /**
  1264. *@brief Computes the transpose of convolution 2d with respect to the input.
  1265. *@par Inputs:
  1266. * Four inputs:
  1267. * @li x: A Tensor of type float16, int8.
  1268. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1269. * @li bias: An optional 1D tensor of the same type as "x".
  1270. * @li offset_w: An optional 1D tensor for quantized inference. Type is int8. Reserved.
  1271. *@par Required Attributes:
  1272. * @li input_size: A Tensor of type int32 or int64. An integer vector representing the
  1273. * shape of input.
  1274. * @li strides: A required list or tuple. The stride of the sliding window for
  1275. * height and width for H/W dimension.
  1276. * @li pads: A required list or tuple of int32. Padding added to each dimension
  1277. * of the input.
  1278. *@par Attributes:
  1279. * Five attributes:
  1280. * @li groups: Number of blocked connections from input channels to output channels.
  1281. * Defaults to "1".
  1282. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1283. * of input. Must be [1, 1, 1, 1].
  1284. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC".
  1285. * Specify the data format of the input and output data.
  1286. * @li output_padding: The size will be added in the output shape. Defaults
  1287. * to [0, 0, 0, 0].
  1288. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1289. * Defaults to "0".
  1290. *@par Outputs:
  1291. * y: A Tensor. Has the same type as "filter".
  1292. *@par Restrictions:
  1293. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DTranspose instead.
  1294. */
  1295. REG_OP(Conv2DTransposeD)
  1296. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1297. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1298. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  1299. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1300. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  1301. .REQUIRED_ATTR(input_size, ListInt)
  1302. .REQUIRED_ATTR(strides, ListInt)
  1303. .REQUIRED_ATTR(pads, ListInt)
  1304. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1305. .ATTR(groups, Int, 1)
  1306. .ATTR(data_format, String, "NHWC")
  1307. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1308. .ATTR(offset_x, Int, 0)
  1309. .OP_END_FACTORY_REG(Conv2DTransposeD)
  1310. /**
  1311. *@brief In the deformable convolution operator, the original input FeatureMap is expanded to a ksize_y * H * ksize_x *W
  1312. *FeatureMap by bilinear interpolation according to the offset offset.
  1313. *@par Inputs:
  1314. * Four inputs:
  1315. * @li x: A Tensor of type float16
  1316. * @li offsets: A Tensor of type float16,float32.Deformation offset parameter.
  1317. *@par Required Attributes:
  1318. * @li strides: A tuple/list of 2 integers.The stride of the sliding window for
  1319. * height and width for H/W dimension.
  1320. * @li pads: A tuple/list of 4 integers.Padding added to each dimension
  1321. * of the input.
  1322. * @li ksize: A tuple/list of 2 integers.kernel size.
  1323. *@par Attributes:
  1324. * Three attributes:
  1325. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1326. * of input. Defaults to [0, 0, 0, 0]
  1327. * @li data_format: An optional string from: "NCHW", "NHWC". Defaults to "NCHW". Specify the data format of the input x.
  1328. * @li deformable_groups: Specify the c-axis grouping number of input x.
  1329. *@par Outputs:
  1330. * y: A Tensor. A Tensor of type float16.
  1331. */
  1332. REG_OP(DeformableOffsets)
  1333. .INPUT(x, TensorType({DT_FLOAT16}))
  1334. .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT32}))
  1335. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1336. .REQUIRED_ATTR(strides, ListInt)
  1337. .REQUIRED_ATTR(pads, ListInt)
  1338. .REQUIRED_ATTR(ksize, ListInt)
  1339. .ATTR(dilations, ListInt, {0, 0, 0, 0})
  1340. .ATTR(data_format, String, "NCHW")
  1341. .ATTR(deformable_groups, Int, 1)
  1342. .OP_END_FACTORY_REG(DeformableOffsets)
  1343. } // namespace ge
  1344. #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两部分组成,详细的架构图如下所示