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

acl_mdl.h 44 kB

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

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