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_base.h 22 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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_BASE_H_
  17. #define INC_EXTERNAL_ACL_ACL_BASE_H_
  18. #include <stdint.h>
  19. #include <stddef.h>
  20. #include "error_codes/rt_error_codes.h"
  21. #include "error_codes/ge_error_codes.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #if defined(_MSC_VER)
  26. #ifdef FUNC_VISIBILITY
  27. #define ACL_FUNC_VISIBILITY _declspec(dllexport)
  28. #else
  29. #define ACL_FUNC_VISIBILITY
  30. #endif
  31. #else
  32. #ifdef FUNC_VISIBILITY
  33. #define ACL_FUNC_VISIBILITY __attribute__((visibility("default")))
  34. #else
  35. #define ACL_FUNC_VISIBILITY
  36. #endif
  37. #endif
  38. #ifdef __GNUC__
  39. #define ACL_DEPRECATED __attribute__((deprecated))
  40. #define ACL_DEPRECATED_MESSAGE(message) __attribute__((deprecated(message)))
  41. #elif defined(_MSC_VER)
  42. #define ACL_DEPRECATED __declspec(deprecated)
  43. #define ACL_DEPRECATED_MESSAGE(message) __declspec(deprecated(message))
  44. #else
  45. #define ACL_DEPRECATED
  46. #define ACL_DEPRECATED_MESSAGE(message)
  47. #endif
  48. typedef void *aclrtStream;
  49. typedef void *aclrtEvent;
  50. typedef void *aclrtContext;
  51. typedef int aclError;
  52. typedef uint16_t aclFloat16;
  53. typedef struct aclDataBuffer aclDataBuffer;
  54. typedef struct aclTensorDesc aclTensorDesc;
  55. static const int ACL_ERROR_NONE = 0;
  56. static const int ACL_SUCCESS = 0;
  57. static const int ACL_ERROR_INVALID_PARAM = 100000;
  58. static const int ACL_ERROR_UNINITIALIZE = 100001;
  59. static const int ACL_ERROR_REPEAT_INITIALIZE = 100002;
  60. static const int ACL_ERROR_INVALID_FILE = 100003;
  61. static const int ACL_ERROR_WRITE_FILE = 100004;
  62. static const int ACL_ERROR_INVALID_FILE_SIZE = 100005;
  63. static const int ACL_ERROR_PARSE_FILE = 100006;
  64. static const int ACL_ERROR_FILE_MISSING_ATTR = 100007;
  65. static const int ACL_ERROR_FILE_ATTR_INVALID = 100008;
  66. static const int ACL_ERROR_INVALID_DUMP_CONFIG = 100009;
  67. static const int ACL_ERROR_INVALID_PROFILING_CONFIG = 100010;
  68. static const int ACL_ERROR_INVALID_MODEL_ID = 100011;
  69. static const int ACL_ERROR_DESERIALIZE_MODEL = 100012;
  70. static const int ACL_ERROR_PARSE_MODEL = 100013;
  71. static const int ACL_ERROR_READ_MODEL_FAILURE = 100014;
  72. static const int ACL_ERROR_MODEL_SIZE_INVALID = 100015;
  73. static const int ACL_ERROR_MODEL_MISSING_ATTR = 100016;
  74. static const int ACL_ERROR_MODEL_INPUT_NOT_MATCH = 100017;
  75. static const int ACL_ERROR_MODEL_OUTPUT_NOT_MATCH = 100018;
  76. static const int ACL_ERROR_MODEL_NOT_DYNAMIC = 100019;
  77. static const int ACL_ERROR_OP_TYPE_NOT_MATCH = 100020;
  78. static const int ACL_ERROR_OP_INPUT_NOT_MATCH = 100021;
  79. static const int ACL_ERROR_OP_OUTPUT_NOT_MATCH = 100022;
  80. static const int ACL_ERROR_OP_ATTR_NOT_MATCH = 100023;
  81. static const int ACL_ERROR_OP_NOT_FOUND = 100024;
  82. static const int ACL_ERROR_OP_LOAD_FAILED = 100025;
  83. static const int ACL_ERROR_UNSUPPORTED_DATA_TYPE = 100026;
  84. static const int ACL_ERROR_FORMAT_NOT_MATCH = 100027;
  85. static const int ACL_ERROR_BIN_SELECTOR_NOT_REGISTERED = 100028;
  86. static const int ACL_ERROR_KERNEL_NOT_FOUND = 100029;
  87. static const int ACL_ERROR_BIN_SELECTOR_ALREADY_REGISTERED = 100030;
  88. static const int ACL_ERROR_KERNEL_ALREADY_REGISTERED = 100031;
  89. static const int ACL_ERROR_INVALID_QUEUE_ID = 100032;
  90. static const int ACL_ERROR_REPEAT_SUBSCRIBE = 100033;
  91. static const int ACL_ERROR_STREAM_NOT_SUBSCRIBE = 100034;
  92. static const int ACL_ERROR_THREAD_NOT_SUBSCRIBE = 100035;
  93. static const int ACL_ERROR_WAIT_CALLBACK_TIMEOUT = 100036;
  94. static const int ACL_ERROR_REPEAT_FINALIZE = 100037;
  95. static const int ACL_ERROR_NOT_STATIC_AIPP = 100038;
  96. static const int ACL_ERROR_COMPILING_STUB_MODE = 100039;
  97. static const int ACL_ERROR_GROUP_NOT_SET = 100040;
  98. static const int ACL_ERROR_GROUP_NOT_CREATE = 100041;
  99. static const int ACL_ERROR_PROF_ALREADY_RUN = 100042;
  100. static const int ACL_ERROR_PROF_NOT_RUN = 100043;
  101. static const int ACL_ERROR_DUMP_ALREADY_RUN = 100044;
  102. static const int ACL_ERROR_DUMP_NOT_RUN = 100045;
  103. static const int ACL_ERROR_PROF_REPEAT_SUBSCRIBE = 148046;
  104. static const int ACL_ERROR_PROF_API_CONFLICT = 148047;
  105. static const int ACL_ERROR_INVALID_MAX_OPQUEUE_NUM_CONFIG = 148048;
  106. static const int ACL_ERROR_INVALID_OPP_PATH = 148049;
  107. static const int ACL_ERROR_OP_UNSUPPORTED_DYNAMIC = 148050;
  108. static const int ACL_ERROR_RELATIVE_RESOURCE_NOT_CLEARED = 148051;
  109. static const int ACL_ERROR_BAD_ALLOC = 200000;
  110. static const int ACL_ERROR_API_NOT_SUPPORT = 200001;
  111. static const int ACL_ERROR_INVALID_DEVICE = 200002;
  112. static const int ACL_ERROR_MEMORY_ADDRESS_UNALIGNED = 200003;
  113. static const int ACL_ERROR_RESOURCE_NOT_MATCH = 200004;
  114. static const int ACL_ERROR_INVALID_RESOURCE_HANDLE = 200005;
  115. static const int ACL_ERROR_FEATURE_UNSUPPORTED = 200006;
  116. static const int ACL_ERROR_PROF_MODULES_UNSUPPORTED = 200007;
  117. static const int ACL_ERROR_STORAGE_OVER_LIMIT = 300000;
  118. static const int ACL_ERROR_INTERNAL_ERROR = 500000;
  119. static const int ACL_ERROR_FAILURE = 500001;
  120. static const int ACL_ERROR_GE_FAILURE = 500002;
  121. static const int ACL_ERROR_RT_FAILURE = 500003;
  122. static const int ACL_ERROR_DRV_FAILURE = 500004;
  123. static const int ACL_ERROR_PROFILING_FAILURE = 500005;
  124. #define ACL_TENSOR_SHAPE_RANGE_NUM 2
  125. #define ACL_TENSOR_VALUE_RANGE_NUM 2
  126. #define ACL_UNKNOWN_RANK 0xFFFFFFFFFFFFFFFE
  127. typedef enum {
  128. ACL_DT_UNDEFINED = -1,
  129. ACL_FLOAT = 0,
  130. ACL_FLOAT16 = 1,
  131. ACL_INT8 = 2,
  132. ACL_INT32 = 3,
  133. ACL_UINT8 = 4,
  134. ACL_INT16 = 6,
  135. ACL_UINT16 = 7,
  136. ACL_UINT32 = 8,
  137. ACL_INT64 = 9,
  138. ACL_UINT64 = 10,
  139. ACL_DOUBLE = 11,
  140. ACL_BOOL = 12,
  141. ACL_STRING = 13,
  142. ACL_COMPLEX64 = 16,
  143. ACL_COMPLEX128 = 17
  144. } aclDataType;
  145. typedef enum {
  146. ACL_FORMAT_UNDEFINED = -1,
  147. ACL_FORMAT_NCHW = 0,
  148. ACL_FORMAT_NHWC = 1,
  149. ACL_FORMAT_ND = 2,
  150. ACL_FORMAT_NC1HWC0 = 3,
  151. ACL_FORMAT_FRACTAL_Z = 4,
  152. ACL_FORMAT_NC1HWC0_C04 = 12,
  153. ACL_FORMAT_HWCN = 16,
  154. ACL_FORMAT_NDHWC = 27,
  155. ACL_FORMAT_FRACTAL_NZ = 29,
  156. ACL_FORMAT_NCDHW = 30,
  157. ACL_FORMAT_NDC1HWC0 = 32,
  158. ACL_FRACTAL_Z_3D = 33
  159. } aclFormat;
  160. typedef enum {
  161. ACL_DEBUG = 0,
  162. ACL_INFO = 1,
  163. ACL_WARNING = 2,
  164. ACL_ERROR = 3,
  165. } aclLogLevel;
  166. typedef enum { ACL_MEMTYPE_DEVICE = 0, ACL_MEMTYPE_HOST = 1, ACL_MEMTYPE_HOST_COMPILE_INDEPENDENT = 2 } aclMemType;
  167. /**
  168. * @ingroup AscendCL
  169. * @brief Converts data of type aclFloat16 to data of type float
  170. *
  171. * @param value [IN] Data to be converted
  172. *
  173. * @retval Transformed data
  174. */
  175. ACL_FUNC_VISIBILITY float aclFloat16ToFloat(aclFloat16 value);
  176. /**
  177. * @ingroup AscendCL
  178. * @brief Converts data of type float to data of type aclFloat16
  179. *
  180. * @param value [IN] Data to be converted
  181. *
  182. * @retval Transformed data
  183. */
  184. ACL_FUNC_VISIBILITY aclFloat16 aclFloatToFloat16(float value);
  185. /**
  186. * @ingroup AscendCL
  187. * @brief create data of aclDataBuffer
  188. *
  189. * @param data [IN] pointer to data
  190. * @li Need to be managed by the user,
  191. * call aclrtMalloc interface to apply for memory,
  192. * call aclrtFree interface to release memory
  193. *
  194. * @param size [IN] size of data in bytes
  195. *
  196. * @retval pointer to created instance. nullptr if run out of memory
  197. *
  198. * @see aclrtMalloc | aclrtFree
  199. */
  200. ACL_FUNC_VISIBILITY aclDataBuffer *aclCreateDataBuffer(void *data, size_t size);
  201. /**
  202. * @ingroup AscendCL
  203. * @brief destroy data of aclDataBuffer
  204. *
  205. * @par Function
  206. * Only the aclDataBuffer type data is destroyed here.
  207. * The memory of the data passed in when the aclDataDataBuffer interface
  208. * is called to create aclDataBuffer type data must be released by the user
  209. *
  210. * @param dataBuffer [IN] pointer to the aclDataBuffer
  211. *
  212. * @retval ACL_SUCCESS The function is successfully executed.
  213. * @retval OtherValues Failure
  214. *
  215. * @see aclCreateDataBuffer
  216. */
  217. ACL_FUNC_VISIBILITY aclError aclDestroyDataBuffer(const aclDataBuffer *dataBuffer);
  218. /**
  219. * @ingroup AscendCL
  220. * @brief update new data of aclDataBuffer
  221. *
  222. * @param dataBuffer [OUT] pointer to aclDataBuffer
  223. * @li The old data need to be released by the user, otherwise it may occur memory leak leakage
  224. * call aclGetDataBufferAddr interface to get old data address
  225. * call aclrtFree interface to release memory
  226. *
  227. * @param data [IN] pointer to new data
  228. * @li Need to be managed by the user,
  229. * call aclrtMalloc interface to apply for memory,
  230. * call aclrtFree interface to release memory
  231. *
  232. * @param size [IN] size of data in bytes
  233. *
  234. * @retval ACL_SUCCESS The function is successfully executed.
  235. * @retval OtherValues Failure
  236. *
  237. * @see aclrtMalloc | aclrtFree | aclGetDataBufferAddr
  238. */
  239. ACL_FUNC_VISIBILITY aclError aclUpdateDataBuffer(aclDataBuffer *dataBuffer, void *data, size_t size);
  240. /**
  241. * @ingroup AscendCL
  242. * @brief get data address from aclDataBuffer
  243. *
  244. * @param dataBuffer [IN] pointer to the data of aclDataBuffer
  245. *
  246. * @retval data address
  247. */
  248. ACL_FUNC_VISIBILITY void *aclGetDataBufferAddr(const aclDataBuffer *dataBuffer);
  249. /**
  250. * @ingroup AscendCL
  251. * @brief get data size of aclDataBuffer
  252. *
  253. * @param dataBuffer [IN] pointer to the data of aclDataBuffer
  254. *
  255. * @retval data size
  256. */
  257. ACL_DEPRECATED_MESSAGE("aclGetDataBufferSize is deprecated, use aclGetDataBufferSizeV2 instead")
  258. ACL_FUNC_VISIBILITY uint32_t aclGetDataBufferSize(const aclDataBuffer *dataBuffer);
  259. /**
  260. * @ingroup AscendCL
  261. * @brief get data size of aclDataBuffer to replace aclGetDataBufferSize
  262. *
  263. * @param dataBuffer [IN] pointer to the data of aclDataBuffer
  264. *
  265. * @retval data size
  266. */
  267. ACL_FUNC_VISIBILITY size_t aclGetDataBufferSizeV2(const aclDataBuffer *dataBuffer);
  268. /**
  269. * @ingroup AscendCL
  270. * @brief get size of aclDataType
  271. *
  272. * @param dataType [IN] aclDataType data the size to get
  273. *
  274. * @retval size of the aclDataType
  275. */
  276. ACL_FUNC_VISIBILITY size_t aclDataTypeSize(aclDataType dataType);
  277. // interfaces of tensor desc
  278. /**
  279. * @ingroup AscendCL
  280. * @brief create data aclTensorDesc
  281. *
  282. * @param dataType [IN] Data types described by tensor
  283. * @param numDims [IN] the number of dimensions of the shape
  284. * @param dims [IN] the size of the specified dimension
  285. * @param format [IN] tensor format
  286. *
  287. * @retval aclTensorDesc pointer.
  288. * @retval nullptr if param is invalid or run out of memory
  289. */
  290. ACL_FUNC_VISIBILITY aclTensorDesc *aclCreateTensorDesc(aclDataType dataType, int numDims, const int64_t *dims,
  291. aclFormat format);
  292. /**
  293. * @ingroup AscendCL
  294. * @brief destroy data aclTensorDesc
  295. *
  296. * @param desc [IN] pointer to the data of aclTensorDesc to destroy
  297. */
  298. ACL_FUNC_VISIBILITY void aclDestroyTensorDesc(const aclTensorDesc *desc);
  299. /**
  300. * @ingroup AscendCL
  301. * @brief set tensor shape range for aclTensorDesc
  302. *
  303. * @param desc [OUT] pointer to the data of aclTensorDesc
  304. * @param dimsCount [IN] the number of dimensions of the shape
  305. * @param dimsRange [IN] the range of dimensions of the shape
  306. *
  307. * @retval ACL_SUCCESS The function is successfully executed.
  308. * @retval OtherValues Failure
  309. */
  310. ACL_FUNC_VISIBILITY aclError aclSetTensorShapeRange(aclTensorDesc *desc, size_t dimsCount,
  311. int64_t dimsRange[][ACL_TENSOR_SHAPE_RANGE_NUM]);
  312. /**
  313. * @ingroup AscendCL
  314. * @brief set value range for aclTensorDesc
  315. *
  316. * @param desc [OUT] pointer to the data of aclTensorDesc
  317. * @param valueCount [IN] the number of value
  318. * @param valueRange [IN] the range of value
  319. *
  320. * @retval ACL_SUCCESS The function is successfully executed.
  321. * @retval OtherValues Failure
  322. */
  323. ACL_FUNC_VISIBILITY aclError aclSetTensorValueRange(aclTensorDesc *desc, size_t valueCount,
  324. int64_t valueRange[][ACL_TENSOR_VALUE_RANGE_NUM]);
  325. /**
  326. * @ingroup AscendCL
  327. * @brief get data type specified by the tensor description
  328. *
  329. * @param desc [IN] pointer to the instance of aclTensorDesc
  330. *
  331. * @retval data type specified by the tensor description.
  332. * @retval ACL_DT_UNDEFINED if description is null
  333. */
  334. ACL_FUNC_VISIBILITY aclDataType aclGetTensorDescType(const aclTensorDesc *desc);
  335. /**
  336. * @ingroup AscendCL
  337. * @brief get data format specified by the tensor description
  338. *
  339. * @param desc [IN] pointer to the instance of aclTensorDesc
  340. *
  341. * @retval data format specified by the tensor description.
  342. * @retval ACL_FORMAT_UNDEFINED if description is null
  343. */
  344. ACL_FUNC_VISIBILITY aclFormat aclGetTensorDescFormat(const aclTensorDesc *desc);
  345. /**
  346. * @ingroup AscendCL
  347. * @brief get tensor size specified by the tensor description
  348. *
  349. * @param desc [IN] pointer to the instance of aclTensorDesc
  350. *
  351. * @retval data size specified by the tensor description.
  352. * @retval 0 if description is null
  353. */
  354. ACL_FUNC_VISIBILITY size_t aclGetTensorDescSize(const aclTensorDesc *desc);
  355. /**
  356. * @ingroup AscendCL
  357. * @brief get element count specified by the tensor description
  358. *
  359. * @param desc [IN] pointer to the instance of aclTensorDesc
  360. *
  361. * @retval element count specified by the tensor description.
  362. * @retval 0 if description is null
  363. */
  364. ACL_FUNC_VISIBILITY size_t aclGetTensorDescElementCount(const aclTensorDesc *desc);
  365. /**
  366. * @ingroup AscendCL
  367. * @brief get number of dims specified by the tensor description
  368. *
  369. * @param desc [IN] pointer to the instance of aclTensorDesc
  370. *
  371. * @retval number of dims specified by the tensor description.
  372. * @retval 0 if description is null
  373. * @retval ACL_UNKNOWN_RANK if the tensor dim is -2
  374. */
  375. ACL_FUNC_VISIBILITY size_t aclGetTensorDescNumDims(const aclTensorDesc *desc);
  376. /**
  377. * @ingroup AscendCL
  378. * @brief Get the size of the specified dim in the tensor description
  379. *
  380. * @param desc [IN] pointer to the instance of aclTensorDesc
  381. * @param index [IN] index of dims, start from 0.
  382. *
  383. * @retval dim specified by the tensor description and index.
  384. * @retval -1 if description or index is invalid
  385. */
  386. ACL_DEPRECATED_MESSAGE("aclGetTensorDescDim is deprecated, use aclGetTensorDescDimV2 instead")
  387. ACL_FUNC_VISIBILITY int64_t aclGetTensorDescDim(const aclTensorDesc *desc, size_t index);
  388. /**
  389. * @ingroup AscendCL
  390. * @brief Get the size of the specified dim in the tensor description
  391. *
  392. * @param desc [IN] pointer to the instance of aclTensorDesc
  393. * @param index [IN] index of dims, start from 0.
  394. * @param dimSize [OUT] size of the specified dim.
  395. *
  396. * @retval ACL_SUCCESS The function is successfully executed.
  397. * @retval OtherValues Failure
  398. */
  399. ACL_FUNC_VISIBILITY aclError aclGetTensorDescDimV2(const aclTensorDesc *desc, size_t index, int64_t *dimSize);
  400. /**
  401. * @ingroup AscendCL
  402. * @brief Get the range of the specified dim in the tensor description
  403. *
  404. * @param desc [IN] pointer to the instance of aclTensorDesc
  405. * @param index [IN] index of dims, start from 0.
  406. * @param dimRangeNum [IN] number of dimRange.
  407. * @param dimRange [OUT] range of the specified dim.
  408. *
  409. * @retval ACL_SUCCESS The function is successfully executed.
  410. * @retval OtherValues Failure
  411. */
  412. ACL_FUNC_VISIBILITY aclError aclGetTensorDescDimRange(const aclTensorDesc *desc, size_t index, size_t dimRangeNum,
  413. int64_t *dimRange);
  414. /**
  415. * @ingroup AscendCL
  416. * @brief set tensor description name
  417. *
  418. * @param desc [OUT] pointer to the instance of aclTensorDesc
  419. * @param name [IN] tensor description name
  420. */
  421. ACL_FUNC_VISIBILITY void aclSetTensorDescName(aclTensorDesc *desc, const char *name);
  422. /**
  423. * @ingroup AscendCL
  424. * @brief get tensor description name
  425. *
  426. * @param desc [IN] pointer to the instance of aclTensorDesc
  427. *
  428. * @retval tensor description name.
  429. * @retval empty string if description is null
  430. */
  431. ACL_FUNC_VISIBILITY const char *aclGetTensorDescName(aclTensorDesc *desc);
  432. /**
  433. * @ingroup AscendCL
  434. * @brief Convert the format in the source aclTensorDesc according to
  435. * the specified dstFormat to generate a new target aclTensorDesc.
  436. * The format in the source aclTensorDesc remains unchanged.
  437. *
  438. * @param srcDesc [IN] pointer to the source tensor desc
  439. * @param dstFormat [IN] destination format
  440. * @param dstDesc [OUT] pointer to the pointer to the destination tensor desc
  441. *
  442. * @retval ACL_SUCCESS The function is successfully executed.
  443. * @retval OtherValues Failure
  444. */
  445. ACL_FUNC_VISIBILITY aclError aclTransTensorDescFormat(const aclTensorDesc *srcDesc, aclFormat dstFormat,
  446. aclTensorDesc **dstDesc);
  447. /**
  448. * @ingroup AscendCL
  449. * @brief Set the storage format specified by the tensor description
  450. *
  451. * @param desc [OUT] pointer to the instance of aclTensorDesc
  452. * @param format [IN] the storage format
  453. *
  454. * @retval ACL_SUCCESS The function is successfully executed.
  455. * @retval OtherValues Failure
  456. */
  457. ACL_DEPRECATED_MESSAGE("aclSetTensorStorageFormat is deprecated, use aclSetTensorFormat instead")
  458. ACL_FUNC_VISIBILITY aclError aclSetTensorStorageFormat(aclTensorDesc *desc, aclFormat format);
  459. /**
  460. * @ingroup AscendCL
  461. * @brief Set the storage shape specified by the tensor description
  462. *
  463. * @param desc [OUT] pointer to the instance of aclTensorDesc
  464. * @param numDims [IN] the number of dimensions of the shape
  465. * @param dims [IN] the size of the specified dimension
  466. *
  467. * @retval ACL_SUCCESS The function is successfully executed.
  468. * @retval OtherValues Failure
  469. */
  470. ACL_DEPRECATED_MESSAGE("aclSetTensorStorageShape is deprecated, use aclSetTensorShape instead")
  471. ACL_FUNC_VISIBILITY aclError aclSetTensorStorageShape(aclTensorDesc *desc, int numDims, const int64_t *dims);
  472. /**
  473. * @ingroup AscendCL
  474. * @brief Set the format specified by the tensor description
  475. *
  476. * @param desc [OUT] pointer to the instance of aclTensorDesc
  477. * @param format [IN] the storage format
  478. *
  479. * @retval ACL_SUCCESS The function is successfully executed.
  480. * @retval OtherValues Failure
  481. */
  482. ACL_FUNC_VISIBILITY aclError aclSetTensorFormat(aclTensorDesc *desc, aclFormat format);
  483. /**
  484. * @ingroup AscendCL
  485. * @brief Set the shape specified by the tensor description
  486. *
  487. * @param desc [OUT] pointer to the instance of aclTensorDesc
  488. * @param numDims [IN] the number of dimensions of the shape
  489. * @param dims [IN] the size of the specified dimension
  490. *
  491. * @retval ACL_SUCCESS The function is successfully executed.
  492. * @retval OtherValues Failure
  493. */
  494. ACL_FUNC_VISIBILITY aclError aclSetTensorShape(aclTensorDesc *desc, int numDims, const int64_t *dims);
  495. /**
  496. * @ingroup AscendCL
  497. * @brief Set the original format specified by the tensor description
  498. *
  499. * @param desc [OUT] pointer to the instance of aclTensorDesc
  500. * @param format [IN] the storage format
  501. *
  502. * @retval ACL_SUCCESS The function is successfully executed.
  503. * @retval OtherValues Failure
  504. */
  505. ACL_FUNC_VISIBILITY aclError aclSetTensorOriginFormat(aclTensorDesc *desc, aclFormat format);
  506. /**
  507. * @ingroup AscendCL
  508. * @brief Set the original shape specified by the tensor description
  509. *
  510. * @param desc [OUT] pointer to the instance of aclTensorDesc
  511. * @param numDims [IN] the number of dimensions of the shape
  512. * @param dims [IN] the size of the specified dimension
  513. *
  514. * @retval ACL_SUCCESS The function is successfully executed.
  515. * @retval OtherValues Failure
  516. */
  517. ACL_FUNC_VISIBILITY aclError aclSetTensorOriginShape(aclTensorDesc *desc, int numDims, const int64_t *dims);
  518. /**
  519. * @ingroup AscendCL
  520. * @brief get op description info
  521. *
  522. * @param desc [IN] pointer to tensor description
  523. * @param index [IN] index of tensor
  524. *
  525. * @retval null for failed.
  526. * @retval OtherValues success.
  527. */
  528. ACL_FUNC_VISIBILITY aclTensorDesc *aclGetTensorDescByIndex(aclTensorDesc *desc, size_t index);
  529. /**
  530. * @ingroup AscendCL
  531. * @brief get address of tensor
  532. *
  533. * @param desc [IN] pointer to tensor description
  534. *
  535. * @retval null for failed
  536. * @retval OtherValues success
  537. */
  538. ACL_FUNC_VISIBILITY void *aclGetTensorDescAddress(const aclTensorDesc *desc);
  539. /**
  540. * @ingroup AscendCL
  541. * @brief Set the dynamic input name specified by the tensor description
  542. *
  543. * @param desc [OUT] pointer to the instance of aclTensorDesc
  544. * @param dynamicInputName [IN] pointer to the dynamic input name
  545. *
  546. * @retval ACL_SUCCESS The function is successfully executed.
  547. * @retval OtherValues Failure
  548. */
  549. ACL_FUNC_VISIBILITY aclError aclSetTensorDynamicInput(aclTensorDesc *desc, const char *dynamicInputName);
  550. /**
  551. * @ingroup AscendCL
  552. * @brief Set const data specified by the tensor description
  553. *
  554. * @param desc [OUT] pointer to the instance of aclTensorDesc
  555. * @param dataBuffer [IN] pointer to the const databuffer
  556. * @param length [IN] the length of const databuffer
  557. *
  558. * @retval ACL_SUCCESS The function is successfully executed.
  559. * @retval OtherValues Failure
  560. */
  561. ACL_FUNC_VISIBILITY aclError aclSetTensorConst(aclTensorDesc *desc, void *dataBuffer, size_t length);
  562. /**
  563. * @ingroup AscendCL
  564. * @brief Set tensor memory type specified by the tensor description
  565. *
  566. * @param desc [OUT] pointer to the instance of aclTensorDesc
  567. * @param memType [IN] ACL_MEMTYPE_DEVICE means device, ACL_MEMTYPE_HOST or
  568. * ACL_MEMTYPE_HOST_COMPILE_INDEPENDENT means host
  569. *
  570. * @retval ACL_SUCCESS The function is successfully executed.
  571. * @retval OtherValues Failure
  572. */
  573. ACL_FUNC_VISIBILITY aclError aclSetTensorPlaceMent(aclTensorDesc *desc, aclMemType memType);
  574. /**
  575. * @ingroup AscendCL
  576. * @brief an interface for users to output APP logs
  577. *
  578. * @param logLevel [IN] the level of current log
  579. * @param func [IN] the function where the log is located
  580. * @param file [IN] the file where the log is located
  581. * @param line [IN] Number of source lines where the log is located
  582. * @param fmt [IN] the format of current log
  583. * @param ... [IN] the value of current log
  584. */
  585. ACL_FUNC_VISIBILITY void aclAppLog(aclLogLevel logLevel, const char *func, const char *file, uint32_t line,
  586. const char *fmt, ...);
  587. /**
  588. * @ingroup AscendCL
  589. * @brief get soc name
  590. *
  591. * @retval null for failed
  592. * @retval OtherValues success
  593. */
  594. ACL_FUNC_VISIBILITY const char *aclrtGetSocName();
  595. #define ACL_APP_LOG(level, fmt, ...) aclAppLog(level, __FUNCTION__, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
  596. #ifdef __cplusplus
  597. }
  598. #endif
  599. #endif // INC_EXTERNAL_ACL_ACL_BASE_H_

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