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 8.6 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
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /**
  2. * Copyright 2019-2022 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, const int64_t *dims, size_t dimNum,
  110. aclDataType dataType, void *data, size_t size);
  111. /**
  112. * @ingroup AscendCL
  113. * @brief Destroy the struct of data item
  114. *
  115. * @param dataItem [IN] pointer to the data item
  116. *
  117. * @retval ACL_SUCCESS The function is successfully executed.
  118. * @retval OtherValues Failure
  119. *
  120. * @see acltdtCreateDataItem
  121. */
  122. ACL_FUNC_VISIBILITY aclError acltdtDestroyDataItem(acltdtDataItem *dataItem);
  123. /**
  124. * @ingroup AscendCL
  125. * @brief Create the tdt dataset
  126. *
  127. * @retval null for failed
  128. * @retval OtherValues success
  129. *
  130. * @see acltdtDestroyDataset
  131. */
  132. ACL_FUNC_VISIBILITY acltdtDataset *acltdtCreateDataset();
  133. /**
  134. * @ingroup AscendCL
  135. * @brief Destroy the tdt dataset
  136. *
  137. * @param dataset [IN] pointer to the dataset
  138. *
  139. * @retval ACL_SUCCESS The function is successfully executed.
  140. * @retval OtherValues Failure
  141. *
  142. * @see acltdtCreateDataset
  143. */
  144. ACL_FUNC_VISIBILITY aclError acltdtDestroyDataset(acltdtDataset *dataset);
  145. /**
  146. * @ingroup AscendCL
  147. * @brief Get the data item
  148. *
  149. * @param dataset [IN] pointer to the dataset
  150. * @param index [IN] index of the dataset
  151. *
  152. * @retval null for failed
  153. * @retval OtherValues success
  154. *
  155. * @see acltdtAddDataItem
  156. */
  157. ACL_FUNC_VISIBILITY acltdtDataItem *acltdtGetDataItem(const acltdtDataset *dataset, size_t index);
  158. /**
  159. * @ingroup AscendCL
  160. * @brief Get the data item
  161. *
  162. * @param dataset [OUT] pointer to the dataset
  163. * @param dataItem [IN] pointer to the data item
  164. *
  165. * @retval ACL_SUCCESS The function is successfully executed.
  166. * @retval OtherValues Failure
  167. *
  168. * @see acltdtGetDataItem
  169. */
  170. ACL_FUNC_VISIBILITY aclError acltdtAddDataItem(acltdtDataset *dataset, acltdtDataItem *dataItem);
  171. /**
  172. * @ingroup AscendCL
  173. * @brief Get the size of dataset
  174. *
  175. * @param dataset [IN] pointer to the dataset
  176. *
  177. * @retval 0 for failed
  178. * @retval OtherValues success
  179. */
  180. ACL_FUNC_VISIBILITY size_t acltdtGetDatasetSize(const acltdtDataset *dataset);
  181. /**
  182. * @ingroup AscendCL
  183. * @brief Get the name of dataset
  184. *
  185. * @param dataset [IN] pointer to the dataset
  186. *
  187. * @retval null for failed
  188. * @retval OtherValues success
  189. */
  190. ACL_FUNC_VISIBILITY const char *acltdtGetDatasetName(const acltdtDataset *dataset);
  191. /**
  192. * @ingroup AscendCL
  193. * @brief Stop the channel
  194. *
  195. * @param handle [IN] pointer to the channel handle
  196. *
  197. * @retval ACL_SUCCESS The function is successfully executed.
  198. * @retval OtherValues Failure
  199. *
  200. * @see acltdtCreateChannel | acltdtDestroyChannel
  201. */
  202. ACL_FUNC_VISIBILITY aclError acltdtStopChannel(acltdtChannelHandle *handle);
  203. /**
  204. * @ingroup AscendCL
  205. * @brief Create the channel
  206. *
  207. * @param deviceId [IN] the device id
  208. * @param name [IN] the name of channel
  209. *
  210. * @retval null for failed
  211. * @retval OtherValues success
  212. *
  213. * @see acltdtStopChannel | acltdtDestroyChannel
  214. */
  215. ACL_FUNC_VISIBILITY acltdtChannelHandle *acltdtCreateChannel(uint32_t deviceId, const char *name);
  216. /**
  217. * @ingroup AscendCL
  218. * @brief Create the channel with max size
  219. *
  220. * @param deviceId [IN] the device id
  221. * @param name [IN] the name of channel
  222. * @param capacity [IN] the capacity of channel
  223. *
  224. * @retval null for failed
  225. * @retval OtherValues success
  226. *
  227. * @see acltdtDestroyChannel
  228. */
  229. ACL_FUNC_VISIBILITY acltdtChannelHandle *acltdtCreateChannelWithCapacity(uint32_t deviceId, const char *name,
  230. size_t capacity);
  231. /**
  232. * @ingroup AscendCL
  233. * @brief Destroy the channel
  234. *
  235. * @param handle [IN] pointer to the channel handle
  236. *
  237. * @retval ACL_SUCCESS The function is successfully executed.
  238. * @retval OtherValues Failure
  239. *
  240. * @see acltdtCreateChannel | acltdtStopChannel
  241. */
  242. ACL_FUNC_VISIBILITY aclError acltdtDestroyChannel(acltdtChannelHandle *handle);
  243. /**
  244. * @ingroup AscendCL
  245. * @brief Send tensor to device
  246. *
  247. * @param handle [IN] pointer to the channel handle
  248. * @param dataset [IN] pointer to the dataset
  249. * @param timeout [IN] to be reserved, now it must be -1
  250. *
  251. * @retval ACL_SUCCESS The function is successfully executed.
  252. * @retval OtherValues Failure
  253. *
  254. * @see acltdtReceiveTensor
  255. */
  256. ACL_FUNC_VISIBILITY aclError acltdtSendTensor(const acltdtChannelHandle *handle, const acltdtDataset *dataset,
  257. int32_t timeout);
  258. /**
  259. * @ingroup AscendCL
  260. * @brief Receive tensor from device
  261. *
  262. * @param handle [IN] pointer to the channel handle
  263. * @param dataset [OUT] pointer to the dataset
  264. * @param timeout [IN] to be reserved, now it must be -1
  265. *
  266. * @retval ACL_SUCCESS The function is successfully executed.
  267. * @retval OtherValues Failure
  268. *
  269. * @see acltdtSendTensor
  270. */
  271. ACL_FUNC_VISIBILITY aclError acltdtReceiveTensor(const acltdtChannelHandle *handle, acltdtDataset *dataset,
  272. int32_t timeout);
  273. /**
  274. * @ingroup AscendCL
  275. * @brief query the size of the channel
  276. *
  277. * @param handle [IN] pointer to the channel handle
  278. * @param size [OUT] current size of this channel
  279. *
  280. * @retval ACL_SUCCESS The function is successfully executed.
  281. * @retval OtherValues Failure
  282. *
  283. */
  284. ACL_FUNC_VISIBILITY aclError acltdtQueryChannelSize(const acltdtChannelHandle *handle, size_t *size);
  285. #ifdef __cplusplus
  286. }
  287. #endif
  288. #endif // INC_EXTERNAL_ACL_ACL_TDT_H_

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