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

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

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