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 43 kB

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

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