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.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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, 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 Stop the channel
  184. *
  185. * @param handle [IN] pointer to the channel handle
  186. *
  187. * @retval ACL_SUCCESS The function is successfully executed.
  188. * @retval OtherValues Failure
  189. *
  190. * @see acltdtCreateChannel | acltdtDestroyChannel
  191. */
  192. ACL_FUNC_VISIBILITY aclError acltdtStopChannel(acltdtChannelHandle *handle);
  193. /**
  194. * @ingroup AscendCL
  195. * @brief Create the channel
  196. *
  197. * @param deviceId [IN] the device id
  198. * @param name [IN] the channel's name
  199. *
  200. * @retval null for failed
  201. * @retval OtherValues success
  202. *
  203. * @see acltdtStopChannel | acltdtDestroyChannel
  204. */
  205. ACL_FUNC_VISIBILITY acltdtChannelHandle *acltdtCreateChannel(uint32_t deviceId, const char *name);
  206. /**
  207. * @ingroup AscendCL
  208. * @brief Destroy the channel
  209. *
  210. * @param handle [IN] pointer to the channel handle
  211. *
  212. * @retval ACL_SUCCESS The function is successfully executed.
  213. * @retval OtherValues Failure
  214. *
  215. * @see acltdtCreateChannel | acltdtStopChannel
  216. */
  217. ACL_FUNC_VISIBILITY aclError acltdtDestroyChannel(acltdtChannelHandle *handle);
  218. /**
  219. * @ingroup AscendCL
  220. * @brief Send tensor to device
  221. *
  222. * @param handle [IN] pointer to the channel handle
  223. * @param dataset [IN] pointer to the dataset
  224. * @param timeout [IN] to be reserved, now it must be -1
  225. *
  226. * @retval ACL_SUCCESS The function is successfully executed.
  227. * @retval OtherValues Failure
  228. *
  229. * @see acltdtReceiveTensor
  230. */
  231. ACL_FUNC_VISIBILITY aclError acltdtSendTensor(const acltdtChannelHandle *handle, const acltdtDataset *dataset,
  232. int32_t timeout);
  233. /**
  234. * @ingroup AscendCL
  235. * @brief Receive tensor from device
  236. *
  237. * @param handle [IN] pointer to the channel handle
  238. * @param dataset [OUT] pointer to the dataset
  239. * @param timeout [IN] to be reserved, now it must be -1
  240. *
  241. * @retval ACL_SUCCESS The function is successfully executed.
  242. * @retval OtherValues Failure
  243. *
  244. * @see acltdtSendTensor
  245. */
  246. ACL_FUNC_VISIBILITY aclError acltdtReceiveTensor(const acltdtChannelHandle *handle, acltdtDataset *dataset,
  247. int32_t timeout);
  248. #ifdef __cplusplus
  249. }
  250. #endif
  251. #endif // INC_EXTERNAL_ACL_ACL_TDT_H_

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