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

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

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