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