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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  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, in_height, in_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. | | float32 | float32 | float32 | float32 | float32
  745. ------------|---------|---------|---------|----------|--------
  746. | Format | NCHW | NCHW | NCHW | ND | NCHW
  747. | | NHWC | HWCN | NHWC | | NHWC
  748. @endverbatim
  749. * For float32 type, the actual convolution calculation part on the chip is
  750. * based on float16.
  751. *\n
  752. *
  753. *@par Attributes:
  754. *@li strides: Required. A list of 4 integers. The stride of the sliding window
  755. * for each dimension of input. The dimension order is interpreted according to
  756. * the data format of "x". The N and C dimensions must be set to 1.
  757. *@li pads: Required. A list of 4 integers. The number of pixels to add to each
  758. * (top, bottom, left, right) side of the input.
  759. *@li dilations: Optional. A list of 4 integers. The dilation factor for each
  760. * dimension of input. The dimension order is interpreted according to the data
  761. * format of "x". The N and C dimensions must be set to 1. Defaults to
  762. * [1, 1, 1, 1].
  763. *@li groups: Optional. An integer of type int32. The number of blocked
  764. * connections from input channels to output channels. In_channels and
  765. * out_channels must both be divisible by "groups". Defaults to 1.
  766. *@li data_format: Reserved.
  767. *@li deformable_groups: Optional. An integer of type int32. The number of
  768. * deformable group partitions. In_channels must be divisible by
  769. * "deformable_groups". Defaults to 1.
  770. *\n
  771. *\n
  772. * The following value range restrictions must be met:
  773. *@verbatim
  774. | Name | Field | Scope
  775. --------------------|--------|----------------------------
  776. | Input Image Size | H | [1, 100000]
  777. | | W | [1, 4096]
  778. --------------------|--------|----------------------------
  779. | Filter Size | H | [1, 255]
  780. | | W | [1, 255]
  781. --------------------|--------|----------------------------
  782. | Stride | H | [1, 63]
  783. | | W | [1, 63]
  784. --------------------|--------|----------------------------
  785. | Padding | Top | [0, 255]
  786. | | Bottom | [0, 255]
  787. | | Left | [0, 255]
  788. | | Right | [0, 255]
  789. ------------ -------|--------|----------------------------
  790. | Dilation | H | [1, 255]
  791. | | W | [1, 255]
  792. @endverbatim
  793. * "W(input)" indicate the image width after padding and W(filter) indicates the
  794. * filter width after dilation.
  795. *\n
  796. *
  797. *@par Outputs:
  798. *@li y: A 4D Tensor of output feature map. Has the same type as "x". With the
  799. * format "NHWC", the data is stored in the order of: [batch, out_height,
  800. * out_width, out_channels].
  801. *\n
  802. * out_height = (in_height + pad_top + pad_bottom -
  803. * (dilation_h * (filter_height - 1) + 1))
  804. * / stride_h + 1
  805. *\n
  806. * out_width = (in_width + pad_left + pad_right -
  807. * (dilation_w * (filter_width - 1) + 1))
  808. * / stride_w + 1
  809. *
  810. *@attention Constraints:
  811. *@li The following restrictions on the output must be met:
  812. *@verbatim
  813. | Output | Restrictions
  814. ----------|--------------------------------
  815. | H == 1 | H * W(input) == H * W(filter)
  816. | W == 1 |
  817. ----------|--------------------------------
  818. | H != 1 | W(input) == W(filter)
  819. | W == 1 | Only for Ascend310 Hi3796V300CS
  820. @endverbatim
  821. * "H * W(input)" indicates the image size after padding and "H * W(filter)"
  822. * indicates the filter size after dilation. "W(input)" and W(filter) indicate
  823. * the same rule on the W dimension.
  824. *
  825. *@par Quantization supported or not
  826. *@li No
  827. *
  828. *@par Third-party framework compatibility
  829. *@li Compatible with the Mxnet operator "DeformableConvolution".
  830. *@li Compatible with the Paddlepaddle operator "deformable_conv".
  831. *@li Compatible with the Mmcv operator "deform_conv".
  832. */
  833. REG_OP(DeformableConv2D)
  834. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  835. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT}))
  836. .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT}))
  837. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT}))
  838. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  839. .REQUIRED_ATTR(strides, ListInt)
  840. .REQUIRED_ATTR(pads, ListInt)
  841. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  842. .ATTR(groups, Int, 1)
  843. .ATTR(data_format, String, "NHWC")
  844. .ATTR(deformable_groups, Int, 1)
  845. .OP_END_FACTORY_REG(DeformableConv2D)
  846. /**
  847. *@brief Computes a 3D convolution given 5D "x" and "filter" tensors.
  848. *@par Inputs:
  849. * @li x: A 5D tensor. Must be one of the following types: float16,
  850. * (Currently does not support int8). The format of x is NCDHW or NDHWC.
  851. * @li filter: A 5D tensor of the same type as "x".
  852. * (Currently does not support int8).
  853. * The format is NCDHW, NDHWC or DHWCN . \n
  854. *@par Optional input:
  855. * @li bias: An optional 1D tensor of the same type as "x".
  856. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  857. *@par Required Attributes:
  858. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  859. * for each dimension of "x".
  860. * The N and C dimensions must be 1. Has the same format as "x".
  861. * @li pads: A list of 6 integers.
  862. * Supports only padding along the D, H and W dimensions in sequence of head,
  863. * tail, top, bottom, left and right . \n
  864. *@par Attributes:
  865. * @li groups: Number of blocked connections from input channels to output
  866. * channels. Reserved.
  867. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  868. * Defaults to "NDHWC". Specify the data format of the input and output data.
  869. * @li dilations: A list of 5 integers. Specifies the dilation factor for each
  870. * dimension of "x", now only support [1,1,1,1,1]
  871. * The N and C dimensions must be 1. Has the same format as "x".
  872. * @li offset_x: An optional int. Input offset, used for quantized inference.
  873. * Defaults to 0. Reserved . \n
  874. *@par Outputs:
  875. *y: A Tensor. Has the same type and data format as "x". \n
  876. *@attention Constraints:
  877. *The image size after padding is greater than the filter size . \n
  878. *@par Third-party framework compatibility
  879. * @li Compatible with the TensorFlow operator conv3d.
  880. * @li Compatible with the Caffe operator Convolution.
  881. */
  882. REG_OP(Conv3D)
  883. .INPUT(x, TensorType({DT_FLOAT16}))
  884. .INPUT(filter, TensorType({DT_FLOAT16}))
  885. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  886. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  887. .OUTPUT(y, TensorType({DT_FLOAT16}))
  888. .REQUIRED_ATTR(strides, ListInt)
  889. .REQUIRED_ATTR(pads, ListInt)
  890. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  891. .ATTR(groups, Int, 1)
  892. .ATTR(data_format, String, "NDHWC")
  893. .ATTR(offset_x, Int, 0)
  894. .OP_END_FACTORY_REG(Conv3D)
  895. /**
  896. *@brief Computes the gradients of convolution 3d with respect to the input.
  897. *@par Inputs:
  898. * Three inputs:
  899. * @li input_size: A Tensor of type int32, int64. An integer vector representing
  900. * the shape of input, where input is a 5-D tensor
  901. * [batch, depth, height, width, channels] or
  902. * [batch, channels, depth, height, width].
  903. * @li filter: A Tensor. Must be one of the following types: float16, float32.
  904. * Currently does not support double.
  905. * @li out_backprop: A Tensor. Must have the same type as filter.
  906. * 5-D with shape [batch, depth, out_height, out_width, out_channels]
  907. * or [batch, out_channels, depth, out_height, out_width]. Gradients with
  908. * respect to the output of the convolution . \n
  909. *@par Required Attributes:
  910. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  911. * for each dimension of "x".
  912. * The N and C dimensions must be 1. Has the same format as "x".
  913. * @li pads: A list of 6 integers.
  914. * Supports only padding along the D, H and W dimensions in sequence of head,
  915. * tail, top, bottom, left and right . \n
  916. *@par Attributes:
  917. * Three attributes:
  918. * @li groups: Number of blocked connections from input channels to output
  919. * channels. Reserved.
  920. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  921. * Defaults to "NDHWC". Specify the data format of the input and output data.
  922. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  923. * dimension of the input, now only support [1,1,1,1,1]
  924. *@par Outputs:
  925. * y: A Tensor. Has the same type as filter,and has same format as input_size
  926. *@par Third-party framework compatibility
  927. * Compatible with Tensorflow's conv3d_backprop_input
  928. */
  929. REG_OP(Conv3DBackpropInput)
  930. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  931. .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  932. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  933. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  934. .REQUIRED_ATTR(strides, ListInt)
  935. .REQUIRED_ATTR(pads, ListInt)
  936. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  937. .ATTR(groups, Int, 1)
  938. .ATTR(data_format, String, "NDHWC")
  939. .OP_END_FACTORY_REG(Conv3DBackpropInput)
  940. /**
  941. *@brief Computes the gradients of convolution 3d with respect to the input.
  942. *@par Inputs:
  943. * Two inputs:
  944. * @li filter: A Tensor whose type is float16. The format of filter is NCDHW,
  945. * NDHWC or DHWCN.
  946. * @li out_backprop: A Tensor. Must have the same type as filter. The format is
  947. * NDHWC or NCDHW. \n
  948. *@par Required Attributes:
  949. * @li strides: A list of 5 integers. Specifies the stride of the sliding window
  950. * for each dimension of "x".
  951. * The N and C dimensions must be 1. Has the same format as "x".
  952. * @li pads: A list of 6 integers. Supports only padding along the D, H and W
  953. * dimensions in sequence of head, tail, top, bottom, left and right.
  954. * @li input_size: A tuple/list of type int32, int64. An integer vector
  955. * representing the shape of input, where input is a 5-D tensor
  956. * [batch, depth, height, width, channels] or
  957. * [batch, channels, depth, height, width] . \n
  958. *@par Attributes:
  959. * Three attributes:
  960. * @li groups: Number of blocked connections from input channels to output
  961. * channels. Reserved.
  962. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  963. * Defaults to "NDHWC". Specify the data format of the input and output data.
  964. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  965. * dimension of input, now only support [1,1,1,1,1]
  966. *@par Outputs:
  967. * y: A Tensor. Has the same type and data format as out_backprop.
  968. *@par Third-party framework compatibility
  969. * Compatible with Tensorflow's conv3d_backprop_input
  970. *@par Restrictions:
  971. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropInput instead.
  972. */
  973. REG_OP(Conv3DBackpropInputD)
  974. .INPUT(filter, TensorType({DT_FLOAT16}))
  975. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  976. .OUTPUT(y, TensorType({DT_FLOAT16}))
  977. .REQUIRED_ATTR(input_size, ListInt)
  978. .REQUIRED_ATTR(strides, ListInt)
  979. .REQUIRED_ATTR(pads, ListInt)
  980. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  981. .ATTR(groups, Int, 1)
  982. .ATTR(data_format, String, "NDHWC")
  983. .OP_END_FACTORY_REG(Conv3DBackpropInputD)
  984. /**
  985. *@brief Applies a multi-layer long short-term memory (LSTM) RNN to an input sequence . \n
  986. *@par Inputs:
  987. * @li x: A Tensor dtype of float16.
  988. * @li cont: A Tensor dtype of float16, float32.
  989. * @li w_x: A Tensor dtype of float16.
  990. * @li bias: A Tensor dtype of int16, int32, float16, float32.
  991. * @li w_h: A Tensor dtype of float16.
  992. * @li x_static: A optinal Tensor dtype of float16.
  993. * @li h_0: A optinal Tensor dtype of float16, float32.
  994. * @li c_0: A optinal Tensor dtype of float16, float32.
  995. * @li w_x_static: A optinal Tensor dtype of float16 . \n
  996. *@par Attributes:
  997. *@li num_output: A Scalar of output size dtype of int.
  998. *@li expose_hidden: A Scalar(bool) of features hidden . \n
  999. *@par Outputs:
  1000. *@li h: A Tensor dtype of float16, float32.
  1001. * @li h_t: A optinal Tensor dtype of float16, float32. The hidden state at time t.
  1002. * @li c_t: A optinal Tensor dtype of float16, float32. The cell state at time t . \n
  1003. *@par Third-party framework compatibility:
  1004. * Compatible with the Pytorch operator adds.
  1005. *@par Restrictions:
  1006. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1007. */
  1008. REG_OP(LSTM)
  1009. .INPUT(x, TensorType({DT_FLOAT16}))
  1010. .INPUT(cont, TensorType({DT_FLOAT32,DT_FLOAT16}))
  1011. .INPUT(w_x, TensorType({DT_FLOAT16}))
  1012. .INPUT(bias, TensorType({DT_FLOAT16,DT_FLOAT32,DT_INT16,DT_INT32}))
  1013. .INPUT(w_h, TensorType({DT_FLOAT16}))
  1014. .OPTIONAL_INPUT(x_static, TensorType({DT_FLOAT16}))
  1015. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1016. .OPTIONAL_INPUT(c_0, TensorType({DT_FLOAT16,DT_FLOAT32}))
  1017. .OPTIONAL_INPUT(w_x_static, TensorType({DT_FLOAT16}))
  1018. .OUTPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1019. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1020. .OUTPUT(c_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1021. .ATTR(num_output, Int, 0)
  1022. .ATTR(expose_hidden, Bool, false)
  1023. .OP_END_FACTORY_REG(LSTM)
  1024. /**
  1025. *@brief Computes the gradients of convolution3D with respect to the filter
  1026. *@par Inputs:
  1027. * Three inputs:
  1028. * @li x: A Tensor. Must be one of the following types: float16, float32.
  1029. * Currently does not support double.
  1030. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1031. * or [batch, in_channels, in_depth, in_height, in_width].
  1032. * @li filter_size: A Tensor of type int32. An integer vector representing the
  1033. * tensor shape of filter, where filter is a 5-D tensor
  1034. * [filter_depth, filter_height, filter_width, in_channels, out_channels]
  1035. * [out_channels, in_channels, filter_depth, filter_height, filter_width]
  1036. * or [out_channels, filter_depth, filter_height, filter_width, in_channels].
  1037. * @li out_backprop: A Tensor. Must have the same type as x.
  1038. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1039. * or [batch, out_channels, out_depth, out_height, out_width].
  1040. * Gradients with respect to the output of the convolution. \n
  1041. *@par Required Attributes:
  1042. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1043. * window for each dimension of "x". The N and C dimensions must be 1.
  1044. * Has the same format as "x".
  1045. * @li pads: A tuple/list of 6 integers, [front, back, top, bottom, left, right]
  1046. * pads on feature map . \n
  1047. *@par Attributes:
  1048. * Three attributes:
  1049. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1050. * dimension of input, now only support [1,1,1,1,1].
  1051. * @li groups: Number of blocked connections from input channels to output
  1052. * channels. Reserved.
  1053. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1054. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1055. *@par Outputs:
  1056. * y: A Tensor that has the same type as x
  1057. * and the format is NDHWC, NCDHW or DHWCN.
  1058. *@par Third-party framework compatibility
  1059. * Compatible with Tensorflow's conv3d_backprop_filter
  1060. */
  1061. REG_OP(Conv3DBackpropFilter)
  1062. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1063. .INPUT(filter_size, TensorType({DT_INT32}))
  1064. .INPUT(out_backprop, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1065. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1066. .REQUIRED_ATTR(strides, ListInt)
  1067. .REQUIRED_ATTR(pads, ListInt)
  1068. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1069. .ATTR(groups, Int, 1)
  1070. .ATTR(data_format, String, "NDHWC")
  1071. .OP_END_FACTORY_REG(Conv3DBackpropFilter)
  1072. /**
  1073. *@brief Computes the gradients of convolution with respect to the filter.
  1074. *@par Inputs:
  1075. * Two inputs:
  1076. * @li x: A Tensor of type float16.
  1077. * 5-D with shape [batch, in_depth, in_height, in_width, in_channels]
  1078. * or [batch, in_channels, in_depth, in_height, in_width].
  1079. * @li out_backprop: A Tensor. Must have the same type as x.
  1080. * 5-D with shape [batch, out_depth, out_height, out_width, out_channels]
  1081. * or [batch, out_channels, out_depth, out_height, out_width].
  1082. * Gradients with respect to the output of the convolution. \n
  1083. *@par Required Attributes:
  1084. * @li filter_size: A tuple/list of type integers. An integer vector
  1085. * representing the tensor shape of filter, where filter is a 5-D tensor
  1086. * [filter_depth, filter_height, filter_width, in_channels, out_channels],
  1087. * [out_channels, filter_depth, filter_height, filter_width, in_channels]
  1088. * or [out_channels, in_channels, filter_depth, filter_height, filter_width].
  1089. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1090. * window for each dimension of "x".
  1091. * The N and C dimensions must be 1. Has the same format as "x".
  1092. * @li pads: A tuple/list of 6 integers, [front, back, top, bottom, left, right]
  1093. * pads on feature map. \n
  1094. *@par Attributes:
  1095. * Three attributes:
  1096. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1097. * dimension of input, now only support [1,1,1,1,1].
  1098. * @li groups: Number of blocked connections from input channels to output
  1099. * channels. Reserved.
  1100. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1101. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1102. *@par Outputs:
  1103. * y: A Tensor of type float32 and the format is NDHWC, NCDHW or DHWCN.
  1104. *@par Third-party framework compatibility
  1105. * Compatible with Tensorflow's conv3d_backprop_filter
  1106. *@par Restrictions:
  1107. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DBackpropFilter instead.
  1108. */
  1109. REG_OP(Conv3DBackpropFilterD)
  1110. .INPUT(x, TensorType({DT_FLOAT16}))
  1111. .INPUT(out_backprop, TensorType({DT_FLOAT16}))
  1112. .OUTPUT(y, TensorType({DT_FLOAT}))
  1113. .REQUIRED_ATTR(filter_size, ListInt)
  1114. .REQUIRED_ATTR(strides, ListInt)
  1115. .REQUIRED_ATTR(pads, ListInt)
  1116. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1117. .ATTR(groups, Int, 1)
  1118. .ATTR(data_format, String, "NDHWC")
  1119. .OP_END_FACTORY_REG(Conv3DBackpropFilterD)
  1120. /**
  1121. *@brief Computes the transpose of convolution 3d with respect to the input.
  1122. *@par Inputs:
  1123. * Three inputs:
  1124. * @li input_size: A Tensor of type int32. An integer vector representing the
  1125. * shape of input.
  1126. * @li x: A Tensor of type float16, currently does not support int8. The format
  1127. * is NDHWC or NCDHW.
  1128. * @li filter: A Tensor of type float16, currently does not support int8.
  1129. * The format is NDHWC, NCDHW or DHWCN.
  1130. *@par Optional input:
  1131. * Two optional inputs
  1132. * @li bias: An optional 1D tensor of the same type as "x". Reserved.
  1133. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  1134. *@par Required Attributes:
  1135. * @li strides: A tuple/list of 5 integers. Specifies the stride of the sliding
  1136. * window for each dimension of "x".
  1137. * The N and C dimensions must be 1. Has the same format as "x".
  1138. * @li pads: A tuple/list of 6 integers
  1139. *@par Attributes:
  1140. * Five attributes:
  1141. * @li groups: Number of blocked connections from input channels to output
  1142. * channels. Reserved.
  1143. * @li dilations: A tuple/list of 5 integers,
  1144. * The dilation factor for each dimension of input, now only support [1,1,1,1,1]
  1145. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1146. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1147. * @li output_padding: The size will be added in the output shape.
  1148. * @li offset_x: Input offset_x value. Reserved.
  1149. *@par Outputs:
  1150. * y: A Tensor. Has the same type and format as x.
  1151. */
  1152. REG_OP(Conv3DTranspose)
  1153. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1154. .INPUT(x, TensorType({DT_FLOAT16}))
  1155. .INPUT(filter, TensorType({DT_FLOAT16}))
  1156. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  1157. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1158. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1159. .REQUIRED_ATTR(strides, ListInt)
  1160. .REQUIRED_ATTR(pads, ListInt)
  1161. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1162. .ATTR(groups, Int, 1)
  1163. .ATTR(data_format, String, "NDHWC")
  1164. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1165. .ATTR(offset_x, Int, 0)
  1166. .OP_END_FACTORY_REG(Conv3DTranspose)
  1167. /**
  1168. *@brief Computes the transpose of convolution 3d with respect to the input.
  1169. *@par Inputs:
  1170. * @li x: A Tensor of type float16, currently does not support int8.
  1171. * The format is NDHWC or NCDHW.
  1172. * @li filter: A Tensor of type float16, currently does not support int8.
  1173. * The format is NDHWC, NCDHW or DHWCN.
  1174. *@par Optional inputs:
  1175. * @li bias: An optional 1D tensor of the same type as "x". Reserved.
  1176. * @li offset_w: An optional 1D tensor for quantized deconvolution. Reserved . \n
  1177. *@par Required Attributes:
  1178. * @li input_size: A tuple/list of type int32.
  1179. * An integer vector representing the shape of input
  1180. * @li strides: A tuple/list of 5 integers.
  1181. * Specifies the stride of the sliding window for each dimension of "x".
  1182. * The N and C dimensions must be 1. Has the same format as "x".
  1183. * @li pads: A tuple/list of 6 integers . \n
  1184. *@par Attributes:
  1185. * Five attributes:
  1186. * @li dilations: A tuple/list of 5 integers, The dilation factor for each
  1187. * dimension of input, now only support [1,1,1,1,1]
  1188. * @li groups: Number of blocked connections from input channels to output
  1189. * channels. Reserved.
  1190. * @li data_format: An optional string from: "NDHWC", "NCDHW".
  1191. * Defaults to "NDHWC". Specify the data format of the input and output data.
  1192. * @li output_padding: The size will be added in the output shape.
  1193. * @li offset_x: Input offset_x value. Reserved.
  1194. *@par Outputs:
  1195. * y: A Tensor. Has the same type and format as x.
  1196. *@par Restrictions:
  1197. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv3DTranspose instead.
  1198. */
  1199. REG_OP(Conv3DTransposeD)
  1200. .INPUT(x, TensorType({DT_FLOAT16}))
  1201. .INPUT(filter, TensorType({DT_FLOAT16}))
  1202. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16}))
  1203. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1204. .OUTPUT(y, TensorType({DT_FLOAT16}))
  1205. .REQUIRED_ATTR(input_size, ListInt)
  1206. .REQUIRED_ATTR(strides, ListInt)
  1207. .REQUIRED_ATTR(pads, ListInt)
  1208. .ATTR(dilations, ListInt, {1, 1, 1, 1, 1})
  1209. .ATTR(groups, Int, 1)
  1210. .ATTR(data_format, String, "NDHWC")
  1211. .ATTR(output_padding, ListInt, {0, 0, 0, 0, 0})
  1212. .ATTR(offset_x, Int, 0)
  1213. .OP_END_FACTORY_REG(Conv3DTransposeD)
  1214. /**
  1215. *@brief Computes the transpose of convolution 2d with respect to the input.
  1216. *@par Inputs:
  1217. * Five inputs:
  1218. * @li input_size: A Tensor of type int32 or int64. An integer vector
  1219. * representing the shape of input, where input is a 4-D tensor
  1220. * [batch, height, width, channels] or [batch, channels, height, width].
  1221. * @li x: A Tensor of type float16, int8. 4-D with shape [batch, out_height,
  1222. * out_width, out_channels] or [batch, out_channels, out_height, out_width].
  1223. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1224. * 4-D with shape [filter_height, filter_width, in_channels, out_channels]
  1225. * or [out_channels, filter_height, filter_width, in_channels]
  1226. * or [out_channels, in_channel, filter_height, filter_width].
  1227. * @li bias: An optional 1D tensor of type float16 or int32. Format is "ND".
  1228. * @li offset_w: An optional 1D tensor for quantized inference. Reserved.
  1229. *@par Required Attributes:
  1230. * @li strides: A required tuple/list of 4 integers. The stride of the sliding
  1231. * window for H/W dimension. The index of H/W is same as data_format.
  1232. * @li pads: A required tuple/list of 4 integers, [top, bottom, left, right]
  1233. * pads on feature map.
  1234. *@par Attributes:
  1235. * Five attributes:
  1236. * @li groups: Number of blocked connections from input channels to output
  1237. * channels.
  1238. * Defaults to "1".
  1239. * @li dilations: A tuple/list of 4 integers, The dilation factor for each
  1240. * dimension of input. Must be [1, 1, 1, 1].
  1241. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC".
  1242. * Specify the data format of the input and output data.
  1243. * @li output_padding: The size will be added in the output shape. Defaults
  1244. * to [0, 0, 0, 0].
  1245. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1246. * Defaults to "0".
  1247. *@par Outputs:
  1248. * y: A Tensor. A Tensor of type float16 or int32, and has same format as
  1249. * input_size.
  1250. */
  1251. REG_OP(Conv2DTranspose)
  1252. .INPUT(input_size, TensorType({DT_INT32, DT_INT64}))
  1253. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1254. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1255. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  1256. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1257. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  1258. .REQUIRED_ATTR(strides, ListInt)
  1259. .REQUIRED_ATTR(pads, ListInt)
  1260. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1261. .ATTR(groups, Int, 1)
  1262. .ATTR(data_format, String, "NHWC")
  1263. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1264. .ATTR(offset_x, Int, 0)
  1265. .OP_END_FACTORY_REG(Conv2DTranspose)
  1266. /**
  1267. *@brief Computes the transpose of convolution 2d with respect to the input.
  1268. *@par Inputs:
  1269. * Four inputs:
  1270. * @li x: A Tensor of type float16, int8.
  1271. * @li filter: A Tensor of type float16, int8. Must have the same type as "x".
  1272. * @li bias: An optional 1D tensor of the same type as "x".
  1273. * @li offset_w: An optional 1D tensor for quantized inference. Type is int8. Reserved.
  1274. *@par Required Attributes:
  1275. * @li input_size: A Tensor of type int32 or int64. An integer vector representing the
  1276. * shape of input.
  1277. * @li strides: A required list or tuple. The stride of the sliding window for
  1278. * height and width for H/W dimension.
  1279. * @li pads: A required list or tuple of int32. Padding added to each dimension
  1280. * of the input.
  1281. *@par Attributes:
  1282. * Five attributes:
  1283. * @li groups: Number of blocked connections from input channels to output channels.
  1284. * Defaults to "1".
  1285. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1286. * of input. Must be [1, 1, 1, 1].
  1287. * @li data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC".
  1288. * Specify the data format of the input and output data.
  1289. * @li output_padding: The size will be added in the output shape. Defaults
  1290. * to [0, 0, 0, 0].
  1291. * @li offset_x: An optional int. Input offset, used for quantized inference.
  1292. * Defaults to "0".
  1293. *@par Outputs:
  1294. * y: A Tensor. Has the same type as "filter".
  1295. *@par Restrictions:
  1296. * Warning: THIS FUNCTION IS DEPRECATED. Please use Conv2DTranspose instead.
  1297. */
  1298. REG_OP(Conv2DTransposeD)
  1299. .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
  1300. .INPUT(filter, TensorType({DT_FLOAT16, DT_INT8}))
  1301. .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32}))
  1302. .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
  1303. .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
  1304. .REQUIRED_ATTR(input_size, ListInt)
  1305. .REQUIRED_ATTR(strides, ListInt)
  1306. .REQUIRED_ATTR(pads, ListInt)
  1307. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1308. .ATTR(groups, Int, 1)
  1309. .ATTR(data_format, String, "NHWC")
  1310. .ATTR(output_padding, ListInt, {0, 0, 0, 0})
  1311. .ATTR(offset_x, Int, 0)
  1312. .OP_END_FACTORY_REG(Conv2DTransposeD)
  1313. /**
  1314. *@brief Computes the deformed convolution output with the expected input
  1315. *@par Inputs:
  1316. * Four inputs:
  1317. * @li x: A Tensor of type float16,float32
  1318. * @li offsets: A Tensor of type float16,float32.Deformation offset parameter.
  1319. *@par Required Attributes:
  1320. * @li strides: A tuple/list of 4 integers.The stride of the sliding window for
  1321. * height and width for H/W dimension.
  1322. * @li pads: A tuple/list of 4 integers.Padding added to each dimension
  1323. * of the input.
  1324. * @li ksize: A tuple/list of 2 integers.kernel size.
  1325. *@par Attributes:
  1326. * Three attributes:
  1327. * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension
  1328. * of input. Defaults to [1, 1, 1, 1]
  1329. * @li data_format: An optional string from: "NCHW", "NHWC". Defaults to "NCHW". Specify the data format of the input x.
  1330. * @li deformable_groups: Specify the c-axis grouping number of input x.
  1331. *@par Outputs:
  1332. * y: A Tensor. A Tensor of type float16, float32.
  1333. */
  1334. REG_OP(DeformableOffsets)
  1335. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1336. .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT}))
  1337. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1338. .REQUIRED_ATTR(strides, ListInt)
  1339. .REQUIRED_ATTR(pads, ListInt)
  1340. .REQUIRED_ATTR(ksize, ListInt)
  1341. .ATTR(dilations, ListInt, {1, 1, 1, 1})
  1342. .ATTR(data_format, String, "NCHW")
  1343. .ATTR(deformable_groups, Int, 1)
  1344. .OP_END_FACTORY_REG(DeformableOffsets)
  1345. } // namespace ge
  1346. #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两部分组成,详细的架构图如下所示