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