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

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