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.

acl_tdt.h 7.8 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef INC_EXTERNAL_ACL_ACL_TDT_H_
  17. #define INC_EXTERNAL_ACL_ACL_TDT_H_
  18. #include "acl/acl_base.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. enum acltdtTensorType {
  23. ACL_TENSOR_DATA_UNDEFINED = -1,
  24. ACL_TENSOR_DATA_TENSOR,
  25. ACL_TENSOR_DATA_END_OF_SEQUENCE,
  26. ACL_TENSOR_DATA_ABNORMAL
  27. };
  28. typedef struct acltdtDataItem acltdtDataItem;
  29. typedef struct acltdtDataset acltdtDataset;
  30. typedef struct acltdtChannelHandle acltdtChannelHandle;
  31. /**
  32. * @ingroup AscendCL
  33. * @brief Get tensor type from item
  34. *
  35. * @param dataItem [IN] pointer to the data item
  36. *
  37. * @retval Tensor type.
  38. * @retval ACL_DT_UNDEFINED if dataItem is null
  39. */
  40. ACL_FUNC_VISIBILITY acltdtTensorType acltdtGetTensorTypeFromItem(const acltdtDataItem *dataItem);
  41. /**
  42. * @ingroup AscendCL
  43. * @brief Get data type from item
  44. *
  45. * @param dataItem [IN] pointer to the data item
  46. *
  47. * @retval Data type.
  48. * @retval ACL_DT_UNDEFINED if dataItem is null
  49. */
  50. ACL_FUNC_VISIBILITY aclDataType acltdtGetDataTypeFromItem(const acltdtDataItem *dataItem);
  51. /**
  52. * @ingroup AscendCL
  53. * @brief Get data address from item
  54. *
  55. * @param dataItem [IN] pointer to data item
  56. *
  57. * @retval null for failed
  58. * @retval OtherValues success
  59. */
  60. ACL_FUNC_VISIBILITY void *acltdtGetDataAddrFromItem(const acltdtDataItem *dataItem);
  61. /**
  62. * @ingroup AscendCL
  63. * @brief Get data size from item
  64. *
  65. * @param dataItem [IN] pointer to data item
  66. *
  67. * @retval 0 for failed
  68. * @retval OtherValues success
  69. */
  70. ACL_FUNC_VISIBILITY size_t acltdtGetDataSizeFromItem(const acltdtDataItem *dataItem);
  71. /**
  72. * @ingroup AscendCL
  73. * @brief Get dim's number from item
  74. *
  75. * @param dataItem [IN] pointer to data item
  76. *
  77. * @retval 0 for failed
  78. * @retval OtherValues success
  79. */
  80. ACL_FUNC_VISIBILITY size_t acltdtGetDimNumFromItem(const acltdtDataItem *dataItem);
  81. /**
  82. * @ingroup AscendCL
  83. * @brief Get dims from item
  84. *
  85. * @param dataItem [IN] the struct of data item
  86. * @param dims [IN|OUT] pointer to the dims of dataTtem
  87. * @param dimNum [IN] the size of the dims
  88. *
  89. * @retval ACL_SUCCESS The function is successfully executed.
  90. * @retval OtherValues Failure
  91. */
  92. ACL_FUNC_VISIBILITY aclError acltdtGetDimsFromItem(const acltdtDataItem *dataItem, int64_t *dims, size_t dimNum);
  93. /**
  94. * @ingroup AscendCL
  95. * @brief Create the struct of data item
  96. *
  97. * @param tdtType [IN] Tdt tensor type
  98. * @param dims [IN] pointer of tdtDataItem's dims
  99. * @param dimNum [IN] Dim number
  100. * @param dataType [IN] Data type
  101. * @param data [IN] Data pointer
  102. * @param size [IN] Data size
  103. *
  104. * @retval null for failed
  105. * @retval OtherValues success
  106. *
  107. * @see acltdtDestroyDataItem
  108. */
  109. ACL_FUNC_VISIBILITY acltdtDataItem *acltdtCreateDataItem(acltdtTensorType tdtType,
  110. const int64_t *dims,
  111. size_t dimNum,
  112. aclDataType dataType,
  113. void *data,
  114. size_t size);
  115. /**
  116. * @ingroup AscendCL
  117. * @brief Destroy the struct of data item
  118. *
  119. * @param dataItem [IN] pointer to the data item
  120. *
  121. * @retval ACL_SUCCESS The function is successfully executed.
  122. * @retval OtherValues Failure
  123. *
  124. * @see acltdtCreateDataItem
  125. */
  126. ACL_FUNC_VISIBILITY aclError acltdtDestroyDataItem(acltdtDataItem *dataItem);
  127. /**
  128. * @ingroup AscendCL
  129. * @brief Create the tdt dataset
  130. *
  131. * @retval null for failed
  132. * @retval OtherValues success
  133. *
  134. * @see acltdtDestroyDataset
  135. */
  136. ACL_FUNC_VISIBILITY acltdtDataset *acltdtCreateDataset();
  137. /**
  138. * @ingroup AscendCL
  139. * @brief Destroy the tdt dataset
  140. *
  141. * @param dataset [IN] pointer to the dataset
  142. *
  143. * @retval ACL_SUCCESS The function is successfully executed.
  144. * @retval OtherValues Failure
  145. *
  146. * @see acltdtCreateDataset
  147. */
  148. ACL_FUNC_VISIBILITY aclError acltdtDestroyDataset(acltdtDataset *dataset);
  149. /**
  150. * @ingroup AscendCL
  151. * @brief Get the data item
  152. *
  153. * @param dataset [IN] pointer to the dataset
  154. * @param index [IN] index of the dataset
  155. *
  156. * @retval null for failed
  157. * @retval OtherValues success
  158. *
  159. * @see acltdtAddDataItem
  160. */
  161. ACL_FUNC_VISIBILITY acltdtDataItem *acltdtGetDataItem(const acltdtDataset *dataset, size_t index);
  162. /**
  163. * @ingroup AscendCL
  164. * @brief Get the data item
  165. *
  166. * @param dataset [OUT] pointer to the dataset
  167. * @param dataItem [IN] pointer to the data item
  168. *
  169. * @retval ACL_SUCCESS The function is successfully executed.
  170. * @retval OtherValues Failure
  171. *
  172. * @see acltdtGetDataItem
  173. */
  174. ACL_FUNC_VISIBILITY aclError acltdtAddDataItem(acltdtDataset *dataset, acltdtDataItem *dataItem);
  175. /**
  176. * @ingroup AscendCL
  177. * @brief Get the size of dataset
  178. *
  179. * @param dataset [IN] pointer to the dataset
  180. *
  181. * @retval 0 for failed
  182. * @retval OtherValues success
  183. */
  184. ACL_FUNC_VISIBILITY size_t acltdtGetDatasetSize(const acltdtDataset *dataset);
  185. /**
  186. * @ingroup AscendCL
  187. * @brief Stop the channel
  188. *
  189. * @param handle [IN] pointer to the channel handle
  190. *
  191. * @retval ACL_SUCCESS The function is successfully executed.
  192. * @retval OtherValues Failure
  193. *
  194. * @see acltdtCreateChannel | acltdtDestroyChannel
  195. */
  196. ACL_FUNC_VISIBILITY aclError acltdtStopChannel(acltdtChannelHandle *handle);
  197. /**
  198. * @ingroup AscendCL
  199. * @brief Create the channel
  200. *
  201. * @param deviceId [IN] the device id
  202. * @param name [IN] the channel's name
  203. *
  204. * @retval null for failed
  205. * @retval OtherValues success
  206. *
  207. * @see acltdtStopChannel | acltdtDestroyChannel
  208. */
  209. ACL_FUNC_VISIBILITY acltdtChannelHandle *acltdtCreateChannel(uint32_t deviceId, const char *name);
  210. /**
  211. * @ingroup AscendCL
  212. * @brief Destroy the channel
  213. *
  214. * @param handle [IN] pointer to the channel handle
  215. *
  216. * @retval ACL_SUCCESS The function is successfully executed.
  217. * @retval OtherValues Failure
  218. *
  219. * @see acltdtCreateChannel | acltdtStopChannel
  220. */
  221. ACL_FUNC_VISIBILITY aclError acltdtDestroyChannel(acltdtChannelHandle *handle);
  222. /**
  223. * @ingroup AscendCL
  224. * @brief Send tensor to device
  225. *
  226. * @param handle [IN] pointer to the channel handle
  227. * @param dataset [IN] pointer to the dataset
  228. * @param timeout [IN] to be reserved, now it must be -1
  229. *
  230. * @retval ACL_SUCCESS The function is successfully executed.
  231. * @retval OtherValues Failure
  232. *
  233. * @see acltdtReceiveTensor
  234. */
  235. ACL_FUNC_VISIBILITY aclError acltdtSendTensor(const acltdtChannelHandle *handle,
  236. const acltdtDataset *dataset,
  237. int32_t timeout);
  238. /**
  239. * @ingroup AscendCL
  240. * @brief Receive tensor from device
  241. *
  242. * @param handle [IN] pointer to the channel handle
  243. * @param dataset [OUT] pointer to the dataset
  244. * @param timeout [IN] to be reserved, now it must be -1
  245. *
  246. * @retval ACL_SUCCESS The function is successfully executed.
  247. * @retval OtherValues Failure
  248. *
  249. * @see acltdtSendTensor
  250. */
  251. ACL_FUNC_VISIBILITY aclError acltdtReceiveTensor(const acltdtChannelHandle *handle,
  252. acltdtDataset *dataset,
  253. int32_t timeout);
  254. #ifdef __cplusplus
  255. }
  256. #endif
  257. #endif //INC_EXTERNAL_ACL_ACL_TDT_H_

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