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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  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. #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 the number of aclDataBuffer in aclmdlDataset
  273. *
  274. * @param dataset [IN] aclmdlDataset poiter
  275. *
  276. * @retval the number of aclDataBuffer
  277. */
  278. ACL_FUNC_VISIBILITY size_t aclmdlGetDatasetNumBuffers(const aclmdlDataset *dataset);
  279. /**
  280. * @ingroup AscendCL
  281. * @brief Get the aclDataBuffer in aclmdlDataset by index
  282. *
  283. * @param dataset [IN] aclmdlDataset poiter
  284. * @param index [IN] the index of aclDataBuffer
  285. *
  286. * @retval Get successfully, return the address of aclDataBuffer
  287. * @retval Failure return NULL
  288. */
  289. ACL_FUNC_VISIBILITY aclDataBuffer *aclmdlGetDatasetBuffer(const aclmdlDataset *dataset, size_t index);
  290. /**
  291. * @ingroup AscendCL
  292. * @brief Load offline model data from files
  293. * and manage memory internally by the system
  294. *
  295. * @par Function
  296. * After the system finishes loading the model,
  297. * the model ID returned is used as a mark to identify the model
  298. * during subsequent operations
  299. *
  300. * @param modelPath [IN] Storage path for offline model files
  301. * @param modelId [OUT] Model ID generated after
  302. * the system finishes loading the model
  303. *
  304. * @retval ACL_SUCCESS The function is successfully executed.
  305. * @retval OtherValues Failure
  306. */
  307. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFile(const char *modelPath, uint32_t *modelId);
  308. /**
  309. * @ingroup AscendCL
  310. * @brief Load offline model data from memory and manage the memory of
  311. * model running internally by the system
  312. *
  313. * @par Function
  314. * After the system finishes loading the model,
  315. * the model ID returned is used as a mark to identify the model
  316. * during subsequent operations
  317. *
  318. * @param model [IN] Model data stored in memory
  319. * @param modelSize [IN] model data size
  320. * @param modelId [OUT] Model ID generated after
  321. * the system finishes loading the model
  322. *
  323. * @retval ACL_SUCCESS The function is successfully executed.
  324. * @retval OtherValues Failure
  325. */
  326. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMem(const void *model, size_t modelSize, uint32_t *modelId);
  327. /**
  328. * @ingroup AscendCL
  329. * @brief Load offline model data from a file,
  330. * and the user manages the memory of the model run by itself
  331. *
  332. * @par Function
  333. * After the system finishes loading the model,
  334. * the model ID returned is used as a mark to identify the model
  335. * during subsequent operations.
  336. * @param modelPath [IN] Storage path for offline model files
  337. * @param modelId [OUT] Model ID generated after finishes loading the model
  338. * @param workPtr [IN] A pointer to the working memory
  339. * required by the model on the Device,can be null
  340. * @param workSize [IN] The amount of working memory required by the model
  341. * @param weightPtr [IN] Pointer to model weight memory on Device
  342. * @param weightSize [IN] The amount of weight memory required by the model
  343. *
  344. * @retval ACL_SUCCESS The function is successfully executed.
  345. * @retval OtherValues Failure
  346. */
  347. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFileWithMem(const char *modelPath, uint32_t *modelId, void *workPtr,
  348. size_t workSize, void *weightPtr, size_t weightSize);
  349. /**
  350. * @ingroup AscendCL
  351. * @brief Load offline model data from memory,
  352. * and the user can manage the memory of model running
  353. *
  354. * @par Function
  355. * After the system finishes loading the model,
  356. * the model ID returned is used as a mark to identify the model
  357. * during subsequent operations
  358. * @param model [IN] Model data stored in memory
  359. * @param modelSize [IN] model data size
  360. * @param modelId [OUT] Model ID generated after finishes loading the model
  361. * @param workPtr [IN] A pointer to the working memory
  362. * required by the model on the Device,can be null
  363. * @param workSize [IN] work memory size
  364. * @param weightPtr [IN] Pointer to model weight memory on Device,can be null
  365. * @param weightSize [IN] The amount of weight memory required by the model
  366. *
  367. * @retval ACL_SUCCESS The function is successfully executed.
  368. * @retval OtherValues Failure
  369. */
  370. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMemWithMem(const void *model, size_t modelSize, uint32_t *modelId,
  371. void *workPtr, size_t workSize, void *weightPtr,
  372. size_t weightSize);
  373. /**
  374. * @ingroup AscendCL
  375. * @brief load model from file with async queue
  376. *
  377. * @param modelPath [IN] model path
  378. * @param modelId [OUT] return model id if load success
  379. * @param inputQ [IN] input queue pointer
  380. * @param inputQNum [IN] input queue num
  381. * @param outputQ [IN] output queue pointer
  382. * @param outputQNum [IN] output queue num
  383. *
  384. * @retval ACL_SUCCESS The function is successfully executed.
  385. * @retval OtherValues Failure
  386. */
  387. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFileWithQ(const char *modelPath, uint32_t *modelId, const uint32_t *inputQ,
  388. size_t inputQNum, const uint32_t *outputQ, size_t outputQNum);
  389. /**
  390. * @ingroup AscendCL
  391. * @brief load model from memory with async queue
  392. *
  393. * @param model [IN] model memory which user manages
  394. * @param modelSize [IN] model size
  395. * @param modelId [OUT] return model id if load success
  396. * @param inputQ [IN] input queue pointer
  397. * @param inputQNum [IN] input queue num
  398. * @param outputQ [IN] output queue pointer
  399. * @param outputQNum [IN] output queue num
  400. *
  401. * @retval ACL_SUCCESS The function is successfully executed.
  402. * @retval OtherValues Failure
  403. */
  404. ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMemWithQ(const void *model, size_t modelSize, uint32_t *modelId,
  405. const uint32_t *inputQ, size_t inputQNum, const uint32_t *outputQ,
  406. size_t outputQNum);
  407. /**
  408. * @ingroup AscendCL
  409. * @brief Execute model synchronous inference until the inference result is returned
  410. *
  411. * @param modelId [IN] ID of the model to perform inference
  412. * @param input [IN] Input data for model inference
  413. * @param output [OUT] Output data for model inference
  414. *
  415. * @retval ACL_SUCCESS The function is successfully executed.
  416. * @retval OtherValues Failure
  417. */
  418. ACL_FUNC_VISIBILITY aclError aclmdlExecute(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output);
  419. /**
  420. * @ingroup AscendCL
  421. * @brief Execute model asynchronous inference until the inference result is returned
  422. *
  423. * @param modelId [IN] ID of the model to perform inference
  424. * @param input [IN] Input data for model inference
  425. * @param output [OUT] Output data for model inference
  426. * @param stream [IN] stream
  427. *
  428. * @retval ACL_SUCCESS The function is successfully executed.
  429. * @retval OtherValues Failure
  430. *
  431. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  432. * aclmdlLoadFromMemWithMem
  433. */
  434. ACL_FUNC_VISIBILITY aclError aclmdlExecuteAsync(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output,
  435. aclrtStream stream);
  436. /**
  437. * @ingroup AscendCL
  438. * @brief unload model with model id
  439. *
  440. * @param modelId [IN] model id to be unloaded
  441. *
  442. * @retval ACL_SUCCESS The function is successfully executed.
  443. * @retval OtherValues Failure
  444. */
  445. ACL_FUNC_VISIBILITY aclError aclmdlUnload(uint32_t modelId);
  446. /**
  447. * @ingroup AscendCL
  448. * @brief Get the weight memory size and working memory size
  449. * required for model execution according to the model file
  450. *
  451. * @param fileName [IN] Model path to get memory information
  452. * @param workSize [OUT] The amount of working memory for model executed
  453. * @param weightSize [OUT] The amount of weight memory for model executed
  454. *
  455. * @retval ACL_SUCCESS The function is successfully executed.
  456. * @retval OtherValues Failure
  457. */
  458. ACL_FUNC_VISIBILITY aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize);
  459. /**
  460. * @ingroup AscendCL
  461. * @brief Obtain the weights required for
  462. * model execution according to the model data in memory
  463. *
  464. * @par Restriction
  465. * The execution and weight memory is Device memory,
  466. * and requires user application and release.
  467. * @param model [IN] model memory which user manages
  468. * @param modelSize [IN] model data size
  469. * @param workSize [OUT] The amount of working memory for model executed
  470. * @param weightSize [OUT] The amount of weight memory for model executed
  471. *
  472. * @retval ACL_SUCCESS The function is successfully executed.
  473. * @retval OtherValues Failure
  474. */
  475. ACL_FUNC_VISIBILITY aclError aclmdlQuerySizeFromMem(const void *model, size_t modelSize, size_t *workSize,
  476. size_t *weightSize);
  477. /**
  478. * @ingroup AscendCL
  479. * @brief In dynamic batch scenarios,
  480. * it is used to set the number of images processed
  481. * at one time during model inference
  482. *
  483. * @param modelId [IN] model id
  484. * @param dataset [IN|OUT] data for model inference
  485. * @param index [IN] index of dynamic tensor
  486. * @param batchSize [IN] Number of images processed at a time during model
  487. *
  488. * @retval ACL_SUCCESS The function is successfully executed.
  489. * @retval OtherValues Failure
  490. *
  491. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  492. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  493. */
  494. ACL_FUNC_VISIBILITY aclError aclmdlSetDynamicBatchSize(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  495. uint64_t batchSize);
  496. /**
  497. * @ingroup AscendCL
  498. * @brief Sets the H and W of the specified input of the model
  499. *
  500. * @param modelId [IN] model id
  501. * @param dataset [IN|OUT] data for model inference
  502. * @param index [IN] index of dynamic tensor
  503. * @param height [IN] model height
  504. * @param width [IN] model width
  505. *
  506. * @retval ACL_SUCCESS The function is successfully executed.
  507. * @retval OtherValues Failure
  508. *
  509. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  510. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  511. */
  512. ACL_FUNC_VISIBILITY aclError aclmdlSetDynamicHWSize(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  513. uint64_t height, uint64_t width);
  514. /**
  515. * @ingroup AscendCL
  516. * @brief Sets the dynamic dims of the specified input of the model
  517. *
  518. * @param modelId [IN] model id
  519. * @param dataset [IN|OUT] data for model inference
  520. * @param index [IN] index of dynamic dims
  521. * @param dims [IN] value of dynamic dims
  522. *
  523. * @retval ACL_SUCCESS The function is successfully executed.
  524. * @retval OtherValues Failure
  525. *
  526. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  527. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  528. */
  529. ACL_FUNC_VISIBILITY aclError aclmdlSetInputDynamicDims(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  530. const aclmdlIODims *dims);
  531. /**
  532. * @ingroup AscendCL
  533. * @brief get input dims info
  534. *
  535. * @param modelDesc [IN] model description
  536. * @param index [IN] input tensor index
  537. * @param dims [OUT] dims info
  538. *
  539. * @retval ACL_SUCCESS The function is successfully executed.
  540. * @retval OtherValues Failure
  541. *
  542. * @see aclmdlGetInputDimsV2
  543. */
  544. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  545. /**
  546. * @ingroup AscendCL
  547. * @brief get input dims info(version 2), especially for static aipp
  548. * it is the same with aclmdlGetInputDims while model without static aipp
  549. *
  550. * @param modelDesc [IN] model description
  551. * @param index [IN] input tensor index
  552. * @param dims [OUT] dims info
  553. *
  554. * @retval ACL_SUCCESS The function is successfully executed.
  555. * @retval OtherValues Failure
  556. *
  557. * @see aclmdlGetInputDims
  558. */
  559. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDimsV2(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  560. /**
  561. * @ingroup AscendCL
  562. * @brief get output dims info
  563. *
  564. * @param modelDesc [IN] model description
  565. * @param index [IN] output tensor index
  566. * @param dims [OUT] dims info
  567. *
  568. * @retval ACL_SUCCESS The function is successfully executed.
  569. * @retval OtherValues Failure
  570. */
  571. ACL_FUNC_VISIBILITY aclError aclmdlGetOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  572. /**
  573. * @ingroup AscendCL
  574. * @brief get current output dims info
  575. *
  576. * @par Function
  577. * The following use cases are supported:
  578. * @li Get current output shape when model is dynamic and
  579. * dynamic shape info is set
  580. * @li Get max output shape when model is dynamic and
  581. * dynamic shape info is not set
  582. * @li Get actual output shape when model is static
  583. *
  584. * @param modelDesc [IN] model description
  585. * @param index [IN] output tensor index
  586. * @param dims [OUT] dims info
  587. *
  588. * @retval ACL_SUCCESS The function is successfully executed.
  589. * @retval OtherValues Failure
  590. */
  591. ACL_FUNC_VISIBILITY aclError aclmdlGetCurOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
  592. /**
  593. * @ingroup AscendCL
  594. * @brief get attr value by op name
  595. *
  596. * @param modelDesc [IN] model description
  597. * @param opName [IN] op name
  598. * @param attr [IN] attr name
  599. *
  600. * @retval the attr value
  601. */
  602. ACL_FUNC_VISIBILITY const char *aclmdlGetOpAttr(aclmdlDesc *modelDesc, const char *opName, const char *attr);
  603. /**
  604. * @ingroup AscendCL
  605. * @brief get input name by index
  606. *
  607. * @param modelDesc [IN] model description
  608. * @param index [IN] intput tensor index
  609. *
  610. * @retval input tensor name,the same life cycle with modelDesc
  611. */
  612. ACL_FUNC_VISIBILITY const char *aclmdlGetInputNameByIndex(const aclmdlDesc *modelDesc, size_t index);
  613. /**
  614. * @ingroup AscendCL
  615. * @brief get output name by index
  616. *
  617. * @param modelDesc [IN] model description
  618. * @param index [IN] output tensor index
  619. *
  620. * @retval output tensor name,the same life cycle with modelDesc
  621. */
  622. ACL_FUNC_VISIBILITY const char *aclmdlGetOutputNameByIndex(const aclmdlDesc *modelDesc, size_t index);
  623. /**
  624. * @ingroup AscendCL
  625. * @brief get input format by index
  626. *
  627. * @param modelDesc [IN] model description
  628. * @param index [IN] intput tensor index
  629. *
  630. * @retval input tensor format
  631. */
  632. ACL_FUNC_VISIBILITY aclFormat aclmdlGetInputFormat(const aclmdlDesc *modelDesc, size_t index);
  633. /**
  634. * @ingroup AscendCL
  635. * @brief get output format by index
  636. *
  637. * @param modelDesc [IN] model description
  638. * @param index [IN] output tensor index
  639. *
  640. * @retval output tensor format
  641. */
  642. ACL_FUNC_VISIBILITY aclFormat aclmdlGetOutputFormat(const aclmdlDesc *modelDesc, size_t index);
  643. /**
  644. * @ingroup AscendCL
  645. * @brief get input data type by index
  646. *
  647. * @param modelDesc [IN] model description
  648. * @param index [IN] intput tensor index
  649. *
  650. * @retval input tensor data type
  651. */
  652. ACL_FUNC_VISIBILITY aclDataType aclmdlGetInputDataType(const aclmdlDesc *modelDesc, size_t index);
  653. /**
  654. * @ingroup AscendCL
  655. * @brief get output data type by index
  656. *
  657. * @param modelDesc [IN] model description
  658. * @param index [IN] output tensor index
  659. *
  660. * @retval output tensor data type
  661. */
  662. ACL_FUNC_VISIBILITY aclDataType aclmdlGetOutputDataType(const aclmdlDesc *modelDesc, size_t index);
  663. /**
  664. * @ingroup AscendCL
  665. * @brief get input tensor index by name
  666. *
  667. * @param modelDesc [IN] model description
  668. * @param name [IN] intput tensor name
  669. * @param index [OUT] intput tensor index
  670. *
  671. * @retval ACL_SUCCESS The function is successfully executed.
  672. * @retval OtherValues Failure
  673. */
  674. ACL_FUNC_VISIBILITY aclError aclmdlGetInputIndexByName(const aclmdlDesc *modelDesc, const char *name, size_t *index);
  675. /**
  676. * @ingroup AscendCL
  677. * @brief get output tensor index by name
  678. *
  679. * @param modelDesc [IN] model description
  680. * @param name [IN] output tensor name
  681. * @param index [OUT] output tensor index
  682. *
  683. * @retval ACL_SUCCESS The function is successfully executed.
  684. * @retval OtherValues Failure
  685. */
  686. ACL_FUNC_VISIBILITY aclError aclmdlGetOutputIndexByName(const aclmdlDesc *modelDesc, const char *name, size_t *index);
  687. /**
  688. * @ingroup AscendCL
  689. * @brief get dynamic batch info
  690. *
  691. * @param modelDesc [IN] model description
  692. * @param batch [OUT] dynamic batch info
  693. *
  694. * @retval ACL_SUCCESS The function is successfully executed.
  695. * @retval OtherValues Failure
  696. */
  697. ACL_FUNC_VISIBILITY aclError aclmdlGetDynamicBatch(const aclmdlDesc *modelDesc, aclmdlBatch *batch);
  698. /**
  699. * @ingroup AscendCL
  700. * @brief get dynamic height&width info
  701. *
  702. * @param modelDesc [IN] model description
  703. * @param index [IN] input tensor index
  704. * @param hw [OUT] dynamic height&width info
  705. *
  706. * @retval ACL_SUCCESS The function is successfully executed.
  707. * @retval OtherValues Failure
  708. */
  709. ACL_FUNC_VISIBILITY aclError aclmdlGetDynamicHW(const aclmdlDesc *modelDesc, size_t index, aclmdlHW *hw);
  710. /**
  711. * @ingroup AscendCL
  712. * @brief get dynamic gear count
  713. *
  714. * @param modelDesc [IN] model description
  715. * @param index [IN] unused, must be -1
  716. * @param gearCount [OUT] dynamic gear count
  717. *
  718. * @retval ACL_SUCCESS The function is successfully executed.
  719. * @retval OtherValues Failure
  720. */
  721. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDynamicGearCount(const aclmdlDesc *modelDesc, size_t index,
  722. size_t *gearCount);
  723. /**
  724. * @ingroup AscendCL
  725. * @brief get dynamic dims info
  726. *
  727. * @param modelDesc [IN] model description
  728. * @param index [IN] unused, must be -1
  729. * @param dims [OUT] value of dynamic dims
  730. * @param gearCount [IN] dynamic gear count
  731. *
  732. * @retval ACL_SUCCESS The function is successfully executed.
  733. * @retval OtherValues Failure
  734. */
  735. ACL_FUNC_VISIBILITY aclError aclmdlGetInputDynamicDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims,
  736. size_t gearCount);
  737. /**
  738. * @ingroup AscendCL
  739. * @brief Create data of type aclmdlAIPP
  740. *
  741. * @param batchSize [IN] batchsizes of model
  742. *
  743. * @retval the aclmdlAIPP pointer
  744. */
  745. ACL_FUNC_VISIBILITY aclmdlAIPP *aclmdlCreateAIPP(uint64_t batchSize);
  746. /**
  747. * @ingroup AscendCL
  748. * @brief destroy data of type aclmdlAIPP
  749. *
  750. * @param aippParmsSet [IN] Pointer for aclmdlAIPP to be destroyed
  751. *
  752. * @retval ACL_SUCCESS The function is successfully executed.
  753. * @retval OtherValues Failure
  754. */
  755. ACL_FUNC_VISIBILITY aclError aclmdlDestroyAIPP(const aclmdlAIPP *aippParmsSet);
  756. /**
  757. * @ingroup AscendCL
  758. * @brief set InputFormat of type aclmdlAIPP
  759. *
  760. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  761. * @param inputFormat [IN] The inputFormat of aipp
  762. *
  763. * @retval ACL_SUCCESS The function is successfully executed.
  764. * @retval OtherValues Failure
  765. *
  766. * @see aclmdlCreateAIPP
  767. */
  768. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPInputFormat(aclmdlAIPP *aippParmsSet, aclAippInputFormat inputFormat);
  769. /**
  770. * @ingroup AscendCL
  771. * @brief set cscParms of type aclmdlAIPP
  772. *
  773. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  774. * @param csc_switch [IN] Csc switch
  775. * @param cscMatrixR0C0 [IN] Csc_matrix_r0_c0
  776. * @param cscMatrixR0C1 [IN] Csc_matrix_r0_c1
  777. * @param cscMatrixR0C2 [IN] Csc_matrix_r0_c2
  778. * @param cscMatrixR1C0 [IN] Csc_matrix_r1_c0
  779. * @param cscMatrixR1C1 [IN] Csc_matrix_r1_c1
  780. * @param cscMatrixR1C2 [IN] Csc_matrix_r1_c2
  781. * @param cscMatrixR2C0 [IN] Csc_matrix_r2_c0
  782. * @param cscMatrixR2C1 [IN] Csc_matrix_r2_c1
  783. * @param cscMatrixR2C2 [IN] Csc_matrix_r2_c2
  784. * @param cscOutputBiasR0 [IN] Output Bias for RGB to YUV, element of row 0, unsigned number
  785. * @param cscOutputBiasR1 [IN] Output Bias for RGB to YUV, element of row 1, unsigned number
  786. * @param cscOutputBiasR2 [IN] Output Bias for RGB to YUV, element of row 2, unsigned number
  787. * @param cscInputBiasR0 [IN] Input Bias for YUV to RGB, element of row 0, unsigned number
  788. * @param cscInputBiasR1 [IN] Input Bias for YUV to RGB, element of row 1, unsigned number
  789. * @param cscInputBiasR2 [IN] Input Bias for YUV to RGB, element of row 2, unsigned number
  790. *
  791. * @retval ACL_SUCCESS The function is successfully executed.
  792. * @retval OtherValues Failure
  793. *
  794. * @see aclmdlCreateAIPP
  795. */
  796. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPCscParams(aclmdlAIPP *aippParmsSet, int8_t csc_switch, int16_t cscMatrixR0C0,
  797. int16_t cscMatrixR0C1, int16_t cscMatrixR0C2, int16_t cscMatrixR1C0,
  798. int16_t cscMatrixR1C1, int16_t cscMatrixR1C2, int16_t cscMatrixR2C0,
  799. int16_t cscMatrixR2C1, int16_t cscMatrixR2C2,
  800. uint8_t cscOutputBiasR0, uint8_t cscOutputBiasR1,
  801. uint8_t cscOutputBiasR2, uint8_t cscInputBiasR0,
  802. uint8_t cscInputBiasR1, uint8_t cscInputBiasR2);
  803. /**
  804. * @ingroup AscendCL
  805. * @brief set rb/ub swap switch of type aclmdlAIPP
  806. *
  807. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  808. * @param rbuvSwapSwitch [IN] rb/ub swap switch
  809. *
  810. * @retval ACL_SUCCESS The function is successfully executed.
  811. * @retval OtherValues Failure
  812. *
  813. * @see aclmdlCreateAIPP
  814. */
  815. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPRbuvSwapSwitch(aclmdlAIPP *aippParmsSet, int8_t rbuvSwapSwitch);
  816. /**
  817. * @ingroup AscendCL
  818. * @brief set RGBA->ARGB, YUVA->AYUV swap switch of type aclmdlAIPP
  819. *
  820. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  821. * @param axSwapSwitch [IN] RGBA->ARGB, YUVA->AYUV swap switch
  822. *
  823. * @retval ACL_SUCCESS The function is successfully executed.
  824. * @retval OtherValues Failure
  825. *
  826. * @see aclmdlCreateAIPP
  827. */
  828. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPAxSwapSwitch(aclmdlAIPP *aippParmsSet, int8_t axSwapSwitch);
  829. /**
  830. * @ingroup AscendCL
  831. * @brief set source image of type aclmdlAIPP
  832. *
  833. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  834. * @param srcImageSizeW [IN] Source image width
  835. * @param srcImageSizeH [IN] Source image height
  836. *
  837. * @retval ACL_SUCCESS The function is successfully executed.
  838. * @retval OtherValues Failure
  839. *
  840. * @see aclmdlCreateAIPP
  841. */
  842. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPSrcImageSize(aclmdlAIPP *aippParmsSet, int32_t srcImageSizeW,
  843. int32_t srcImageSizeH);
  844. /**
  845. * @ingroup AscendCL
  846. * @brief set resize switch of type aclmdlAIPP
  847. *
  848. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  849. * @param scfSwitch [IN] Resize switch
  850. * @param scfInputSizeW [IN] Input width of scf
  851. * @param scfInputSizeH [IN] Input height of scf
  852. * @param scfOutputSizeW [IN] Output width of scf
  853. * @param scfOutputSizeH [IN] Output height of scf
  854. * @param batchIndex [IN] Batch parameter index
  855. *
  856. * @retval ACL_SUCCESS The function is successfully executed.
  857. * @retval OtherValues Failure
  858. *
  859. * @see aclmdlCreateAIPP
  860. */
  861. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPScfParams(aclmdlAIPP *aippParmsSet, int8_t scfSwitch, int32_t scfInputSizeW,
  862. int32_t scfInputSizeH, int32_t scfOutputSizeW,
  863. int32_t scfOutputSizeH, uint64_t batchIndex);
  864. /**
  865. * @ingroup AscendCL
  866. * @brief set cropParams of type aclmdlAIPP
  867. *
  868. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  869. * @param cropSwitch [IN] Crop switch
  870. * @param cropStartPosW [IN] The start horizontal position of cropping
  871. * @param cropStartPosH [IN] The start vertical position of cropping
  872. * @param cropSizeW [IN] Crop width
  873. * @param cropSizeH [IN] Crop height
  874. * @param batchIndex [IN] Batch parameter index
  875. *
  876. * @retval ACL_SUCCESS The function is successfully executed.
  877. * @retval OtherValues Failure
  878. *
  879. * @see aclmdlCreateAIPP
  880. */
  881. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPCropParams(aclmdlAIPP *aippParmsSet, int8_t cropSwitch, int32_t cropStartPosW,
  882. int32_t cropStartPosH, int32_t cropSizeW, int32_t cropSizeH,
  883. uint64_t batchIndex);
  884. /**
  885. * @ingroup AscendCL
  886. * @brief set paddingParams of type aclmdlAIPP
  887. *
  888. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  889. * @param paddingSwitch [IN] Padding switch
  890. * @param paddingSizeTop [IN] Top padding size
  891. * @param paddingSizeBottom [IN] Bottom padding size
  892. * @param paddingSizeLeft [IN] Left padding size
  893. * @param paddingSizeRight [IN] Right padding size
  894. * @param batchIndex [IN] Batch parameter index
  895. *
  896. * @retval ACL_SUCCESS The function is successfully executed.
  897. * @retval OtherValues Failure
  898. *
  899. * @see aclmdlCreateAIPP
  900. */
  901. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPPaddingParams(aclmdlAIPP *aippParmsSet, int8_t paddingSwitch,
  902. int32_t paddingSizeTop, int32_t paddingSizeBottom,
  903. int32_t paddingSizeLeft, int32_t paddingSizeRight,
  904. uint64_t batchIndex);
  905. /**
  906. * @ingroup AscendCL
  907. * @brief set DtcPixelMean of type aclmdlAIPP
  908. *
  909. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  910. * @param dtcPixelMeanChn0 [IN] Mean value of channel 0
  911. * @param dtcPixelMeanChn1 [IN] Mean value of channel 1
  912. * @param dtcPixelMeanChn2 [IN] Mean value of channel 2
  913. * @param dtcPixelMeanChn3 [IN] Mean value of channel 3
  914. * @param batchIndex [IN] Batch parameter index
  915. *
  916. * @retval ACL_SUCCESS The function is successfully executed.
  917. * @retval OtherValues Failure
  918. *
  919. * @see aclmdlCreateAIPP
  920. */
  921. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPDtcPixelMean(aclmdlAIPP *aippParmsSet, int16_t dtcPixelMeanChn0,
  922. int16_t dtcPixelMeanChn1, int16_t dtcPixelMeanChn2,
  923. int16_t dtcPixelMeanChn3, uint64_t batchIndex);
  924. /**
  925. * @ingroup AscendCL
  926. * @brief set DtcPixelMin of type aclmdlAIPP
  927. *
  928. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  929. * @param dtcPixelMinChn0 [IN] Min value of channel 0
  930. * @param dtcPixelMinChn1 [IN] Min value of channel 1
  931. * @param dtcPixelMinChn2 [IN] Min value of channel 2
  932. * @param dtcPixelMinChn3 [IN] Min value of channel 3
  933. * @param batchIndex [IN] Batch parameter index
  934. *
  935. * @retval ACL_SUCCESS The function is successfully executed.
  936. * @retval OtherValues Failure
  937. *
  938. * @see aclmdlCreateAIPP
  939. */
  940. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPDtcPixelMin(aclmdlAIPP *aippParmsSet, float dtcPixelMinChn0,
  941. float dtcPixelMinChn1, float dtcPixelMinChn2,
  942. float dtcPixelMinChn3, uint64_t batchIndex);
  943. /**
  944. * @ingroup AscendCL
  945. * @brief set PixelVarReci of type aclmdlAIPP
  946. *
  947. * @param aippParmsSet [OUT] Pointer for aclmdlAIPP
  948. * @param dtcPixelVarReciChn0 [IN] sfr_dtc_pixel_variance_reci_ch0
  949. * @param dtcPixelVarReciChn1 [IN] sfr_dtc_pixel_variance_reci_ch1
  950. * @param dtcPixelVarReciChn2 [IN] sfr_dtc_pixel_variance_reci_ch2
  951. * @param dtcPixelVarReciChn3 [IN] sfr_dtc_pixel_variance_reci_ch3
  952. * @param batchIndex [IN] Batch parameter index
  953. *
  954. * @retval ACL_SUCCESS The function is successfully executed.
  955. * @retval OtherValues Failure
  956. *
  957. * @see aclmdlCreateAIPP
  958. */
  959. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPPixelVarReci(aclmdlAIPP *aippParmsSet, float dtcPixelVarReciChn0,
  960. float dtcPixelVarReciChn1, float dtcPixelVarReciChn2,
  961. float dtcPixelVarReciChn3, uint64_t batchIndex);
  962. /**
  963. * @ingroup AscendCL
  964. * @brief set aipp parameters to model
  965. *
  966. * @param modelId [IN] model id
  967. * @param dataset [IN] Pointer of dataset
  968. * @param index [IN] index of input for aipp data(ACL_DYNAMIC_AIPP_NODE)
  969. * @param aippParmsSet [IN] Pointer for aclmdlAIPP
  970. *
  971. * @retval ACL_SUCCESS The function is successfully executed.
  972. * @retval OtherValues Failure
  973. *
  974. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  975. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
  976. */
  977. ACL_FUNC_VISIBILITY aclError aclmdlSetInputAIPP(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  978. const aclmdlAIPP *aippParmsSet);
  979. /**
  980. * @ingroup AscendCL
  981. * @brief set aipp parameters to model
  982. *
  983. * @param modelId [IN] model id
  984. * @param dataset [IN] Pointer of dataset
  985. * @param index [IN] index of input for data which linked dynamic aipp(ACL_DATA_WITH_DYNAMIC_AIPP)
  986. * @param aippParmsSet [IN] Pointer for aclmdlAIPP
  987. *
  988. * @retval ACL_SUCCESS The function is successfully executed.
  989. * @retval OtherValues Failure
  990. *
  991. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  992. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
  993. */
  994. ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPByInputIndex(uint32_t modelId, aclmdlDataset *dataset, size_t index,
  995. const aclmdlAIPP *aippParmsSet);
  996. /**
  997. * @ingroup AscendCL
  998. * @brief get input aipp type
  999. *
  1000. * @param modelId [IN] model id
  1001. * @param index [IN] index of input
  1002. * @param type [OUT] aipp type for input.refrer to aclmdlInputAippType(enum)
  1003. * @param dynamicAttachedDataIndex [OUT] index for dynamic attached data(ACL_DYNAMIC_AIPP_NODE)
  1004. * valid when type is ACL_DATA_WITH_DYNAMIC_AIPP, invalid value is ACL_INVALID_NODE_INDEX
  1005. *
  1006. * @retval ACL_SUCCESS The function is successfully executed.
  1007. * @retval OtherValues Failure
  1008. *
  1009. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  1010. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
  1011. */
  1012. ACL_FUNC_VISIBILITY aclError aclmdlGetAippType(uint32_t modelId, size_t index, aclmdlInputAippType *type,
  1013. size_t *dynamicAttachedDataIndex);
  1014. /**
  1015. * @ingroup AscendCL
  1016. * @brief get static aipp parameters from model
  1017. *
  1018. * @param modelId [IN] model id
  1019. * @param index [IN] index of tensor
  1020. * @param aippinfo [OUT] Pointer for static aipp info
  1021. *
  1022. * @retval ACL_SUCCESS The function is successfully executed.
  1023. * @retval ACL_ERROR_MODEL_AIPP_NOT_EXIST The tensor of index is not configured with aipp
  1024. * @retval OtherValues Failure
  1025. *
  1026. * @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
  1027. * aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
  1028. */
  1029. ACL_FUNC_VISIBILITY aclError aclmdlGetFirstAippInfo(uint32_t modelId, size_t index, aclAippInfo *aippinfo);
  1030. /**
  1031. * @ingroup AscendCL
  1032. * @brief get op description info
  1033. *
  1034. * @param deviceId [IN] device id
  1035. * @param streamId [IN] stream id
  1036. * @param taskId [IN] task id
  1037. * @param opName [OUT] pointer to op name
  1038. * @param opNameLen [IN] the length of op name
  1039. * @param inputDesc [OUT] pointer to input description
  1040. * @param numInputs [OUT] the number of input tensor
  1041. * @param outputDesc [OUT] pointer to output description
  1042. * @param numOutputs [OUT] the number of output tensor
  1043. *
  1044. * @retval ACL_SUCCESS The function is successfully executed
  1045. * @retval OtherValues Failure
  1046. */
  1047. ACL_FUNC_VISIBILITY aclError aclmdlCreateAndGetOpDesc(uint32_t deviceId, uint32_t streamId, uint32_t taskId,
  1048. char *opName, size_t opNameLen, aclTensorDesc **inputDesc,
  1049. size_t *numInputs, aclTensorDesc **outputDesc,
  1050. size_t *numOutputs);
  1051. /**
  1052. * @ingroup AscendCL
  1053. * @brief init dump
  1054. *
  1055. * @retval ACL_SUCCESS The function is successfully executed.
  1056. * @retval OtherValues Failure
  1057. */
  1058. ACL_FUNC_VISIBILITY aclError aclmdlInitDump();
  1059. /**
  1060. * @ingroup AscendCL
  1061. * @brief set param of dump
  1062. *
  1063. * @param dumpCfgPath [IN] the path of dump config
  1064. *
  1065. * @retval ACL_SUCCESS The function is successfully executed.
  1066. * @retval OtherValues Failure
  1067. */
  1068. ACL_FUNC_VISIBILITY aclError aclmdlSetDump(const char *dumpCfgPath);
  1069. /**
  1070. * @ingroup AscendCL
  1071. * @brief finalize dump.
  1072. *
  1073. * @retval ACL_SUCCESS The function is successfully executed.
  1074. * @retval OtherValues Failure
  1075. */
  1076. ACL_FUNC_VISIBILITY aclError aclmdlFinalizeDump();
  1077. /**
  1078. * @ingroup AscendCL
  1079. * @brief load model with config
  1080. *
  1081. * @param handle [IN] pointer to model config handle
  1082. * @param modelId [OUT] pointer to model id
  1083. *
  1084. * @retval ACL_SUCCESS The function is successfully executed.
  1085. * @retval OtherValues Failure
  1086. */
  1087. ACL_FUNC_VISIBILITY aclError aclmdlLoadWithConfig(const aclmdlConfigHandle *handle, uint32_t *modelId);
  1088. /**
  1089. * @ingroup AscendCL
  1090. * @brief create model config handle of type aclmdlConfigHandle
  1091. *
  1092. * @retval the aclmdlConfigHandle pointer
  1093. *
  1094. * @see aclmdlDestroyConfigHandle
  1095. */
  1096. ACL_FUNC_VISIBILITY aclmdlConfigHandle *aclmdlCreateConfigHandle();
  1097. /**
  1098. * @ingroup AscendCL
  1099. * @brief destroy data of type aclmdlConfigHandle
  1100. *
  1101. * @param handle [IN] pointer to model config handle
  1102. *
  1103. * @retval ACL_SUCCESS The function is successfully executed.
  1104. * @retval OtherValues Failure
  1105. *
  1106. * @see aclmdlCreateConfigHandle
  1107. */
  1108. ACL_FUNC_VISIBILITY aclError aclmdlDestroyConfigHandle(aclmdlConfigHandle *handle);
  1109. /**
  1110. * @ingroup AscendCL
  1111. * @brief set config for model load
  1112. *
  1113. * @param handle [OUT] pointer to model config handle
  1114. * @param attr [IN] config attr in model config handle to be set
  1115. * @param attrValue [IN] pointer to model config value
  1116. * @param valueSize [IN] memory size of attrValue
  1117. *
  1118. * @retval ACL_SUCCESS The function is successfully executed.
  1119. * @retval OtherValues Failure
  1120. */
  1121. ACL_FUNC_VISIBILITY aclError aclmdlSetConfigOpt(aclmdlConfigHandle *handle, aclmdlConfigAttr attr,
  1122. const void *attrValue, size_t valueSize);
  1123. /**
  1124. * @ingroup AscendCL
  1125. * @brief get real tensor name from modelDesc
  1126. *
  1127. * @param modelDesc [IN] pointer to modelDesc
  1128. * @param name [IN] tensor name
  1129. *
  1130. * @retval the pointer of real tensor name
  1131. * @retval Failure return NULL
  1132. */
  1133. ACL_FUNC_VISIBILITY const char *aclmdlGetTensorRealName(const aclmdlDesc *modelDesc, const char *name);
  1134. #ifdef __cplusplus
  1135. }
  1136. #endif
  1137. #endif // INC_EXTERNAL_ACL_ACL_MODEL_H_

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