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

acl_mdl.h 44 kB

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