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 21 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
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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_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_BAD_ALLOC = 200000;
  107. static const int ACL_ERROR_API_NOT_SUPPORT = 200001;
  108. static const int ACL_ERROR_INVALID_DEVICE = 200002;
  109. static const int ACL_ERROR_MEMORY_ADDRESS_UNALIGNED = 200003;
  110. static const int ACL_ERROR_RESOURCE_NOT_MATCH = 200004;
  111. static const int ACL_ERROR_INVALID_RESOURCE_HANDLE = 200005;
  112. static const int ACL_ERROR_FEATURE_UNSUPPORTED = 200006;
  113. static const int ACL_ERROR_PROF_MODULES_UNSUPPORTED = 200007;
  114. static const int ACL_ERROR_STORAGE_OVER_LIMIT = 300000;
  115. static const int ACL_ERROR_INTERNAL_ERROR = 500000;
  116. static const int ACL_ERROR_FAILURE = 500001;
  117. static const int ACL_ERROR_GE_FAILURE = 500002;
  118. static const int ACL_ERROR_RT_FAILURE = 500003;
  119. static const int ACL_ERROR_DRV_FAILURE = 500004;
  120. static const int ACL_ERROR_PROFILING_FAILURE = 500005;
  121. #define ACL_TENSOR_SHAPE_RANGE_NUM 2
  122. #define ACL_UNKNOWN_RANK 0xFFFFFFFFFFFFFFFE
  123. typedef enum {
  124. ACL_DT_UNDEFINED = -1,
  125. ACL_FLOAT = 0,
  126. ACL_FLOAT16 = 1,
  127. ACL_INT8 = 2,
  128. ACL_INT32 = 3,
  129. ACL_UINT8 = 4,
  130. ACL_INT16 = 6,
  131. ACL_UINT16 = 7,
  132. ACL_UINT32 = 8,
  133. ACL_INT64 = 9,
  134. ACL_UINT64 = 10,
  135. ACL_DOUBLE = 11,
  136. ACL_BOOL = 12,
  137. ACL_STRING = 13,
  138. } aclDataType;
  139. typedef enum {
  140. ACL_FORMAT_UNDEFINED = -1,
  141. ACL_FORMAT_NCHW = 0,
  142. ACL_FORMAT_NHWC = 1,
  143. ACL_FORMAT_ND = 2,
  144. ACL_FORMAT_NC1HWC0 = 3,
  145. ACL_FORMAT_FRACTAL_Z = 4,
  146. ACL_FORMAT_NC1HWC0_C04 = 12,
  147. ACL_FORMAT_NDHWC = 27,
  148. ACL_FORMAT_FRACTAL_NZ = 29,
  149. ACL_FORMAT_NCDHW = 30,
  150. ACL_FORMAT_NDC1HWC0 = 32,
  151. ACL_FRACTAL_Z_3D = 33
  152. } aclFormat;
  153. typedef enum {
  154. ACL_DEBUG = 0,
  155. ACL_INFO = 1,
  156. ACL_WARNING = 2,
  157. ACL_ERROR = 3,
  158. } aclLogLevel;
  159. /**
  160. * @ingroup AscendCL
  161. * @brief Converts data of type aclFloat16 to data of type float
  162. *
  163. * @param value [IN] Data to be converted
  164. *
  165. * @retval Transformed data
  166. */
  167. ACL_FUNC_VISIBILITY float aclFloat16ToFloat(aclFloat16 value);
  168. /**
  169. * @ingroup AscendCL
  170. * @brief Converts data of type float to data of type aclFloat16
  171. *
  172. * @param value [IN] Data to be converted
  173. *
  174. * @retval Transformed data
  175. */
  176. ACL_FUNC_VISIBILITY aclFloat16 aclFloatToFloat16(float value);
  177. /**
  178. * @ingroup AscendCL
  179. * @brief create data of aclDataBuffer
  180. *
  181. * @param data [IN] pointer to data
  182. * @li Need to be managed by the user,
  183. * call aclrtMalloc interface to apply for memory,
  184. * call aclrtFree interface to release memory
  185. *
  186. * @param size [IN] size of data in bytes
  187. *
  188. * @retval pointer to created instance. nullptr if run out of memory
  189. *
  190. * @see aclrtMalloc | aclrtFree
  191. */
  192. ACL_FUNC_VISIBILITY aclDataBuffer *aclCreateDataBuffer(void *data, size_t size);
  193. /**
  194. * @ingroup AscendCL
  195. * @brief destroy data of aclDataBuffer
  196. *
  197. * @par Function
  198. * Only the aclDataBuffer type data is destroyed here.
  199. * The memory of the data passed in when the aclDataDataBuffer interface
  200. * is called to create aclDataBuffer type data must be released by the user
  201. *
  202. * @param dataBuffer [IN] pointer to the aclDataBuffer
  203. *
  204. * @retval ACL_SUCCESS The function is successfully executed.
  205. * @retval OtherValues Failure
  206. *
  207. * @see aclCreateDataBuffer
  208. */
  209. ACL_FUNC_VISIBILITY aclError aclDestroyDataBuffer(const aclDataBuffer *dataBuffer);
  210. /**
  211. * @ingroup AscendCL
  212. * @brief update new data of aclDataBuffer
  213. *
  214. * @param dataBuffer [OUT] pointer to aclDataBuffer
  215. * @li The old data need to be released by the user, otherwise it may occur memory leak leakage
  216. * call aclGetDataBufferAddr interface to get old data address
  217. * call aclrtFree interface to release memory
  218. *
  219. * @param data [IN] pointer to new data
  220. * @li Need to be managed by the user,
  221. * call aclrtMalloc interface to apply for memory,
  222. * call aclrtFree interface to release memory
  223. *
  224. * @param size [IN] size of data in bytes
  225. *
  226. * @retval ACL_SUCCESS The function is successfully executed.
  227. * @retval OtherValues Failure
  228. *
  229. * @see aclrtMalloc | aclrtFree | aclGetDataBufferAddr
  230. */
  231. ACL_FUNC_VISIBILITY aclError aclUpdateDataBuffer(aclDataBuffer *dataBuffer, void *data, size_t size);
  232. /**
  233. * @ingroup AscendCL
  234. * @brief get data address from aclDataBuffer
  235. *
  236. * @param dataBuffer [IN] pointer to the data of aclDataBuffer
  237. *
  238. * @retval data address
  239. */
  240. ACL_FUNC_VISIBILITY void *aclGetDataBufferAddr(const aclDataBuffer *dataBuffer);
  241. /**
  242. * @ingroup AscendCL
  243. * @brief get data size of aclDataBuffer
  244. *
  245. * @param dataBuffer [IN] pointer to the data of aclDataBuffer
  246. *
  247. * @retval data size
  248. */
  249. ACL_DEPRECATED_MESSAGE("aclGetDataBufferSize is deprecated, use aclGetDataBufferSizeV2 instead")
  250. ACL_FUNC_VISIBILITY uint32_t aclGetDataBufferSize(const aclDataBuffer *dataBuffer);
  251. /**
  252. * @ingroup AscendCL
  253. * @brief get data size of aclDataBuffer to replace aclGetDataBufferSize
  254. *
  255. * @param dataBuffer [IN] pointer to the data of aclDataBuffer
  256. *
  257. * @retval data size
  258. */
  259. ACL_FUNC_VISIBILITY size_t aclGetDataBufferSizeV2(const aclDataBuffer *dataBuffer);
  260. /**
  261. * @ingroup AscendCL
  262. * @brief get size of aclDataType
  263. *
  264. * @param dataType [IN] aclDataType data the size to get
  265. *
  266. * @retval size of the aclDataType
  267. */
  268. ACL_FUNC_VISIBILITY size_t aclDataTypeSize(aclDataType dataType);
  269. // interfaces of tensor desc
  270. /**
  271. * @ingroup AscendCL
  272. * @brief create data aclTensorDesc
  273. *
  274. * @param dataType [IN] Data types described by tensor
  275. * @param numDims [IN] the number of dimensions of the shape
  276. * @param dims [IN] the size of the specified dimension
  277. * @param format [IN] tensor format
  278. *
  279. * @retval aclTensorDesc pointer.
  280. * @retval nullptr if param is invalid or run out of memory
  281. */
  282. ACL_FUNC_VISIBILITY aclTensorDesc *aclCreateTensorDesc(aclDataType dataType, int numDims, const int64_t *dims,
  283. aclFormat format);
  284. /**
  285. * @ingroup AscendCL
  286. * @brief destroy data aclTensorDesc
  287. *
  288. * @param desc [IN] pointer to the data of aclTensorDesc to destroy
  289. */
  290. ACL_FUNC_VISIBILITY void aclDestroyTensorDesc(const aclTensorDesc *desc);
  291. /**
  292. * @ingroup AscendCL
  293. * @brief set tensor shape range for aclTensorDesc
  294. *
  295. * @param desc [OUT] pointer to the data of aclTensorDesc
  296. * @param dimsCount [IN] the number of dimensions of the shape
  297. * @param dimsRange [IN] the range of dimensions of the shape
  298. *
  299. * @retval ACL_SUCCESS The function is successfully executed.
  300. * @retval OtherValues Failure
  301. */
  302. ACL_FUNC_VISIBILITY aclError aclSetTensorShapeRange(aclTensorDesc *desc, size_t dimsCount,
  303. int64_t dimsRange[][ACL_TENSOR_SHAPE_RANGE_NUM]);
  304. /**
  305. * @ingroup AscendCL
  306. * @brief get data type specified by the tensor description
  307. *
  308. * @param desc [IN] pointer to the instance of aclTensorDesc
  309. *
  310. * @retval data type specified by the tensor description.
  311. * @retval ACL_DT_UNDEFINED if description is null
  312. */
  313. ACL_FUNC_VISIBILITY aclDataType aclGetTensorDescType(const aclTensorDesc *desc);
  314. /**
  315. * @ingroup AscendCL
  316. * @brief get data format specified by the tensor description
  317. *
  318. * @param desc [IN] pointer to the instance of aclTensorDesc
  319. *
  320. * @retval data format specified by the tensor description.
  321. * @retval ACL_FORMAT_UNDEFINED if description is null
  322. */
  323. ACL_FUNC_VISIBILITY aclFormat aclGetTensorDescFormat(const aclTensorDesc *desc);
  324. /**
  325. * @ingroup AscendCL
  326. * @brief get tensor size specified by the tensor description
  327. *
  328. * @param desc [IN] pointer to the instance of aclTensorDesc
  329. *
  330. * @retval data size specified by the tensor description.
  331. * @retval 0 if description is null
  332. */
  333. ACL_FUNC_VISIBILITY size_t aclGetTensorDescSize(const aclTensorDesc *desc);
  334. /**
  335. * @ingroup AscendCL
  336. * @brief get element count specified by the tensor description
  337. *
  338. * @param desc [IN] pointer to the instance of aclTensorDesc
  339. *
  340. * @retval element count specified by the tensor description.
  341. * @retval 0 if description is null
  342. */
  343. ACL_FUNC_VISIBILITY size_t aclGetTensorDescElementCount(const aclTensorDesc *desc);
  344. /**
  345. * @ingroup AscendCL
  346. * @brief get number of dims specified by the tensor description
  347. *
  348. * @param desc [IN] pointer to the instance of aclTensorDesc
  349. *
  350. * @retval number of dims specified by the tensor description.
  351. * @retval 0 if description is null
  352. * @retval ACL_UNKNOWN_RANK if the tensor dim is -2
  353. */
  354. ACL_FUNC_VISIBILITY size_t aclGetTensorDescNumDims(const aclTensorDesc *desc);
  355. /**
  356. * @ingroup AscendCL
  357. * @brief Get the size of the specified dim in the tensor description
  358. *
  359. * @param desc [IN] pointer to the instance of aclTensorDesc
  360. * @param index [IN] index of dims, start from 0.
  361. *
  362. * @retval dim specified by the tensor description and index.
  363. * @retval -1 if description or index is invalid
  364. */
  365. ACL_DEPRECATED_MESSAGE("aclGetTensorDescDim is deprecated, use aclGetTensorDescDimV2 instead")
  366. ACL_FUNC_VISIBILITY int64_t aclGetTensorDescDim(const aclTensorDesc *desc, size_t index);
  367. /**
  368. * @ingroup AscendCL
  369. * @brief Get the size of the specified dim in the tensor description
  370. *
  371. * @param desc [IN] pointer to the instance of aclTensorDesc
  372. * @param index [IN] index of dims, start from 0.
  373. * @param dimSize [OUT] size of the specified dim.
  374. *
  375. * @retval ACL_SUCCESS The function is successfully executed.
  376. * @retval OtherValues Failure
  377. */
  378. ACL_FUNC_VISIBILITY aclError aclGetTensorDescDimV2(const aclTensorDesc *desc, size_t index, int64_t *dimSize);
  379. /**
  380. * @ingroup AscendCL
  381. * @brief Get the range of the specified dim in the tensor description
  382. *
  383. * @param desc [IN] pointer to the instance of aclTensorDesc
  384. * @param index [IN] index of dims, start from 0.
  385. * @param dimRangeNum [IN] number of dimRange.
  386. * @param dimRange [OUT] range of the specified dim.
  387. *
  388. * @retval ACL_SUCCESS The function is successfully executed.
  389. * @retval OtherValues Failure
  390. */
  391. ACL_FUNC_VISIBILITY aclError aclGetTensorDescDimRange(const aclTensorDesc *desc, size_t index, size_t dimRangeNum,
  392. int64_t *dimRange);
  393. /**
  394. * @ingroup AscendCL
  395. * @brief set tensor description name
  396. *
  397. * @param desc [OUT] pointer to the instance of aclTensorDesc
  398. * @param name [IN] tensor description name
  399. */
  400. ACL_FUNC_VISIBILITY void aclSetTensorDescName(aclTensorDesc *desc, const char *name);
  401. /**
  402. * @ingroup AscendCL
  403. * @brief get tensor description name
  404. *
  405. * @param desc [IN] pointer to the instance of aclTensorDesc
  406. *
  407. * @retval tensor description name.
  408. * @retval empty string if description is null
  409. */
  410. ACL_FUNC_VISIBILITY const char *aclGetTensorDescName(aclTensorDesc *desc);
  411. /**
  412. * @ingroup AscendCL
  413. * @brief Convert the format in the source aclTensorDesc according to
  414. * the specified dstFormat to generate a new target aclTensorDesc.
  415. * The format in the source aclTensorDesc remains unchanged.
  416. *
  417. * @param srcDesc [IN] pointer to the source tensor desc
  418. * @param dstFormat [IN] destination format
  419. * @param dstDesc [OUT] pointer to the pointer to the destination tensor desc
  420. *
  421. * @retval ACL_SUCCESS The function is successfully executed.
  422. * @retval OtherValues Failure
  423. */
  424. ACL_FUNC_VISIBILITY aclError aclTransTensorDescFormat(const aclTensorDesc *srcDesc, aclFormat dstFormat,
  425. aclTensorDesc **dstDesc);
  426. /**
  427. * @ingroup AscendCL
  428. * @brief Set the storage format specified by the tensor description
  429. *
  430. * @param desc [OUT] pointer to the instance of aclTensorDesc
  431. * @param format [IN] the storage format
  432. *
  433. * @retval ACL_SUCCESS The function is successfully executed.
  434. * @retval OtherValues Failure
  435. */
  436. ACL_DEPRECATED_MESSAGE("aclSetTensorStorageFormat is deprecated, use aclSetTensorFormat instead")
  437. ACL_FUNC_VISIBILITY aclError aclSetTensorStorageFormat(aclTensorDesc *desc, aclFormat format);
  438. /**
  439. * @ingroup AscendCL
  440. * @brief Set the storage shape specified by the tensor description
  441. *
  442. * @param desc [OUT] pointer to the instance of aclTensorDesc
  443. * @param numDims [IN] the number of dimensions of the shape
  444. * @param dims [IN] the size of the specified dimension
  445. *
  446. * @retval ACL_SUCCESS The function is successfully executed.
  447. * @retval OtherValues Failure
  448. */
  449. ACL_DEPRECATED_MESSAGE("aclSetTensorStorageShape is deprecated, use aclSetTensorShape instead")
  450. ACL_FUNC_VISIBILITY aclError aclSetTensorStorageShape(aclTensorDesc *desc, int numDims, const int64_t *dims);
  451. /**
  452. * @ingroup AscendCL
  453. * @brief Set the format specified by the tensor description
  454. *
  455. * @param desc [OUT] pointer to the instance of aclTensorDesc
  456. * @param format [IN] the storage format
  457. *
  458. * @retval ACL_SUCCESS The function is successfully executed.
  459. * @retval OtherValues Failure
  460. */
  461. ACL_FUNC_VISIBILITY aclError aclSetTensorFormat(aclTensorDesc *desc, aclFormat format);
  462. /**
  463. * @ingroup AscendCL
  464. * @brief Set the shape specified by the tensor description
  465. *
  466. * @param desc [OUT] pointer to the instance of aclTensorDesc
  467. * @param numDims [IN] the number of dimensions of the shape
  468. * @param dims [IN] the size of the specified dimension
  469. *
  470. * @retval ACL_SUCCESS The function is successfully executed.
  471. * @retval OtherValues Failure
  472. */
  473. ACL_FUNC_VISIBILITY aclError aclSetTensorShape(aclTensorDesc *desc, int numDims, const int64_t *dims);
  474. /**
  475. * @ingroup AscendCL
  476. * @brief Set the original format specified by the tensor description
  477. *
  478. * @param desc [OUT] pointer to the instance of aclTensorDesc
  479. * @param format [IN] the storage format
  480. *
  481. * @retval ACL_SUCCESS The function is successfully executed.
  482. * @retval OtherValues Failure
  483. */
  484. ACL_FUNC_VISIBILITY aclError aclSetTensorOriginFormat(aclTensorDesc *desc, aclFormat format);
  485. /**
  486. * @ingroup AscendCL
  487. * @brief Set the original shape specified by the tensor description
  488. *
  489. * @param desc [OUT] pointer to the instance of aclTensorDesc
  490. * @param numDims [IN] the number of dimensions of the shape
  491. * @param dims [IN] the size of the specified dimension
  492. *
  493. * @retval ACL_SUCCESS The function is successfully executed.
  494. * @retval OtherValues Failure
  495. */
  496. ACL_FUNC_VISIBILITY aclError aclSetTensorOriginShape(aclTensorDesc *desc, int numDims, const int64_t *dims);
  497. /**
  498. * @ingroup AscendCL
  499. * @brief get op description info
  500. *
  501. * @param desc [IN] pointer to tensor description
  502. * @param index [IN] index of tensor
  503. *
  504. * @retval null for failed.
  505. * @retval OtherValues success.
  506. */
  507. ACL_FUNC_VISIBILITY aclTensorDesc *aclGetTensorDescByIndex(aclTensorDesc *desc, size_t index);
  508. /**
  509. * @ingroup AscendCL
  510. * @brief get address of tensor
  511. *
  512. * @param desc [IN] pointer to tensor description
  513. *
  514. * @retval null for failed
  515. * @retval OtherValues success
  516. */
  517. ACL_FUNC_VISIBILITY void *aclGetTensorDescAddress(const aclTensorDesc *desc);
  518. /**
  519. * @ingroup AscendCL
  520. * @brief Set the dynamic input name specified by the tensor description
  521. *
  522. * @param desc [OUT] pointer to the instance of aclTensorDesc
  523. * @param dynamicInputName [IN] pointer to the dynamic input name
  524. *
  525. * @retval ACL_SUCCESS The function is successfully executed.
  526. * @retval OtherValues Failure
  527. */
  528. ACL_FUNC_VISIBILITY aclError aclSetTensorDynamicInput(aclTensorDesc *desc, const char *dynamicInputName);
  529. /**
  530. * @ingroup AscendCL
  531. * @brief Set const data specified by the tensor description
  532. *
  533. * @param desc [OUT] pointer to the instance of aclTensorDesc
  534. * @param dataBuffer [IN] pointer to the const databuffer
  535. * @param length [IN] the length of const databuffer
  536. *
  537. * @retval ACL_SUCCESS The function is successfully executed.
  538. * @retval OtherValues Failure
  539. */
  540. ACL_FUNC_VISIBILITY aclError aclSetTensorConst(aclTensorDesc *desc, void *dataBuffer, size_t length);
  541. /**
  542. * @ingroup AscendCL
  543. * @brief an interface for users to output APP logs
  544. *
  545. * @param logLevel [IN] the level of current log
  546. * @param func [IN] the function where the log is located
  547. * @param file [IN] the file where the log is located
  548. * @param line [IN] Number of source lines where the log is located
  549. * @param fmt [IN] the format of current log
  550. * @param ... [IN] the value of current log
  551. */
  552. ACL_FUNC_VISIBILITY void aclAppLog(aclLogLevel logLevel, const char *func, const char *file, uint32_t line,
  553. const char *fmt, ...);
  554. #define ACL_APP_LOG(level, fmt, ...) aclAppLog(level, __FUNCTION__, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
  555. #ifdef __cplusplus
  556. }
  557. #endif
  558. #endif // INC_EXTERNAL_ACL_ACL_BASE_H_

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