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

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

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