You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

nn_calculation_ops.h 75 kB

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