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.

split_combination_ops.h 15 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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 split_combination_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Splits a tensor along dimension "split_dim" into "num_split" smaller tensors . \n
  26. *@par Inputs:
  27. * Two inputs, including:
  28. *@li x: An ND Tensor.
  29. *Must be one of the types:float16, float32, double, int64, int32, uint8, uint16, uint32, uint64, int8, int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32.
  30. *@li split_dim: Must be the following type:int32. Specifies the dimension along which to split . \n
  31. *@par Attributes:
  32. *num_split: A required int32. Specifies the number of output tensors. No default value . \n
  33. *@par Outputs:
  34. *y: Dynamic output.A list of output tensors. Has the same type and format as "x" . \n
  35. *@attention Constraints:
  36. *@li "num_split" is greater than or equals to 1.
  37. *@li "num_split" is divisible by the size of dimension "split_dim".
  38. *@li "split_dim" is in the range [-len(x.shape), (x.shape)-1] . \n
  39. *@par Third-party framework compatibility
  40. * Compatible with the TensorFlow operator Split.
  41. */
  42. REG_OP(Split)
  43. .INPUT(split_dim, TensorType({DT_INT32}))
  44. .INPUT(x, TensorType::BasicType())
  45. .DYNAMIC_OUTPUT(y, TensorType::BasicType())
  46. .REQUIRED_ATTR(num_split, Int)
  47. .OP_END_FACTORY_REG(Split)
  48. /**
  49. *@brief Splits a tensor along dimension "split_dim" into "num_split" smaller tensors . \n
  50. *@par Inputs:
  51. * One input:
  52. *: An ND Tensor.
  53. *Must be one of the following types: float16, float32, int32, int8, int16, int64, uint8, uint16, uint32, uint64
  54. *@par Attributes:
  55. *@li split_dim: A required int32. Specifies the dimension along which to split. No default value.
  56. *@li num_split: A required int32. Specifies the number of output tensors. No default value . \n
  57. *@par Outputs:
  58. *y:Dynamic output. A list of output tensors. Has the same type and format as "x" . \n
  59. *@attention Constraints:
  60. *@li "num_split" is greater than or equals to 1.
  61. *@li "num_split" is divisible by the size of dimension "split_dim".
  62. *@li "split_dim" is in the range [-len(x.shape), (x.shape)-1] . \n
  63. *@par Third-party framework compatibility
  64. * Compatible with the TensorFlow operator Split.
  65. * @par Restrictions:
  66. * Warning: THIS FUNCTION IS DEPRECATED. Please use Split instead.
  67. */
  68. REG_OP(SplitD)
  69. .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  70. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT, DT_FLOAT16}))
  71. .DYNAMIC_OUTPUT(y, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  72. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT, DT_FLOAT16}))
  73. .REQUIRED_ATTR(split_dim, Int)
  74. .REQUIRED_ATTR(num_split, Int)
  75. .OP_END_FACTORY_REG(SplitD)
  76. /**
  77. *@brief Splits a tensor along dimension "split_dim" into "num_split" smaller tensors according to "size_splits" . \n
  78. *@par Inputs:
  79. * Three inputs, including:
  80. *@li x: An ND Tensor.
  81. *Must be one of the types:float16, float32, double, int64, int32, uint8, uint16, uint32, uint64, int8, int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32.
  82. *@li size_splits: Must be one of the types:int32, int64. Specifies a list containing the sizes of each output tensor along the split dimension.
  83. *@li split_dim: Must be the following type:int32. Specifies the dimension along which to split . \n
  84. *@par Attributes:
  85. *num_split: A required int32. Specifies the number of output tensors. No default value . \n
  86. *@par Outputs:
  87. *y: Dynamic output.A list of output tensors. Has the same type and format as "x" . \n
  88. *@attention Constraints:
  89. *@li Each element in "size_splits" is greater than or equal to 1.
  90. *@li "size_splits" and "num_split" have the same length.
  91. *@li The elements in "size_splits" sum to the size of dimension "split_dim" . \n
  92. *@par Third-party framework compatibility
  93. * Compatible with the TensorFlow operator SplitV.
  94. */
  95. REG_OP(SplitV)
  96. .INPUT(x, TensorType::BasicType())
  97. .INPUT(size_splits, TensorType::IndexNumberType())
  98. .INPUT(split_dim, TensorType({DT_INT32}))
  99. .DYNAMIC_OUTPUT(y, TensorType::BasicType())
  100. .REQUIRED_ATTR(num_split, Int)
  101. .OP_END_FACTORY_REG(SplitV)
  102. /**
  103. *@brief Splits a tensor along dimension "split_dim" into "num_split" smaller tensors according to "size_splits" . \n
  104. *@par Inputs:
  105. * One input:
  106. * x: An ND Tensor.
  107. *Must be one of the following types: float16, float32, int32, int8, int16, int64, uint8, uint16, uint32, uint64
  108. *@par Attributes:
  109. *@li size_splits: A required list of int32. Specifies a list containing the sizes of each output tensor along the split dimension.
  110. *@li split_dim: A required int32. Specifies the dimension along which to split. No default value.
  111. *@li num_split: A required int32. Specifies the number of output tensors. No default value . \n
  112. *@par Outputs:
  113. *y: Dynamic output.A list of output tensors. Has the same type and format as "x" . \n
  114. *@attention Constraints:
  115. *@li Each element in "size_splits" is greater than or equal to 1.
  116. *@li "size_splits" and "num_split" have the same length.
  117. Under the caffe framework, the conversion of slice_point through the cut point to cut segment is mapped to size_splits.
  118. *@li The elements in "size_splits" sum to the size of dimension "split_dim".
  119. Under the caffe framework,size_splits or axis transformat to split_dim.Only one can effect.
  120. *@par Third-party framework compatibility
  121. * Compatible with the TensorFlow operator SplitV.
  122. * @par Restrictions:
  123. * Warning: THIS FUNCTION IS DEPRECATED. Please use SplitV instead.
  124. */
  125. REG_OP(SplitVD)
  126. .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  127. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT, DT_FLOAT16}))
  128. .DYNAMIC_OUTPUT(y, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
  129. DT_UINT16, DT_UINT32, DT_UINT64, DT_FLOAT, DT_FLOAT16}))
  130. .REQUIRED_ATTR(size_splits, ListInt)
  131. .REQUIRED_ATTR(split_dim, Int)
  132. .REQUIRED_ATTR(num_split, Int)
  133. .OP_END_FACTORY_REG(SplitVD)
  134. /**
  135. *@brief Concatenates a list of N tensors along the first dimension.
  136. *@par Inputs:
  137. * Two inputs, including:
  138. * @li values: A list of Tensors. Must be one of the following types: int8, int16, int32,
  139. * int64, uint8, uint16, uint32, uint64, float16, float32.
  140. * Tensors to be concatenated. All must have size 1 in the first dimension and same shape.
  141. * It's a dynamic input.
  142. * @li shape: A Tensor of the same type as "x".
  143. * The final shape of the result. Should be equal to the shapes of any input
  144. * but with the number of input values in the first dimension . \n
  145. *@par Attributes:
  146. * @li shape: A required list of ints.
  147. * @li N: The numble of dynamic_input "values" . \n
  148. *@par Outputs:
  149. *output_data: The concatenated tensor with same type as "values".
  150. *@par Third-party framework compatibility
  151. *Compatible with the TensorFlow operator ParallelConcat.
  152. */
  153. REG_OP(ParallelConcat)
  154. .DYNAMIC_INPUT(values, TensorType({DT_FLOAT,DT_FLOAT16,DT_INT8,DT_INT16,DT_INT32,DT_INT64,DT_UINT8,DT_UINT16,DT_UINT32,DT_UINT64}))
  155. .OUTPUT(output_data, TensorType({DT_FLOAT,DT_FLOAT16,DT_INT8,DT_INT16,DT_INT32,DT_INT64,DT_UINT8,DT_UINT16,DT_UINT32,DT_UINT64}))
  156. .REQUIRED_ATTR(shape, ListInt)
  157. .REQUIRED_ATTR(N, Int)
  158. .OP_END_FACTORY_REG(ParallelConcat)
  159. /**
  160. *@brief Concatenates tensors along one dimension . \n
  161. *@par Inputs:
  162. * One input:
  163. *x: Dynamic input.An NC1HWC0 or ND Tensor.
  164. *Must be one of the following types: float16, float32, int32, int8, int16, int64, uint8, uint16, uint32, uint64
  165. *@par Attributes:
  166. *concat_dim: A required int8, int16, int32, or int64. Specifies the dimension along which to concatenate. No default value.
  167. *N: An attribute int8, int16, int32, or int64. Specifies the number of elements in "x". Defaults to "1".
  168. *@par Outputs:
  169. *y: A Tensor. Has the same type and format as "x" . \n
  170. *@attention Constraints:
  171. *@li "x" is a list of at least 2 "tensor" objects of the same type.
  172. *@li "concat_dim" is in the range [-len(x.shape), len(x.shape)] . \n
  173. *@par Third-party framework compatibility
  174. * Compatible with the TensorFlow operator ConcatV2.
  175. *@par Restrictions:
  176. *Warning: THIS FUNCTION IS DEPRECATED. Please use ConcatV2 instead.
  177. */
  178. REG_OP(ConcatV2D)
  179. .DYNAMIC_INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_INT64, DT_UINT64, DT_UINT32, DT_INT16, DT_UINT16, DT_UINT8}))
  180. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_INT64, DT_UINT64, DT_UINT32, DT_INT16, DT_UINT16, DT_UINT8}))
  181. .REQUIRED_ATTR(concat_dim, Int)
  182. .ATTR(N, Int, 1)
  183. .OP_END_FACTORY_REG(ConcatV2D)
  184. /**
  185. *@brief Concatenates tensors along one dimension . \n
  186. *@par Inputs:
  187. * Two inputs, including:
  188. *@li Dynamic input "x" is An NC1HWC0 or ND Tensor.
  189. *Must be one of the following types: float16, float32, int32, int8, int16, int64, uint8, uint16, uint32, uint64
  190. *@li concat_dim: An int32, or int64. Specifies the dimension along which to concatenate . \n
  191. *@par Attributes:
  192. *N: An optional int8, int16, int32, or int64. Specifies the number of elements in "x". No default value . \n
  193. *@par Outputs:
  194. *y: A Tensor. Has the same type and format as "x" . \n
  195. *@attention Constraints:
  196. * "x" is a list of at least 2 "tensor" objects of the same type . \n
  197. *@par Third-party framework compatibility
  198. * Compatible with the TensorFlow operator ConcatV2.
  199. */
  200. REG_OP(ConcatV2)
  201. .DYNAMIC_INPUT(x, TensorType::BasicType())
  202. .INPUT(concat_dim, TensorType::IndexNumberType())
  203. .OUTPUT(y, TensorType::BasicType())
  204. .ATTR(N, Int, 1)
  205. .OP_END_FACTORY_REG(ConcatV2)
  206. /**
  207. *@brief Concatenates tensors along one dimension . \n
  208. *@par Inputs:
  209. * One input:
  210. *x:Dynamic input. An NC1HWC0 or ND Tensor.
  211. *Must be one of the following types: float16, float32, int32, int8, int16, int64, uint8, uint16, uint32, uint64
  212. *@par Attributes:
  213. *@li concat_dim: A required int8, int16, int32, or int64. Specifies the dimension along which to concatenate. No default value.
  214. *@li N: An optional int8, int16, int32, or int64. Specifies the number of elements in "x". No default value . \n
  215. *@par Outputs:
  216. *y: A Tensor. Has the same type and format as "x" . \n
  217. *@attention Constraints:
  218. *@li "x" is a list of at least 2 "tensor" objects of the same type.
  219. *@li "concat_dim" is in the range [-len(x.shape), len(x.shape)] . \n
  220. *@par Third-party framework compatibility
  221. * Compatible with the TensorFlow operator Concat.
  222. *@par Restrictions:
  223. *Warning: THIS FUNCTION IS DEPRECATED. Please use Concat instead.
  224. */
  225. REG_OP(ConcatD)
  226. .DYNAMIC_INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16,DT_INT8,DT_INT16,DT_INT32,DT_INT64,DT_UINT8,DT_UINT16,DT_UINT32,DT_UINT64}))
  227. .OUTPUT(y, TensorType({DT_FLOAT,DT_FLOAT16,DT_INT8,DT_INT16,DT_INT32,DT_INT64,DT_UINT8,DT_UINT16,DT_UINT32,DT_UINT64}))
  228. .REQUIRED_ATTR(concat_dim, Int)
  229. .ATTR(N, Int, 1)
  230. .OP_END_FACTORY_REG(ConcatD)
  231. /**
  232. *@brief Concatenates tensors along one dimension . \n
  233. *@par Inputs:
  234. * Two inputs, including:
  235. *@li x: Dynamic input.An NC1HWC0 or ND Tensor.
  236. *Must be one of the following types: float16, float32, double, int32,
  237. * uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16,
  238. * complex128, uint32, uint64, qint16, quint16.
  239. *@li concat_dim: An int32, or int64. Specifies the dimension along which to concatenate . \n
  240. *@par Attributes:
  241. *N: An optional int8, int16, int32, or int64. Specifies the number of elements in "x" . \n
  242. *@par Outputs:
  243. *y: A Tensor. Has the same type and format as "x" . \n
  244. *@attention Constraints:
  245. *@li "x" is a list of at least 2 "tensor" objects of the same type.
  246. *@li "concat_dim" is in the range [-len(x.shape), len(x.shape)] . \n
  247. *@par Third-party framework compatibility
  248. * Compatible with the TensorFlow operator Concat.
  249. */
  250. REG_OP(Concat)
  251. .DYNAMIC_INPUT(x, TensorType::BasicType())
  252. .INPUT(concat_dim, TensorType::IndexNumberType())
  253. .OUTPUT(y, TensorType::BasicType())
  254. .ATTR(N, Int, 1)
  255. .OP_END_FACTORY_REG(Concat)
  256. /**
  257. *@brief Packs the list of tensors in values into a tensor with rank one higher than each tensor in
  258. * values, by packing them along the axis dimension. Given a list of length N of tensors of
  259. * shape (A, B, C); if axis == 0 then the output tensor will have the shape (N, A, B, C) . \n
  260. *@par Inputs:
  261. * x: A list of N Tensors. Must be one of the following types: int8, int16, int32,
  262. * int64, uint8, uint16, uint32, uint64, float16, float32, bool . It's a dynamic input. \n
  263. *@par Attributes:
  264. *@li axis: A optional int, defaultvalue is 0.
  265. * Dimension along which to pack. The range is [-(R+1), R+1).
  266. *@li N: A required int. Number of tensors . \n
  267. *@par Outputs:
  268. *y: A Tensor. Has the same type as "x".
  269. *@par Third-party framework compatibility
  270. *Compatible with the TensorFlow operator Pack.
  271. It's a dynamic output.
  272. */
  273. REG_OP(Pack)
  274. .DYNAMIC_INPUT(x, TensorType::BasicType())
  275. .OUTPUT(y, TensorType::BasicType())
  276. .ATTR(axis, Int, 0)
  277. .REQUIRED_ATTR(N, Int)
  278. .OP_END_FACTORY_REG(Pack)
  279. /**
  280. *@brief Computes offsets of concat inputs within its output . \n
  281. *@par Inputs:
  282. *Two inputs, including:
  283. * @li concat_dim: A Tensor of type int32.
  284. * @li x: A list of 1D Tensor objects of type int32 . It's a dynamic input. \n
  285. *@par Attributes:
  286. *N: A required int . \n
  287. *@par Outputs:
  288. *y: A Tensor list with same type as "x" . It's a dynamic output. \n
  289. *@par Third-party framework compatibility
  290. *@ Compatible with the TensorFlow operator ConcatOffset.
  291. */
  292. REG_OP(ConcatOffset)
  293. .INPUT(concat_dim, TensorType({DT_INT32}))
  294. .DYNAMIC_INPUT(x, TensorType({DT_INT32}))
  295. .DYNAMIC_OUTPUT(y, TensorType({DT_INT32}))
  296. .REQUIRED_ATTR(N, Int)
  297. .OP_END_FACTORY_REG(ConcatOffset)
  298. /**
  299. *@brief Computes offsets of concat inputs within its output . \n
  300. *@par Inputs:
  301. *Two inputs, including:
  302. * @li concat_dim: A Tensor of type int32.
  303. * @li x: A list of 1D Tensor objects of type int32 . It's a dynamic input. \n
  304. *@par Attributes:
  305. *@li Concat_dim: A required int. Must be within the rank of input "x".
  306. *@li N: A required int . \n
  307. *@par Outputs:
  308. *y: A Tensor list with same type as "x" . It's a dynamic output. \n
  309. *@par Third-party framework compatibility
  310. *@ Compatible with the TensorFlow operator ConcatOffset.
  311. *@par Restrictions:
  312. *Warning: THIS FUNCTION IS DEPRECATED. Please use ConcatOffset instead.
  313. */
  314. REG_OP(ConcatOffsetD)
  315. .DYNAMIC_INPUT(x, TensorType({DT_INT32}))
  316. .DYNAMIC_OUTPUT(y, TensorType({DT_INT32}))
  317. .REQUIRED_ATTR(concat_dim, Int)
  318. .REQUIRED_ATTR(N, Int)
  319. .OP_END_FACTORY_REG(ConcatOffsetD)
  320. } // namespace ge
  321. #endif // OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示