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_mdl.h 42 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
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
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  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_MODEL_H_
  17. #define INC_EXTERNAL_ACL_ACL_MODEL_H_
  18. #include <stddef.h>
  19. #include <stdint.h>
  20. #include "acl_base.h"
  21. #include "acl_rt.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #define ACL_MAX_DIM_CNT 128
  26. #define ACL_MAX_TENSOR_NAME_LEN 128
  27. #define ACL_MAX_BATCH_NUM 128
  28. #define ACL_MAX_HW_NUM 128
  29. #define ACL_MAX_SHAPE_COUNT 128
  30. #define ACL_INVALID_NODE_INDEX 0xFFFFFFFF
  31. #define ACL_MDL_LOAD_FROM_FILE 1
  32. #define ACL_MDL_LOAD_FROM_FILE_WITH_MEM 2
  33. #define ACL_MDL_LOAD_FROM_MEM 3
  34. #define ACL_MDL_LOAD_FROM_MEM_WITH_MEM 4
  35. #define ACL_MDL_LOAD_FROM_FILE_WITH_Q 5
  36. #define ACL_MDL_LOAD_FROM_MEM_WITH_Q 6
  37. #define ACL_DYNAMIC_TENSOR_NAME "ascend_mbatch_shape_data"
  38. #define ACL_DYNAMIC_AIPP_NAME "ascend_dynamic_aipp_data"
  39. typedef struct aclmdlDataset aclmdlDataset;
  40. typedef struct aclmdlDesc aclmdlDesc;
  41. typedef struct aclmdlAIPP aclmdlAIPP;
  42. typedef struct aclAippExtendInfo aclAippExtendInfo;
  43. typedef struct aclmdlConfigHandle aclmdlConfigHandle;
  44. typedef enum {
  45. ACL_YUV420SP_U8 = 1,
  46. ACL_XRGB8888_U8,
  47. ACL_RGB888_U8,
  48. ACL_YUV400_U8,
  49. ACL_NC1HWC0DI_FP16,
  50. ACL_NC1HWC0DI_S8,
  51. ACL_ARGB8888_U8,
  52. ACL_YUYV_U8,
  53. ACL_YUV422SP_U8,
  54. ACL_AYUV444_U8,
  55. ACL_RAW10,
  56. ACL_RAW12,
  57. ACL_RAW16,
  58. ACL_RAW24,
  59. ACL_AIPP_RESERVED = 0xffff,
  60. } aclAippInputFormat;
  61. typedef enum {
  62. ACL_MDL_PRIORITY_INT32 = 0,
  63. ACL_MDL_LOAD_TYPE_SIZET,
  64. ACL_MDL_PATH_PTR, /**< pointer to model load path with deep copy */
  65. ACL_MDL_MEM_ADDR_PTR, /**< pointer to model memory with shallow copy */
  66. ACL_MDL_MEM_SIZET,
  67. ACL_MDL_WEIGHT_ADDR_PTR, /**< pointer to weight memory of model with shallow copy */
  68. ACL_MDL_WEIGHT_SIZET,
  69. ACL_MDL_WORKSPACE_ADDR_PTR, /**< pointer to worksapce memory of model with shallow copy */
  70. ACL_MDL_WORKSPACE_SIZET,
  71. ACL_MDL_INPUTQ_NUM_SIZET,
  72. ACL_MDL_INPUTQ_ADDR_PTR, /**< pointer to inputQ with shallow copy */
  73. ACL_MDL_OUTPUTQ_NUM_SIZET,
  74. ACL_MDL_OUTPUTQ_ADDR_PTR /**< pointer to outputQ with shallow copy */
  75. } aclmdlConfigAttr;
  76. typedef enum {
  77. ACL_DATA_WITHOUT_AIPP = 0,
  78. ACL_DATA_WITH_STATIC_AIPP,
  79. ACL_DATA_WITH_DYNAMIC_AIPP,
  80. ACL_DYNAMIC_AIPP_NODE
  81. } aclmdlInputAippType;
  82. typedef struct aclmdlIODims {
  83. char name[ACL_MAX_TENSOR_NAME_LEN]; /**< tensor name */
  84. size_t dimCount; /**< dim array count */
  85. int64_t dims[ACL_MAX_DIM_CNT]; /**< dim data array */
  86. } aclmdlIODims;
  87. typedef struct aclAippDims {
  88. aclmdlIODims srcDims; /**< input dims before model transform */
  89. size_t srcSize; /**< input size before model transform */
  90. aclmdlIODims aippOutdims; /**< aipp output dims */
  91. size_t aippOutSize; /**< aipp output size */
  92. } aclAippDims;
  93. typedef struct aclmdlBatch {
  94. size_t batchCount; /**< batch array count */
  95. uint64_t batch[ACL_MAX_BATCH_NUM]; /**< batch data array */
  96. } aclmdlBatch;
  97. typedef struct aclmdlHW {
  98. size_t hwCount; /**< height&width array count */
  99. uint64_t hw[ACL_MAX_HW_NUM][2]; /**< height&width data array */
  100. } aclmdlHW;
  101. typedef struct aclAippInfo {
  102. aclAippInputFormat inputFormat;
  103. int32_t srcImageSizeW;
  104. int32_t srcImageSizeH;
  105. int8_t cropSwitch;
  106. int32_t loadStartPosW;
  107. int32_t loadStartPosH;
  108. int32_t cropSizeW;
  109. int32_t cropSizeH;
  110. int8_t resizeSwitch;
  111. int32_t resizeOutputW;
  112. int32_t resizeOutputH;
  113. int8_t paddingSwitch;
  114. int32_t leftPaddingSize;
  115. int32_t rightPaddingSize;
  116. int32_t topPaddingSize;
  117. int32_t bottomPaddingSize;
  118. int8_t cscSwitch;
  119. int8_t rbuvSwapSwitch;
  120. int8_t axSwapSwitch;
  121. int8_t singleLineMode;
  122. int32_t matrixR0C0;
  123. int32_t matrixR0C1;
  124. int32_t matrixR0C2;
  125. int32_t matrixR1C0;
  126. int32_t matrixR1C1;
  127. int32_t matrixR1C2;
  128. int32_t matrixR2C0;
  129. int32_t matrixR2C1;
  130. int32_t matrixR2C2;
  131. int32_t outputBias0;
  132. int32_t outputBias1;
  133. int32_t outputBias2;
  134. int32_t inputBias0;
  135. int32_t inputBias1;
  136. int32_t inputBias2;
  137. int32_t meanChn0;
  138. int32_t meanChn1;
  139. int32_t meanChn2;
  140. int32_t meanChn3;
  141. float minChn0;
  142. float minChn1;
  143. float minChn2;
  144. float minChn3;
  145. float varReciChn0;
  146. float varReciChn1;
  147. float varReciChn2;
  148. float varReciChn3;
  149. aclFormat srcFormat;
  150. aclDataType srcDatatype;
  151. size_t srcDimNum;
  152. size_t shapeCount;
  153. aclAippDims outDims[ACL_MAX_SHAPE_COUNT];
  154. aclAippExtendInfo *aippExtend; /**< reserved parameters, current version needs to be null */
  155. } aclAippInfo;
  156. /**
  157. * @ingroup AscendCL
  158. * @brief Create data of type aclmdlDesc
  159. *
  160. * @retval the aclmdlDesc pointer
  161. */
  162. ACL_FUNC_VISIBILITY aclmdlDesc *aclmdlCreateDesc();
  163. /**
  164. * @ingroup AscendCL
  165. * @brief destroy data of type aclmdlDesc
  166. *
  167. * @param modelDesc [IN] Pointer to almdldlDesc to be destroyed
  168. *
  169. * @retval ACL_SUCCESS The function is successfully executed.
  170. * @retval OtherValues Failure
  171. */
  172. ACL_FUNC_VISIBILITY aclError aclmdlDestroyDesc(aclmdlDesc *modelDesc);
  173. /**
  174. * @ingroup AscendCL
  175. * @brief Get aclmdlDesc data of the model according to the model ID
  176. *
  177. * @param modelDesc [OUT] aclmdlDesc pointer
  178. * @param modelId [IN] model id
  179. *
  180. * @retval ACL_SUCCESS The function is successfully executed.
  181. * @retval OtherValues Failure
  182. */
  183. ACL_FUNC_VISIBILITY aclError aclmdlGetDesc(aclmdlDesc *modelDesc, uint32_t modelId);
  184. /**
  185. * @ingroup AscendCL
  186. * @brief Get the number of the inputs of
  187. * the model according to data of aclmdlDesc
  188. *
  189. * @param modelDesc [IN] aclmdlDesc pointer
  190. *
  191. * @retval input size with aclmdlDesc
  192. */
  193. ACL_FUNC_VISIBILITY size_t aclmdlGetNumInputs(aclmdlDesc *modelDesc);
  194. /**
  195. * @ingroup AscendCL
  196. * @brief Get the number of the output of
  197. * the model according to data of aclmdlDesc
  198. *
  199. * @param modelDesc [IN] aclmdlDesc pointer
  200. *
  201. * @retval output size with aclmdlDesc
  202. */
  203. ACL_FUNC_VISIBILITY size_t aclmdlGetNumOutputs(aclmdlDesc *modelDesc);
  204. /**
  205. * @ingroup AscendCL
  206. * @brief Get the size of the specified input according to
  207. * the data of type aclmdlDesc
  208. *
  209. * @param modelDesc [IN] aclmdlDesc pointer
  210. * @param index [IN] the size of the number of inputs to be obtained,
  211. * the index value starts from 0
  212. *
  213. * @retval Specify the size of the input
  214. */
  215. ACL_FUNC_VISIBILITY size_t aclmdlGetInputSizeByIndex(aclmdlDesc *modelDesc, size_t index);
  216. /**
  217. * @ingroup AscendCL
  218. * @brief Get the size of the specified output according to
  219. * the data of type aclmdlDesc
  220. *
  221. * @param modelDesc [IN] aclmdlDesc pointer
  222. * @param index [IN] the size of the number of outputs to be obtained,
  223. * the index value starts from 0
  224. *
  225. * @retval Specify the size of the output
  226. */
  227. ACL_FUNC_VISIBILITY size_t aclmdlGetOutputSizeByIndex(aclmdlDesc *modelDesc, size_t index);
  228. /**
  229. * @ingroup AscendCL
  230. * @brief Create data of type aclmdlDataset
  231. *
  232. * @retval the aclmdlDataset pointer
  233. */
  234. ACL_FUNC_VISIBILITY aclmdlDataset *aclmdlCreateDataset();
  235. /**
  236. * @ingroup AscendCL
  237. * @brief destroy data of type aclmdlDataset
  238. *
  239. * @param dataset [IN] Pointer to aclmdlDataset to be destroyed
  240. *
  241. * @retval ACL_SUCCESS The function is successfully executed.
  242. * @retval OtherValues Failure
  243. */
  244. ACL_FUNC_VISIBILITY aclError aclmdlDestroyDataset(const aclmdlDataset *dataset);
  245. /**
  246. * @ingroup AscendCL
  247. * @brief Add aclDataBuffer to aclmdlDataset
  248. *
  249. * @param dataset [OUT] aclmdlDataset address of aclDataBuffer to be added
  250. * @param dataBuffer [IN] aclDataBuffer address to be added
  251. *
  252. * @retval ACL_SUCCESS The function is successfully executed.
  253. * @retval OtherValues Failure
  254. */
  255. ACL_FUNC_VISIBILITY aclError aclmdlAddDatasetBuffer(aclmdlDataset *dataset, aclDataBuffer *dataBuffer);
  256. /**
  257. * @ingroup AscendCL
  258. * @brief Get the number of aclDataBuffer in aclmdlDataset
  259. *
  260. * @param dataset [IN] aclmdlDataset poiter
  261. *
  262. * @retval the number of aclDataBuffer
  263. */
  264. ACL_FUNC_VISIBILITY size_t aclmdlGetDatasetNumBuffers(const aclmdlDataset *dataset);
  265. /**
  266. * @ingroup AscendCL
  267. * @brief Get the aclDataBuffer in aclmdlDataset by index
  268. *
  269. * @param dataset [IN] aclmdlDataset poiter
  270. * @param index [IN] the index of aclDataBuffer
  271. *
  272. * @retval Get successfully, return the address of aclDataBuffer
  273. * @retval Failure return NULL
  274. */
  275. ACL_FUNC_VISIBILITY aclDataBuffer *aclmdlGetDatasetBuffer(const aclmdlDataset *dataset, size_t index);
  276. /**
  277. * @ingroup AscendCL
  278. * @brief Load offline model data from files
  279. * and manage memory internally by the system
  280. *
  281. * @par Function
  282. * After the system finishes loading the model,
  283. * the model ID returned is used as a mark to identify the model
  284. * during subsequent operations
  285. *
  286. * @param modelPath [IN] Storage path for offline model files
  287. * @param modelId [OUT] Model ID generated after
  288. * the system finishes loading the model
  289. *
  290. * @retval ACL_SUCCESS The function is successfully executed.
  291. * @retval OtherValues Failure
  292. */
  293. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFile(const char *modelPath, uint32_t *modelId);
  294. /**
  295. * @ingroup AscendCL
  296. * @brief Load offline model data from memory and manage the memory of
  297. * model running internally by the system
  298. *
  299. * @par Function
  300. * After the system finishes loading the model,
  301. * the model ID returned is used as a mark to identify the model
  302. * during subsequent operations
  303. *
  304. * @param model [IN] Model data stored in memory
  305. * @param modelSize [IN] model data size
  306. * @param modelId [OUT] Model ID generated after
  307. * the system finishes loading the model
  308. *
  309. * @retval ACL_SUCCESS The function is successfully executed.
  310. * @retval OtherValues Failure
  311. */
  312. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMem(const void *model, size_t modelSize, uint32_t *modelId);
  313. /**
  314. * @ingroup AscendCL
  315. * @brief Load offline model data from a file,
  316. * and the user manages the memory of the model run by itself
  317. *
  318. * @par Function
  319. * After the system finishes loading the model,
  320. * the model ID returned is used as a mark to identify the model
  321. * during subsequent operations.
  322. * @param modelPath [IN] Storage path for offline model files
  323. * @param modelId [OUT] Model ID generated after finishes loading the model
  324. * @param workPtr [IN] A pointer to the working memory
  325. * required by the model on the Device,can be null
  326. * @param workSize [IN] The amount of working memory required by the model
  327. * @param weightPtr [IN] Pointer to model weight memory on Device
  328. * @param weightSize [IN] The amount of weight memory required by the model
  329. *
  330. * @retval ACL_SUCCESS The function is successfully executed.
  331. * @retval OtherValues Failure
  332. */
  333. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFileWithMem(const char *modelPath, uint32_t *modelId, void *workPtr,
  334. size_t workSize, void *weightPtr, size_t weightSize);
  335. /**
  336. * @ingroup AscendCL
  337. * @brief Load offline model data from memory,
  338. * and the user can manage the memory of model running
  339. *
  340. * @par Function
  341. * After the system finishes loading the model,
  342. * the model ID returned is used as a mark to identify the model
  343. * during subsequent operations
  344. * @param model [IN] Model data stored in memory
  345. * @param modelSize [IN] model data size
  346. * @param modelId [OUT] Model ID generated after finishes loading the model
  347. * @param workPtr [IN] A pointer to the working memory
  348. * required by the model on the Device,can be null
  349. * @param workSize [IN] work memory size
  350. * @param weightPtr [IN] Pointer to model weight memory on Device,can be null
  351. * @param weightSize [IN] The amount of weight memory required by the model
  352. *
  353. * @retval ACL_SUCCESS The function is successfully executed.
  354. * @retval OtherValues Failure
  355. */
  356. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMemWithMem(const void *model, size_t modelSize, uint32_t *modelId,
  357. void *workPtr, size_t workSize, void *weightPtr,
  358. size_t weightSize);
  359. /**
  360. * @ingroup AscendCL
  361. * @brief load model from file with async queue
  362. *
  363. * @param modelPath [IN] model path
  364. * @param modelId [OUT] return model id if load success
  365. * @param inputQ [IN] input queue pointer
  366. * @param inputQNum [IN] input queue num
  367. * @param outputQ [IN] output queue pointer
  368. * @param outputQNum [IN] output queue num
  369. *
  370. * @retval ACL_SUCCESS The function is successfully executed.
  371. * @retval OtherValues Failure
  372. */
  373. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFileWithQ(const char *modelPath, uint32_t *modelId, const uint32_t *inputQ,
  374. size_t inputQNum, const uint32_t *outputQ, size_t outputQNum);
  375. /**
  376. * @ingroup AscendCL
  377. * @brief load model from memory with async queue
  378. *
  379. * @param model [IN] model memory which user manages
  380. * @param modelSize [IN] model size
  381. * @param modelId [OUT] return model id if load success
  382. * @param inputQ [IN] input queue pointer
  383. * @param inputQNum [IN] input queue num
  384. * @param outputQ [IN] output queue pointer
  385. * @param outputQNum [IN] output queue num
  386. *
  387. * @retval ACL_SUCCESS The function is successfully executed.
  388. * @retval OtherValues Failure
  389. */
  390. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMemWithQ(const void *model, size_t modelSize, uint32_t *modelId,
  391. const uint32_t *inputQ, size_t inputQNum, const uint32_t *outputQ,
  392. size_t outputQNum);
  393. /**
  394. * @ingroup AscendCL
  395. * @brief Execute model synchronous inference until the inference result is returned
  396. *
  397. * @param modelId [IN] ID of the model to perform inference
  398. * @param input [IN] Input data for model inference
  399. * @param output [OUT] Output data for model inference
  400. *
  401. * @retval ACL_SUCCESS The function is successfully executed.
  402. * @retval OtherValues Failure
  403. */
  404. ACL_FUNC_VISIBILITY aclError aclmdlExecute(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output);
  405. /**
  406. * @ingroup AscendCL
  407. * @brief Execute model asynchronous inference until the inference result is returned
  408. *
  409. * @param modelId [IN] ID of the model to perform inference
  410. * @param input [IN] Input data for model inference
  411. * @param output [OUT] Output data for model inference
  412. * @param stream [IN] stream
  413. *
  414. * @retval ACL_SUCCESS The function is successfully executed.
  415. * @retval OtherValues Failure
  416. *
  417. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  418. * aclmdlLoadFromMemWithMem
  419. */
  420. ACL_FUNC_VISIBILITY aclError aclmdlExecuteAsync(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output,
  421. aclrtStream stream);
  422. /**
  423. * @ingroup AscendCL
  424. * @brief unload model with model id
  425. *
  426. * @param modelId [IN] model id to be unloaded
  427. *
  428. * @retval ACL_SUCCESS The function is successfully executed.
  429. * @retval OtherValues Failure
  430. */
  431. ACL_FUNC_VISIBILITY aclError aclmdlUnload(uint32_t modelId);
  432. /**
  433. * @ingroup AscendCL
  434. * @brief Get the weight memory size and working memory size
  435. * required for model execution according to the model file
  436. *
  437. * @param fileName [IN] Model path to get memory information
  438. * @param workSize [OUT] The amount of working memory for model executed
  439. * @param weightSize [OUT] The amount of weight memory for model executed
  440. *
  441. * @retval ACL_SUCCESS The function is successfully executed.
  442. * @retval OtherValues Failure
  443. */
  444. ACL_FUNC_VISIBILITY aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize);
  445. /**
  446. * @ingroup AscendCL
  447. * @brief Obtain the weights required for
  448. * model execution according to the model data in memory
  449. *
  450. * @par Restriction
  451. * The execution and weight memory is Device memory,
  452. * and requires user application and release.
  453. * @param model [IN] model memory which user manages
  454. * @param modelSize [IN] model data size
  455. * @param workSize [OUT] The amount of working memory for model executed
  456. * @param weightSize [OUT] The amount of weight memory for model executed
  457. *
  458. * @retval ACL_SUCCESS The function is successfully executed.
  459. * @retval OtherValues Failure
  460. */
  461. ACL_FUNC_VISIBILITY aclError aclmdlQuerySizeFromMem(const void *model, size_t modelSize, size_t *workSize,
  462. size_t *weightSize);
  463. /**
  464. * @ingroup AscendCL
  465. * @brief In dynamic batch scenarios,
  466. * it is used to set the number of images processed
  467. * at one time during model inference
  468. *
  469. * @param modelId [IN] model id
  470. * @param dataset [IN|OUT] data for model inference
  471. * @param index [IN] index of dynamic tensor
  472. * @param batchSize [IN] Number of images processed at a time during model
  473. *
  474. * @retval ACL_SUCCESS The function is successfully executed.
  475. * @retval OtherValues Failure
  476. *
  477. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  478. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  479. */
  480. ACL_FUNC_VISIBILITY aclError aclmdlSetDynamicBatchSize(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  481. uint64_t batchSize);
  482. /**
  483. * @ingroup AscendCL
  484. * @brief Sets the H and W of the specified input of the model
  485. *
  486. * @param modelId [IN] model id
  487. * @param dataset [IN|OUT] data for model inference
  488. * @param index [IN] index of dynamic tensor
  489. * @param height [IN] model height
  490. * @param width [IN] model width
  491. *
  492. * @retval ACL_SUCCESS The function is successfully executed.
  493. * @retval OtherValues Failure
  494. *
  495. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  496. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  497. */
  498. ACL_FUNC_VISIBILITY aclError aclmdlSetDynamicHWSize(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  499. uint64_t height, uint64_t width);
  500. /**
  501. * @ingroup AscendCL
  502. * @brief Sets the dynamic dims of the specified input of the model
  503. *
  504. * @param modelId [IN] model id
  505. * @param dataset [IN|OUT] data for model inference
  506. * @param index [IN] index of dynamic dims
  507. * @param dims [IN] value of dynamic dims
  508. *
  509. * @retval ACL_SUCCESS The function is successfully executed.
  510. * @retval OtherValues Failure
  511. *
  512. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  513. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  514. */
  515. ACL_FUNC_VISIBILITY aclError aclmdlSetInputDynamicDims(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  516. const aclmdlIODims *dims);
  517. /**
  518. * @ingroup AscendCL
  519. * @brief get input dims info
  520. *
  521. * @param modelDesc [IN] model description
  522. * @param index [IN] input tensor index
  523. * @param dims [OUT] dims info
  524. *
  525. * @retval ACL_SUCCESS The function is successfully executed.
  526. * @retval OtherValues Failure
  527. *
  528. * @see aclmdlGetInputDimsV2
  529. */
  530. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  531. /**
  532. * @ingroup AscendCL
  533. * @brief get input dims info(version 2), especially for static aipp
  534. * it is the same with aclmdlGetInputDims while model without static aipp
  535. *
  536. * @param modelDesc [IN] model description
  537. * @param index [IN] input tensor index
  538. * @param dims [OUT] dims info
  539. *
  540. * @retval ACL_SUCCESS The function is successfully executed.
  541. * @retval OtherValues Failure
  542. *
  543. * @see aclmdlGetInputDims
  544. */
  545. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDimsV2(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  546. /**
  547. * @ingroup AscendCL
  548. * @brief get output dims info
  549. *
  550. * @param modelDesc [IN] model description
  551. * @param index [IN] output tensor index
  552. * @param dims [OUT] dims info
  553. *
  554. * @retval ACL_SUCCESS The function is successfully executed.
  555. * @retval OtherValues Failure
  556. */
  557. ACL_FUNC_VISIBILITY aclError aclmdlGetOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  558. /**
  559. * @ingroup AscendCL
  560. * @brief get current output dims info
  561. *
  562. * @par Function
  563. * The following use cases are supported:
  564. * @li Get current output shape when model is dynamic and
  565. * dynamic shape info is set
  566. * @li Get max output shape when model is dynamic and
  567. * dynamic shape info is not set
  568. * @li Get actual output shape when model is static
  569. *
  570. * @param modelDesc [IN] model description
  571. * @param index [IN] output tensor index
  572. * @param dims [OUT] dims info
  573. *
  574. * @retval ACL_SUCCESS The function is successfully executed.
  575. * @retval OtherValues Failure
  576. */
  577. ACL_FUNC_VISIBILITY aclError aclmdlGetCurOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  578. /**
  579. * @ingroup AscendCL
  580. * @brief get input name by index
  581. *
  582. * @param modelDesc [IN] model description
  583. * @param index [IN] intput tensor index
  584. *
  585. * @retval input tensor name,the same life cycle with modelDesc
  586. */
  587. ACL_FUNC_VISIBILITY const char *aclmdlGetInputNameByIndex(const aclmdlDesc *modelDesc, size_t index);
  588. /**
  589. * @ingroup AscendCL
  590. * @brief get output name by index
  591. *
  592. * @param modelDesc [IN] model description
  593. * @param index [IN] output tensor index
  594. *
  595. * @retval output tensor name,the same life cycle with modelDesc
  596. */
  597. ACL_FUNC_VISIBILITY const char *aclmdlGetOutputNameByIndex(const aclmdlDesc *modelDesc, size_t index);
  598. /**
  599. * @ingroup AscendCL
  600. * @brief get input format by index
  601. *
  602. * @param modelDesc [IN] model description
  603. * @param index [IN] intput tensor index
  604. *
  605. * @retval input tensor format
  606. */
  607. ACL_FUNC_VISIBILITY aclFormat aclmdlGetInputFormat(const aclmdlDesc *modelDesc, size_t index);
  608. /**
  609. * @ingroup AscendCL
  610. * @brief get output format by index
  611. *
  612. * @param modelDesc [IN] model description
  613. * @param index [IN] output tensor index
  614. *
  615. * @retval output tensor format
  616. */
  617. ACL_FUNC_VISIBILITY aclFormat aclmdlGetOutputFormat(const aclmdlDesc *modelDesc, size_t index);
  618. /**
  619. * @ingroup AscendCL
  620. * @brief get input data type by index
  621. *
  622. * @param modelDesc [IN] model description
  623. * @param index [IN] intput tensor index
  624. *
  625. * @retval input tensor data type
  626. */
  627. ACL_FUNC_VISIBILITY aclDataType aclmdlGetInputDataType(const aclmdlDesc *modelDesc, size_t index);
  628. /**
  629. * @ingroup AscendCL
  630. * @brief get output data type by index
  631. *
  632. * @param modelDesc [IN] model description
  633. * @param index [IN] output tensor index
  634. *
  635. * @retval output tensor data type
  636. */
  637. ACL_FUNC_VISIBILITY aclDataType aclmdlGetOutputDataType(const aclmdlDesc *modelDesc, size_t index);
  638. /**
  639. * @ingroup AscendCL
  640. * @brief get input tensor index by name
  641. *
  642. * @param modelDesc [IN] model description
  643. * @param name [IN] intput tensor name
  644. * @param index [OUT] intput tensor index
  645. *
  646. * @retval ACL_SUCCESS The function is successfully executed.
  647. * @retval OtherValues Failure
  648. */
  649. ACL_FUNC_VISIBILITY aclError aclmdlGetInputIndexByName(const aclmdlDesc *modelDesc, const char *name, size_t *index);
  650. /**
  651. * @ingroup AscendCL
  652. * @brief get output tensor index by name
  653. *
  654. * @param modelDesc [IN] model description
  655. * @param name [IN] output tensor name
  656. * @param index [OUT] output tensor index
  657. *
  658. * @retval ACL_SUCCESS The function is successfully executed.
  659. * @retval OtherValues Failure
  660. */
  661. ACL_FUNC_VISIBILITY aclError aclmdlGetOutputIndexByName(const aclmdlDesc *modelDesc, const char *name, size_t *index);
  662. /**
  663. * @ingroup AscendCL
  664. * @brief get dynamic batch info
  665. *
  666. * @param modelDesc [IN] model description
  667. * @param batch [OUT] dynamic batch info
  668. *
  669. * @retval ACL_SUCCESS The function is successfully executed.
  670. * @retval OtherValues Failure
  671. */
  672. ACL_FUNC_VISIBILITY aclError aclmdlGetDynamicBatch(const aclmdlDesc *modelDesc, aclmdlBatch *batch);
  673. /**
  674. * @ingroup AscendCL
  675. * @brief get dynamic height&width info
  676. *
  677. * @param modelDesc [IN] model description
  678. * @param index [IN] input tensor index
  679. * @param hw [OUT] dynamic height&width info
  680. *
  681. * @retval ACL_SUCCESS The function is successfully executed.
  682. * @retval OtherValues Failure
  683. */
  684. ACL_FUNC_VISIBILITY aclError aclmdlGetDynamicHW(const aclmdlDesc *modelDesc, size_t index, aclmdlHW *hw);
  685. /**
  686. * @ingroup AscendCL
  687. * @brief get dynamic gear count
  688. *
  689. * @param modelDesc [IN] model description
  690. * @param index [IN] unused, must be -1
  691. * @param gearCount [OUT] dynamic gear count
  692. *
  693. * @retval ACL_SUCCESS The function is successfully executed.
  694. * @retval OtherValues Failure
  695. */
  696. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDynamicGearCount(const aclmdlDesc *modelDesc, size_t index,
  697. size_t *gearCount);
  698. /**
  699. * @ingroup AscendCL
  700. * @brief get dynamic dims info
  701. *
  702. * @param modelDesc [IN] model description
  703. * @param index [IN] unused, must be -1
  704. * @param dims [OUT] value of dynamic dims
  705. * @param gearCount [IN] dynamic gear count
  706. *
  707. * @retval ACL_SUCCESS The function is successfully executed.
  708. * @retval OtherValues Failure
  709. */
  710. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDynamicDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims,
  711. size_t gearCount);
  712. /**
  713. * @ingroup AscendCL
  714. * @brief Create data of type aclmdlAIPP
  715. *
  716. * @param batchSize [IN] batchsizes of model
  717. *
  718. * @retval the aclmdlAIPP pointer
  719. */
  720. ACL_FUNC_VISIBILITY aclmdlAIPP *aclmdlCreateAIPP(uint64_t batchSize);
  721. /**
  722. * @ingroup AscendCL
  723. * @brief destroy data of type aclmdlAIPP
  724. *
  725. * @param aippParmsSet [IN] Pointer for aclmdlAIPP to be destroyed
  726. *
  727. * @retval ACL_SUCCESS The function is successfully executed.
  728. * @retval OtherValues Failure
  729. */
  730. ACL_FUNC_VISIBILITY aclError aclmdlDestroyAIPP(const aclmdlAIPP *aippParmsSet);
  731. /**
  732. * @ingroup AscendCL
  733. * @brief set InputFormat of type aclmdlAIPP
  734. *
  735. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  736. * @param inputFormat [IN] The inputFormat of aipp
  737. *
  738. * @retval ACL_SUCCESS The function is successfully executed.
  739. * @retval OtherValues Failure
  740. *
  741. * @see aclmdlCreateAIPP
  742. */
  743. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPInputFormat(aclmdlAIPP *aippParmsSet, aclAippInputFormat inputFormat);
  744. /**
  745. * @ingroup AscendCL
  746. * @brief set cscParms of type aclmdlAIPP
  747. *
  748. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  749. * @param csc_switch [IN] Csc switch
  750. * @param cscMatrixR0C0 [IN] Csc_matrix_r0_c0
  751. * @param cscMatrixR0C1 [IN] Csc_matrix_r0_c1
  752. * @param cscMatrixR0C2 [IN] Csc_matrix_r0_c2
  753. * @param cscMatrixR1C0 [IN] Csc_matrix_r1_c0
  754. * @param cscMatrixR1C1 [IN] Csc_matrix_r1_c1
  755. * @param cscMatrixR1C2 [IN] Csc_matrix_r1_c2
  756. * @param cscMatrixR2C0 [IN] Csc_matrix_r2_c0
  757. * @param cscMatrixR2C1 [IN] Csc_matrix_r2_c1
  758. * @param cscMatrixR2C2 [IN] Csc_matrix_r2_c2
  759. * @param cscOutputBiasR0 [IN] Output Bias for RGB to YUV, element of row 0, unsigned number
  760. * @param cscOutputBiasR1 [IN] Output Bias for RGB to YUV, element of row 1, unsigned number
  761. * @param cscOutputBiasR2 [IN] Output Bias for RGB to YUV, element of row 2, unsigned number
  762. * @param cscInputBiasR0 [IN] Input Bias for YUV to RGB, element of row 0, unsigned number
  763. * @param cscInputBiasR1 [IN] Input Bias for YUV to RGB, element of row 1, unsigned number
  764. * @param cscInputBiasR2 [IN] Input Bias for YUV to RGB, element of row 2, unsigned number
  765. *
  766. * @retval ACL_SUCCESS The function is successfully executed.
  767. * @retval OtherValues Failure
  768. *
  769. * @see aclmdlCreateAIPP
  770. */
  771. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPCscParams(aclmdlAIPP *aippParmsSet, int8_t csc_switch, int16_t cscMatrixR0C0,
  772. int16_t cscMatrixR0C1, int16_t cscMatrixR0C2, int16_t cscMatrixR1C0,
  773. int16_t cscMatrixR1C1, int16_t cscMatrixR1C2, int16_t cscMatrixR2C0,
  774. int16_t cscMatrixR2C1, int16_t cscMatrixR2C2,
  775. uint8_t cscOutputBiasR0, uint8_t cscOutputBiasR1,
  776. uint8_t cscOutputBiasR2, uint8_t cscInputBiasR0,
  777. uint8_t cscInputBiasR1, uint8_t cscInputBiasR2);
  778. /**
  779. * @ingroup AscendCL
  780. * @brief set rb/ub swap switch of type aclmdlAIPP
  781. *
  782. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  783. * @param rbuvSwapSwitch [IN] rb/ub swap switch
  784. *
  785. * @retval ACL_SUCCESS The function is successfully executed.
  786. * @retval OtherValues Failure
  787. *
  788. * @see aclmdlCreateAIPP
  789. */
  790. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPRbuvSwapSwitch(aclmdlAIPP *aippParmsSet, int8_t rbuvSwapSwitch);
  791. /**
  792. * @ingroup AscendCL
  793. * @brief set RGBA->ARGB, YUVA->AYUV swap switch of type aclmdlAIPP
  794. *
  795. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  796. * @param axSwapSwitch [IN] RGBA->ARGB, YUVA->AYUV swap switch
  797. *
  798. * @retval ACL_SUCCESS The function is successfully executed.
  799. * @retval OtherValues Failure
  800. *
  801. * @see aclmdlCreateAIPP
  802. */
  803. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPAxSwapSwitch(aclmdlAIPP *aippParmsSet, int8_t axSwapSwitch);
  804. /**
  805. * @ingroup AscendCL
  806. * @brief set source image of type aclmdlAIPP
  807. *
  808. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  809. * @param srcImageSizeW [IN] Source image width
  810. * @param srcImageSizeH [IN] Source image height
  811. *
  812. * @retval ACL_SUCCESS The function is successfully executed.
  813. * @retval OtherValues Failure
  814. *
  815. * @see aclmdlCreateAIPP
  816. */
  817. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPSrcImageSize(aclmdlAIPP *aippParmsSet, int32_t srcImageSizeW,
  818. int32_t srcImageSizeH);
  819. /**
  820. * @ingroup AscendCL
  821. * @brief set resize switch of type aclmdlAIPP
  822. *
  823. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  824. * @param scfSwitch [IN] Resize switch
  825. * @param scfInputSizeW [IN] Input width of scf
  826. * @param scfInputSizeH [IN] Input height of scf
  827. * @param scfOutputSizeW [IN] Output width of scf
  828. * @param scfOutputSizeH [IN] Output height of scf
  829. * @param batchIndex [IN] Batch parameter index
  830. *
  831. * @retval ACL_SUCCESS The function is successfully executed.
  832. * @retval OtherValues Failure
  833. *
  834. * @see aclmdlCreateAIPP
  835. */
  836. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPScfParams(aclmdlAIPP *aippParmsSet, int8_t scfSwitch, int32_t scfInputSizeW,
  837. int32_t scfInputSizeH, int32_t scfOutputSizeW,
  838. int32_t scfOutputSizeH, uint64_t batchIndex);
  839. /**
  840. * @ingroup AscendCL
  841. * @brief set cropParams of type aclmdlAIPP
  842. *
  843. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  844. * @param cropSwitch [IN] Crop switch
  845. * @param cropStartPosW [IN] The start horizontal position of cropping
  846. * @param cropStartPosH [IN] The start vertical position of cropping
  847. * @param cropSizeW [IN] Crop width
  848. * @param cropSizeH [IN] Crop height
  849. * @param batchIndex [IN] Batch parameter index
  850. *
  851. * @retval ACL_SUCCESS The function is successfully executed.
  852. * @retval OtherValues Failure
  853. *
  854. * @see aclmdlCreateAIPP
  855. */
  856. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPCropParams(aclmdlAIPP *aippParmsSet, int8_t cropSwitch, int32_t cropStartPosW,
  857. int32_t cropStartPosH, int32_t cropSizeW, int32_t cropSizeH,
  858. uint64_t batchIndex);
  859. /**
  860. * @ingroup AscendCL
  861. * @brief set paddingParams of type aclmdlAIPP
  862. *
  863. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  864. * @param paddingSwitch [IN] Padding switch
  865. * @param paddingSizeTop [IN] Top padding size
  866. * @param paddingSizeBottom [IN] Bottom padding size
  867. * @param paddingSizeLeft [IN] Left padding size
  868. * @param paddingSizeRight [IN] Right padding size
  869. * @param batchIndex [IN] Batch parameter index
  870. *
  871. * @retval ACL_SUCCESS The function is successfully executed.
  872. * @retval OtherValues Failure
  873. *
  874. * @see aclmdlCreateAIPP
  875. */
  876. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPPaddingParams(aclmdlAIPP *aippParmsSet, int8_t paddingSwitch,
  877. int32_t paddingSizeTop, int32_t paddingSizeBottom,
  878. int32_t paddingSizeLeft, int32_t paddingSizeRight,
  879. uint64_t batchIndex);
  880. /**
  881. * @ingroup AscendCL
  882. * @brief set DtcPixelMean of type aclmdlAIPP
  883. *
  884. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  885. * @param dtcPixelMeanChn0 [IN] Mean value of channel 0
  886. * @param dtcPixelMeanChn1 [IN] Mean value of channel 1
  887. * @param dtcPixelMeanChn2 [IN] Mean value of channel 2
  888. * @param dtcPixelMeanChn3 [IN] Mean value of channel 3
  889. * @param batchIndex [IN] Batch parameter index
  890. *
  891. * @retval ACL_SUCCESS The function is successfully executed.
  892. * @retval OtherValues Failure
  893. *
  894. * @see aclmdlCreateAIPP
  895. */
  896. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPDtcPixelMean(aclmdlAIPP *aippParmsSet, int16_t dtcPixelMeanChn0,
  897. int16_t dtcPixelMeanChn1, int16_t dtcPixelMeanChn2,
  898. int16_t dtcPixelMeanChn3, uint64_t batchIndex);
  899. /**
  900. * @ingroup AscendCL
  901. * @brief set DtcPixelMin of type aclmdlAIPP
  902. *
  903. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  904. * @param dtcPixelMinChn0 [IN] Min value of channel 0
  905. * @param dtcPixelMinChn1 [IN] Min value of channel 1
  906. * @param dtcPixelMinChn2 [IN] Min value of channel 2
  907. * @param dtcPixelMinChn3 [IN] Min value of channel 3
  908. * @param batchIndex [IN] Batch parameter index
  909. *
  910. * @retval ACL_SUCCESS The function is successfully executed.
  911. * @retval OtherValues Failure
  912. *
  913. * @see aclmdlCreateAIPP
  914. */
  915. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPDtcPixelMin(aclmdlAIPP *aippParmsSet, float dtcPixelMinChn0,
  916. float dtcPixelMinChn1, float dtcPixelMinChn2,
  917. float dtcPixelMinChn3, uint64_t batchIndex);
  918. /**
  919. * @ingroup AscendCL
  920. * @brief set PixelVarReci of type aclmdlAIPP
  921. *
  922. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  923. * @param dtcPixelVarReciChn0 [IN] sfr_dtc_pixel_variance_reci_ch0
  924. * @param dtcPixelVarReciChn1 [IN] sfr_dtc_pixel_variance_reci_ch1
  925. * @param dtcPixelVarReciChn2 [IN] sfr_dtc_pixel_variance_reci_ch2
  926. * @param dtcPixelVarReciChn3 [IN] sfr_dtc_pixel_variance_reci_ch3
  927. * @param batchIndex [IN] Batch parameter index
  928. *
  929. * @retval ACL_SUCCESS The function is successfully executed.
  930. * @retval OtherValues Failure
  931. *
  932. * @see aclmdlCreateAIPP
  933. */
  934. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPPixelVarReci(aclmdlAIPP *aippParmsSet, float dtcPixelVarReciChn0,
  935. float dtcPixelVarReciChn1, float dtcPixelVarReciChn2,
  936. float dtcPixelVarReciChn3, uint64_t batchIndex);
  937. /**
  938. * @ingroup AscendCL
  939. * @brief set aipp parameters to model
  940. *
  941. * @param modelId [IN] model id
  942. * @param dataset [IN] Pointer of dataset
  943. * @param index [IN] index of input for aipp data(ACL_DYNAMIC_AIPP_NODE)
  944. * @param aippParmsSet [IN] Pointer for aclmdlAIPP
  945. *
  946. * @retval ACL_SUCCESS The function is successfully executed.
  947. * @retval OtherValues Failure
  948. *
  949. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  950. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
  951. */
  952. ACL_FUNC_VISIBILITY aclError aclmdlSetInputAIPP(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  953. const aclmdlAIPP *aippParmsSet);
  954. /**
  955. * @ingroup AscendCL
  956. * @brief set aipp parameters to model
  957. *
  958. * @param modelId [IN] model id
  959. * @param dataset [IN] Pointer of dataset
  960. * @param index [IN] index of input for data which linked dynamic aipp(ACL_DATA_WITH_DYNAMIC_AIPP)
  961. * @param aippParmsSet [IN] Pointer for aclmdlAIPP
  962. *
  963. * @retval ACL_SUCCESS The function is successfully executed.
  964. * @retval OtherValues Failure
  965. *
  966. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  967. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
  968. */
  969. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPByInputIndex(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  970. const aclmdlAIPP *aippParmsSet);
  971. /**
  972. * @ingroup AscendCL
  973. * @brief get input aipp type
  974. *
  975. * @param modelId [IN] model id
  976. * @param index [IN] index of input
  977. * @param type [OUT] aipp type for input.refrer to aclmdlInputAippType(enum)
  978. * @param dynamicAttachedDataIndex [OUT] index for dynamic attached data(ACL_DYNAMIC_AIPP_NODE)
  979. * valid when type is ACL_DATA_WITH_DYNAMIC_AIPP, invalid value is ACL_INVALID_NODE_INDEX
  980. *
  981. * @retval ACL_SUCCESS The function is successfully executed.
  982. * @retval OtherValues Failure
  983. *
  984. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  985. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
  986. */
  987. ACL_FUNC_VISIBILITY aclError aclmdlGetAippType(uint32_t modelId, size_t index, aclmdlInputAippType *type,
  988. size_t *dynamicAttachedDataIndex);
  989. /**
  990. * @ingroup AscendCL
  991. * @brief get static aipp parameters from model
  992. *
  993. * @param modelId [IN] model id
  994. * @param index [IN] index of tensor
  995. * @param aippinfo [OUT] Pointer for static aipp info
  996. *
  997. * @retval ACL_SUCCESS The function is successfully executed.
  998. * @retval ACL_ERROR_MODEL_AIPP_NOT_EXIST The tensor of index is not configured with aipp
  999. * @retval OtherValues Failure
  1000. *
  1001. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  1002. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  1003. */
  1004. ACL_FUNC_VISIBILITY aclError aclmdlGetFirstAippInfo(uint32_t modelId, size_t index, aclAippInfo *aippinfo);
  1005. /**
  1006. * @ingroup AscendCL
  1007. * @brief get op description info
  1008. *
  1009. * @param deviceId [IN] device id
  1010. * @param streamId [IN] stream id
  1011. * @param taskId [IN] task id
  1012. * @param opName [OUT] pointer to op name
  1013. * @param opNameLen [IN] the length of op name
  1014. * @param inputDesc [OUT] pointer to input description
  1015. * @param numInputs [OUT] the number of input tensor
  1016. * @param outputDesc [OUT] pointer to output description
  1017. * @param numOutputs [OUT] the number of output tensor
  1018. *
  1019. * @retval ACL_SUCCESS The function is successfully executed
  1020. * @retval OtherValues Failure
  1021. */
  1022. ACL_FUNC_VISIBILITY aclError aclmdlCreateAndGetOpDesc(uint32_t deviceId, uint32_t streamId, uint32_t taskId,
  1023. char *opName, size_t opNameLen, aclTensorDesc **inputDesc,
  1024. size_t *numInputs, aclTensorDesc **outputDesc,
  1025. size_t *numOutputs);
  1026. /**
  1027. * @ingroup AscendCL
  1028. * @brief init dump
  1029. *
  1030. * @retval ACL_SUCCESS The function is successfully executed.
  1031. * @retval OtherValues Failure
  1032. */
  1033. ACL_FUNC_VISIBILITY aclError aclmdlInitDump();
  1034. /**
  1035. * @ingroup AscendCL
  1036. * @brief set param of dump
  1037. *
  1038. * @param dumpCfgPath [IN] the path of dump config
  1039. *
  1040. * @retval ACL_SUCCESS The function is successfully executed.
  1041. * @retval OtherValues Failure
  1042. */
  1043. ACL_FUNC_VISIBILITY aclError aclmdlSetDump(const char *dumpCfgPath);
  1044. /**
  1045. * @ingroup AscendCL
  1046. * @brief finalize dump.
  1047. *
  1048. * @retval ACL_SUCCESS The function is successfully executed.
  1049. * @retval OtherValues Failure
  1050. */
  1051. ACL_FUNC_VISIBILITY aclError aclmdlFinalizeDump();
  1052. /**
  1053. * @ingroup AscendCL
  1054. * @brief load model with config
  1055. *
  1056. * @param handle [IN] pointer to model config handle
  1057. * @param modelId [OUT] pointer to model id
  1058. *
  1059. * @retval ACL_SUCCESS The function is successfully executed.
  1060. * @retval OtherValues Failure
  1061. */
  1062. ACL_FUNC_VISIBILITY aclError aclmdlLoadWithConfig(const aclmdlConfigHandle *handle, uint32_t *modelId);
  1063. /**
  1064. * @ingroup AscendCL
  1065. * @brief create model config handle of type aclmdlConfigHandle
  1066. *
  1067. * @retval the aclmdlConfigHandle pointer
  1068. *
  1069. * @see aclmdlDestroyConfigHandle
  1070. */
  1071. ACL_FUNC_VISIBILITY aclmdlConfigHandle *aclmdlCreateConfigHandle();
  1072. /**
  1073. * @ingroup AscendCL
  1074. * @brief destroy data of type aclmdlConfigHandle
  1075. *
  1076. * @param handle [IN] pointer to model config handle
  1077. *
  1078. * @retval ACL_SUCCESS The function is successfully executed.
  1079. * @retval OtherValues Failure
  1080. *
  1081. * @see aclmdlCreateConfigHandle
  1082. */
  1083. ACL_FUNC_VISIBILITY aclError aclmdlDestroyConfigHandle(aclmdlConfigHandle *handle);
  1084. /**
  1085. * @ingroup AscendCL
  1086. * @brief set config for model load
  1087. *
  1088. * @param handle [OUT] pointer to model config handle
  1089. * @param attr [IN] config attr in model config handle to be set
  1090. * @param attrValue [IN] pointer to model config value
  1091. * @param valueSize [IN] memory size of attrValue
  1092. *
  1093. * @retval ACL_SUCCESS The function is successfully executed.
  1094. * @retval OtherValues Failure
  1095. */
  1096. ACL_FUNC_VISIBILITY aclError aclmdlSetConfigOpt(aclmdlConfigHandle *handle, aclmdlConfigAttr attr,
  1097. const void *attrValue, size_t valueSize);
  1098. /**
  1099. * @ingroup AscendCL
  1100. * @brief get real tensor name from modelDesc
  1101. *
  1102. * @param modelDesc [IN] pointer to modelDesc
  1103. * @param name [IN] tensor name
  1104. *
  1105. * @retval the pointer of real tensor name
  1106. * @retval Failure return NULL
  1107. */
  1108. ACL_FUNC_VISIBILITY const char *aclmdlGetTensorRealName(const aclmdlDesc *modelDesc, const char *name);
  1109. #ifdef __cplusplus
  1110. }
  1111. #endif
  1112. #endif // INC_EXTERNAL_ACL_ACL_MODEL_H_

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