You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

acl_mdl.h 42 kB

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