* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#ifndef INC_EXTERNAL_ACL_ACL_MODEL_H_
#define INC_EXTERNAL_ACL_ACL_MODEL_H_
#include <stddef.h>
#include <stdint.h>
#include "acl_base.h"
#include "acl_rt.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ACL_DIM_ENDPOINTS 2
#define ACL_MAX_DIM_CNT 128
#define ACL_MAX_TENSOR_NAME_LEN 128
#define ACL_MAX_BATCH_NUM 128
#define ACL_MAX_HW_NUM 128
#define ACL_MAX_SHAPE_COUNT 128
#define ACL_INVALID_NODE_INDEX 0xFFFFFFFF
#define ACL_MDL_LOAD_FROM_FILE 1
#define ACL_MDL_LOAD_FROM_FILE_WITH_MEM 2
#define ACL_MDL_LOAD_FROM_MEM 3
#define ACL_MDL_LOAD_FROM_MEM_WITH_MEM 4
#define ACL_MDL_LOAD_FROM_FILE_WITH_Q 5
#define ACL_MDL_LOAD_FROM_MEM_WITH_Q 6
#define ACL_DYNAMIC_TENSOR_NAME "ascend_mbatch_shape_data"
#define ACL_DYNAMIC_AIPP_NAME "ascend_dynamic_aipp_data"
#define ACL_ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES "_datadump_original_op_names"
#define ACL_WORKSPACE_MEM_OPTIMIZE_DEFAULT 0
#define ACL_WORKSPACE_MEM_OPTIMIZE_INPUTOUTPUT 1
#define ACL_MODEL_STREAM_FLAG_HEAD 0x00000000U
#define ACL_MODEL_STREAM_FLAG_DEFAULT 0x7FFFFFFFU
typedef struct aclmdlDataset aclmdlDataset;
typedef struct aclmdlDesc aclmdlDesc;
typedef struct aclmdlAIPP aclmdlAIPP;
typedef struct aclAippExtendInfo aclAippExtendInfo;
typedef struct aclmdlConfigHandle aclmdlConfigHandle;
typedef struct aclmdlExecConfigHandle aclmdlExecConfigHandle;
typedef struct aclmdlBundleQueryInfo aclmdlBundleQueryInfo;
typedef void* aclmdlModel;
typedef enum {
ACL_YUV420SP_U8 = 1,
ACL_XRGB8888_U8 = 2,
ACL_RGB888_U8 = 3,
ACL_YUV400_U8 = 4,
ACL_NC1HWC0DI_FP16 = 5,
ACL_NC1HWC0DI_S8 = 6,
ACL_ARGB8888_U8 = 7,
ACL_YUYV_U8 = 8,
ACL_YUV422SP_U8 = 9,
ACL_AYUV444_U8 = 10,
ACL_RAW10 = 11,
ACL_RAW12 = 12,
ACL_RAW16 = 13,
ACL_RAW24 = 14,
ACL_AIPP_RESERVED = 0xFFFF,
} aclAippInputFormat;
typedef enum {
ACL_MDL_PRIORITY_INT32 = 0,
ACL_MDL_LOAD_TYPE_SIZET,
ACL_MDL_PATH_PTR,
ACL_MDL_MEM_ADDR_PTR,
ACL_MDL_MEM_SIZET,
ACL_MDL_WEIGHT_ADDR_PTR,
ACL_MDL_WEIGHT_SIZET,
ACL_MDL_WORKSPACE_ADDR_PTR,
ACL_MDL_WORKSPACE_SIZET,
ACL_MDL_INPUTQ_NUM_SIZET,
ACL_MDL_INPUTQ_ADDR_PTR,
ACL_MDL_OUTPUTQ_NUM_SIZET,
ACL_MDL_OUTPUTQ_ADDR_PTR,
ACL_MDL_WORKSPACE_MEM_OPTIMIZE,
ACL_MDL_WEIGHT_PATH_PTR,
ACL_MDL_MODEL_DESC_PTR,
ACL_MDL_MODEL_DESC_SIZET,
ACL_MDL_KERNEL_PTR,
ACL_MDL_KERNEL_SIZET,
ACL_MDL_KERNEL_ARGS_PTR,
ACL_MDL_KERNEL_ARGS_SIZET,
ACL_MDL_STATIC_TASK_PTR,
ACL_MDL_STATIC_TASK_SIZET,
ACL_MDL_DYNAMIC_TASK_PTR,
ACL_MDL_DYNAMIC_TASK_SIZET,
ACL_MDL_MEM_MALLOC_POLICY_SIZET,
ACL_MDL_FIFO_PTR,
ACL_MDL_FIFO_SIZET,
ACL_MDL_WITHOUT_GRAPH_INT32,
ACL_NPU_PERF_MODE,
ACL_MDL_RESERVED = 0xFFFF
} aclmdlConfigAttr;
typedef enum {
ACL_MDL_STREAM_SYNC_TIMEOUT = 0,
ACL_MDL_EVENT_SYNC_TIMEOUT,
ACL_MDL_WORK_ADDR_PTR,
ACL_MDL_WORK_SIZET,
ACL_MDL_MPAIMID_SIZET,
ACL_MDL_AICQOS_SIZET,
ACL_MDL_AICOST_SIZET,
ACL_MDL_MEC_TIMETHR_SIZET,
ACL_MDL_EXEC_PRIORITY_INT32,
ACL_MDL_NPU_PERF_MODE
} aclmdlExecConfigAttr;
typedef enum {
ACL_DATA_WITHOUT_AIPP = 0,
ACL_DATA_WITH_STATIC_AIPP,
ACL_DATA_WITH_DYNAMIC_AIPP,
ACL_DYNAMIC_AIPP_NODE
} aclmdlInputAippType;
typedef struct aclmdlIODims {
char name[ACL_MAX_TENSOR_NAME_LEN];
size_t dimCount;
int64_t dims[ACL_MAX_DIM_CNT];
} aclmdlIODims;
typedef struct aclmdlIODimsRange {
size_t rangeCount;
int64_t range[ACL_MAX_DIM_CNT][ACL_DIM_ENDPOINTS];
} aclmdlIODimsRange;
typedef struct aclAippDims {
aclmdlIODims srcDims;
size_t srcSize;
aclmdlIODims aippOutdims;
size_t aippOutSize;
} aclAippDims;
typedef struct aclmdlBatch {
size_t batchCount;
uint64_t batch[ACL_MAX_BATCH_NUM];
} aclmdlBatch;
typedef struct aclmdlHW {
size_t hwCount;
uint64_t hw[ACL_MAX_HW_NUM][2];
} aclmdlHW;
typedef struct aclAippInfo {
aclAippInputFormat inputFormat;
int32_t srcImageSizeW;
int32_t srcImageSizeH;
int8_t cropSwitch;
int32_t loadStartPosW;
int32_t loadStartPosH;
int32_t cropSizeW;
int32_t cropSizeH;
int8_t resizeSwitch;
int32_t resizeOutputW;
int32_t resizeOutputH;
int8_t paddingSwitch;
int32_t leftPaddingSize;
int32_t rightPaddingSize;
int32_t topPaddingSize;
int32_t bottomPaddingSize;
int8_t cscSwitch;
int8_t rbuvSwapSwitch;
int8_t axSwapSwitch;
int8_t singleLineMode;
int32_t matrixR0C0;
int32_t matrixR0C1;
int32_t matrixR0C2;
int32_t matrixR1C0;
int32_t matrixR1C1;
int32_t matrixR1C2;
int32_t matrixR2C0;
int32_t matrixR2C1;
int32_t matrixR2C2;
int32_t outputBias0;
int32_t outputBias1;
int32_t outputBias2;
int32_t inputBias0;
int32_t inputBias1;
int32_t inputBias2;
int32_t meanChn0;
int32_t meanChn1;
int32_t meanChn2;
int32_t meanChn3;
float minChn0;
float minChn1;
float minChn2;
float minChn3;
float varReciChn0;
float varReciChn1;
float varReciChn2;
float varReciChn3;
aclFormat srcFormat;
aclDataType srcDatatype;
size_t srcDimNum;
size_t shapeCount;
aclAippDims outDims[ACL_MAX_SHAPE_COUNT];
aclAippExtendInfo *aippExtend;
} aclAippInfo;
typedef struct aclmdlExeOMDesc {
size_t workSize;
size_t weightSize;
size_t modelDescSize;
size_t kernelSize;
size_t kernelArgsSize;
size_t staticTaskSize;
size_t dynamicTaskSize;
size_t fifoTaskSize;
size_t reserved[8];
} aclmdlExeOMDesc;
* @ingroup AscendCL
* @brief Create data of type aclmdlDesc
*
* @retval the aclmdlDesc pointer
*/
ACL_FUNC_VISIBILITY aclmdlDesc *aclmdlCreateDesc();
* @ingroup AscendCL
* @brief destroy data of type aclmdlDesc
*
* @param modelDesc [IN] Pointer to almdldlDesc to be destroyed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlDestroyDesc(aclmdlDesc *modelDesc);
* @ingroup AscendCL
* @brief Get aclmdlDesc data of the model according to the model ID
*
* @param modelDesc [OUT] aclmdlDesc pointer
* @param modelId [IN] model id
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetDesc(aclmdlDesc *modelDesc, uint32_t modelId);
* @ingroup AscendCL
* @brief Get aclmdlDesc data of the model according to the model path
*
* @param modelDesc [OUT] aclmdlDesc pointer
* @param modelPath [IN] model path
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetDescFromFile(aclmdlDesc *modelDesc, const char *modelPath);
* @ingroup AscendCL
* @brief Get aclmdlDesc data of the model according to the model and modelSize
*
* @param modelDesc [OUT] aclmdlDesc pointer
* @param model [IN] model pointer
* @param modelSize [IN] model size
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetDescFromMem(aclmdlDesc *modelDesc, const void *model, size_t modelSize);
* @ingroup AscendCL
* @brief Get the number of the inputs of
* the model according to data of aclmdlDesc
*
* @param modelDesc [IN] aclmdlDesc pointer
*
* @retval input size with aclmdlDesc
*/
ACL_FUNC_VISIBILITY size_t aclmdlGetNumInputs(aclmdlDesc *modelDesc);
* @ingroup AscendCL
* @brief Get the number of the output of
* the model according to data of aclmdlDesc
*
* @param modelDesc [IN] aclmdlDesc pointer
*
* @retval output size with aclmdlDesc
*/
ACL_FUNC_VISIBILITY size_t aclmdlGetNumOutputs(aclmdlDesc *modelDesc);
* @ingroup AscendCL
* @brief Get the size of the specified input according to
* the data of type aclmdlDesc
*
* @param modelDesc [IN] aclmdlDesc pointer
* @param index [IN] the size of the number of inputs to be obtained,
* the index value starts from 0
*
* @retval Specify the size of the input
*/
ACL_FUNC_VISIBILITY size_t aclmdlGetInputSizeByIndex(aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief Get the size of the specified output according to
* the data of type aclmdlDesc
*
* @param modelDesc [IN] aclmdlDesc pointer
* @param index [IN] the size of the number of outputs to be obtained,
* the index value starts from 0
*
* @retval Specify the size of the output
*/
ACL_FUNC_VISIBILITY size_t aclmdlGetOutputSizeByIndex(aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief Create config handle of execute
*
* @retval the aclmdlCreateExecConfigHandle pointer
*/
ACL_FUNC_VISIBILITY aclmdlExecConfigHandle *aclmdlCreateExecConfigHandle();
* @ingroup AscendCL
* @brief Destroy config handle of model execute
*
* @param handle [IN] Pointer to aclmdlExecConfigHandle to be destroyed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlDestroyExecConfigHandle(const aclmdlExecConfigHandle *handle);
* @ingroup AscendCL
* @brief Create data of type aclmdlDataset
*
* @retval the aclmdlDataset pointer
*/
ACL_FUNC_VISIBILITY aclmdlDataset *aclmdlCreateDataset();
* @ingroup AscendCL
* @brief destroy data of type aclmdlDataset
*
* @param dataset [IN] Pointer to aclmdlDataset to be destroyed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlDestroyDataset(const aclmdlDataset *dataset);
* @ingroup AscendCL
* @brief Add aclDataBuffer to aclmdlDataset
*
* @param dataset [OUT] aclmdlDataset address of aclDataBuffer to be added
* @param dataBuffer [IN] aclDataBuffer address to be added
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlAddDatasetBuffer(aclmdlDataset *dataset, aclDataBuffer *dataBuffer);
* @ingroup AscendCL
* @brief Set aclTensorDesc to aclmdlDataset
*
* @param dataset [OUT] aclmdlDataset address of aclDataBuffer to be added
* @param tensorDesc [IN] aclTensorDesc address to be added
* @param index [IN] index of tensorDesc which to be added
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetDatasetTensorDesc(aclmdlDataset *dataset,
aclTensorDesc *tensorDesc,
size_t index);
* @ingroup AscendCL
* @brief Get aclTensorDesc from aclmdlDataset
*
* @param dataset [IN] aclmdlDataset pointer;
* @param index [IN] index of tensorDesc
*
* @retval Get address of aclTensorDesc when executed successfully.
* @retval Failure return NULL
*/
ACL_FUNC_VISIBILITY aclTensorDesc *aclmdlGetDatasetTensorDesc(const aclmdlDataset *dataset, size_t index);
* @ingroup AscendCL
* @brief Get the number of aclDataBuffer in aclmdlDataset
*
* @param dataset [IN] aclmdlDataset pointer
*
* @retval the number of aclDataBuffer
*/
ACL_FUNC_VISIBILITY size_t aclmdlGetDatasetNumBuffers(const aclmdlDataset *dataset);
* @ingroup AscendCL
* @brief Get the aclDataBuffer in aclmdlDataset by index
*
* @param dataset [IN] aclmdlDataset pointer
* @param index [IN] the index of aclDataBuffer
*
* @retval Get successfully, return the address of aclDataBuffer
* @retval Failure return NULL
*/
ACL_FUNC_VISIBILITY aclDataBuffer *aclmdlGetDatasetBuffer(const aclmdlDataset *dataset, size_t index);
* @ingroup AscendCL
* @brief Load offline model data from files
* and manage memory internally by the system
*
* @par Function
* After the system finishes loading the model,
* the model ID returned is used as a mark to identify the model
* during subsequent operations
*
* @param modelPath [IN] Storage path for offline model files
* @param modelId [OUT] Model ID generated after
* the system finishes loading the model
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFile(const char *modelPath, uint32_t *modelId);
* @ingroup AscendCL
* @brief Load offline bundle model data from file
* and manage memory internally by the system
*
* @par Function
* After the system finishes loading the bundle model,
* the bundle model ID returned is used as a mark to identify the bundle model
* during subsequent operations
*
* @param modelPath [IN] Storage path for offline bundle model file
* @param bundleId [OUT] Bundle model id generated
* the system finishes loading the bundle model
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleLoadFromFile(const char *modelPath, uint32_t *bundleId);
* @ingroup AscendCL
* @brief Load offline bundle model data from memory and manage the memory of
* model running internally by the system
*
* @par Function
* After the system finishes loading the bundle model,
* the bundle model ID returned is used as a mark to identify the bundle model
* during subsequent operations
*
* @param model [IN] Bundle model data stored in memory
* @param modelSize [IN] model data size
* @param bundleId [OUT] Bundle model id generated
* the system finishes loading the model
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleLoadFromMem(const void *model, size_t modelSize, uint32_t *bundleId);
* @ingroup AscendCL
* @brief unload bundle model with bundle model id
*
* @param bundleId [IN] bundle model id to be unloaded
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleUnload(uint32_t bundleId);
* @ingroup AscendCL
* @brief get bundle model inner model nums
*
* @param bundleId [IN] bundle id acquired by aclmdlBundleLoadFromFile or aclmdlBundleLoadFromMem
* @param modelNum [OUT] the pointer to model num
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleGetModelNum(uint32_t bundleId, size_t *modelNum);
* @ingroup AscendCL
* @brief get inner model id by index
*
* @param bundleId [IN] bundle id acquired by aclmdlBundleLoadFromFile or aclmdlBundleLoadFromMem
* @param index [IN] index of bundle models
* @param modelId [OUT] the pointer to inner model id which to be executed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleGetModelId(uint32_t bundleId, size_t index, uint32_t *modelId);
* @ingroup AscendCL
* @brief Create data of type aclmdlBundleQueryInfo
*
* @retval the aclmdlBundleQueryInfo pointer
*/
ACL_FUNC_VISIBILITY aclmdlBundleQueryInfo *aclmdlBundleCreateQueryInfo();
* @ingroup AscendCL
* @brief destroy data of type aclmdlBundleQueryInfo
*
* @param modelDesc [IN] Pointer to aclmdlBundleQueryInfo to be destroyed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleDestroyQueryInfo(aclmdlBundleQueryInfo *queryInfo);
* @ingroup AscendCL
* @brief Get the bundle om query info
*
* @param fileName [IN] Model path to get memory information
* @param queryInfo [OUT] The aclmdlBundleQueryInfo struct which is acquired by aclmdlBundleCreateQueryInfo
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleQueryInfoFromFile(const char* fileName, aclmdlBundleQueryInfo *queryInfo);
* @ingroup AscendCL
* @brief Get the bundle om query info
*
* @param model [IN] model memory which user manages
* @param modelSize [IN] model data size
* @param queryInfo [OUT] The aclmdlBundleQueryInfo struct which is acquired by aclmdlBundleCreateQueryInfo
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleQueryInfoFromMem(const void *model, size_t modelSize,
aclmdlBundleQueryInfo *queryInfo);
* @ingroup AscendCL
* @brief Get the bundle om inner model num
*
* @param queryInfo [IN] The aclmdlBundleQueryInfo struct which is acquired by aclmdlBundleQueryInfoFromXX
* @param modelNum [OUT] the pointer to model num
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleGetQueryModelNum(const aclmdlBundleQueryInfo *queryInfo, size_t *modelNum);
* @ingroup AscendCL
* @brief Get the bundle om variable weight size
*
* @param queryInfo [IN] The aclmdlBundleQueryInfo struct which is acquired by aclmdlBundleQueryInfoFromXX
* @param variableWeightSize [OUT] the pointer to variable weight size
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleGetVarWeightSize(const aclmdlBundleQueryInfo *queryInfo,
size_t *variableWeightSize);
* @ingroup AscendCL
* @brief Get the bundle inner sub om workSize and weightSize
*
* @param queryInfo [IN] The aclmdlBundleQueryInfo struct which is acquired by aclmdlBundleQueryInfoFromXX
* @param index [IN] The inner model index
* @param workSize [OUT] The amount of working memory for model executed
* @param constWeightSize [OUT] The amount of weight memory for model executed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleGetSize(const aclmdlBundleQueryInfo *queryInfo, size_t index,
size_t *workSize, size_t *constWeightSize);
* @ingroup AscendCL
* @brief init bundle model data from file
*
* @par Function
* After the system finishes loading the bundle model,
* the bundle model ID returned is used as a mark to identify the bundle model
* during subsequent operations
*
* @param modelPath [IN] Storage path for offline bundle model file
* @param varWeightPtr [IN] the pointer to varWeight, can be null
* @param varWeightSize [IN] varWeightSize
* @param bundleId [OUT] Bundle model id generated
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleInitFromFile(const char* modelPath, void *varWeightPtr,
size_t varWeightSize, uint32_t *bundleId);
* @ingroup AscendCL
* @brief init bundle model data from mem
*
* @par Function
* After the system finishes loading the bundle model,
* the bundle model ID returned is used as a mark to identify the bundle model
* during subsequent operations
*
* @param model [IN] model memory which user manages
* @param modelSize [IN] model data size
* @param varWeightPtr [IN] the pointer to varWeight, can be null
* @param varWeightSize [IN] varWeightSize
* @param bundleId [OUT] Bundle model id generated
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleInitFromMem(const void* model, size_t modelSize, void *varWeightPtr,
size_t varWeightSize, uint32_t *bundleId);
* @ingroup AscendCL
* @brief Load model by index in bundle model
*
* @param bundleId [IN] Bundle model id generated
* @param index [IN] Bundle om inner model index
* @param modelId [OUT] inner model id loaded which can be executed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleLoadModel(uint32_t bundleId, size_t index, uint32_t *modelId);
* @ingroup AscendCL
* @brief Load model by index in bundle model with mem
*
* @param bundleId [IN] Bundle model id generated
* @param index [IN] Bundle om inner model index
* @param workPtr [IN] A pointer to the working memory
* required by the model on the Device,can be null
* @param workSize [IN] work memory size
* @param weightPtr [IN] Pointer to model weight memory on Device,can be null
* @param weightSize [IN] The amount of weight memory required by the model
* @param modelId [OUT] inner model id loaded which can be executed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleLoadModelWithMem(uint32_t bundleId, size_t index, void *workPtr,
size_t workSize, void *weightPtr,
size_t weightSize, uint32_t *modelId);
* @ingroup AscendCL
* @brief Load model by index in bundle model with config
*
* @param bundleId [IN] Bundle model id generated
* @param index [IN] Bundle om inner model index
* @param handle [IN] pointer to model config handle
* @param modelId [OUT] inner model id loaded which can be executed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleLoadModelWithConfig(uint32_t bundleId, size_t index,
aclmdlConfigHandle *handle, uint32_t *modelId);
* @ingroup AscendCL
* @brief unload bundle inner model with model id
*
* @param bundleId [IN] Bundle model id generated
* @param modelId [IN] inner model id to be unloaded
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlBundleUnloadModel(uint32_t bundleId, uint32_t modelId);
* @ingroup AscendCL
* @brief Load offline model data from memory and manage the memory of
* model running internally by the system
*
* @par Function
* After the system finishes loading the model,
* the model ID returned is used as a mark to identify the model
* during subsequent operations
*
* @param model [IN] Model data stored in memory
* @param modelSize [IN] model data size
* @param modelId [OUT] Model ID generated after
* the system finishes loading the model
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMem(const void *model, size_t modelSize, uint32_t *modelId);
* @ingroup AscendCL
* @brief Load offline model data from a file,
* and the user manages the memory of the model run by itself
*
* @par Function
* After the system finishes loading the model,
* the model ID returned is used as a mark to identify the model
* during subsequent operations.
* @param modelPath [IN] Storage path for offline model files
* @param modelId [OUT] Model ID generated after finishes loading the model
* @param workPtr [IN] A pointer to the working memory
* required by the model on the Device,can be null
* @param workSize [IN] The amount of working memory required by the model
* @param weightPtr [IN] Pointer to model weight memory on Device
* @param weightSize [IN] The amount of weight memory required by the model
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFileWithMem(const char *modelPath,
uint32_t *modelId, void *workPtr, size_t workSize,
void *weightPtr, size_t weightSize);
* @ingroup AscendCL
* @brief Load offline model data from memory,
* and the user can manage the memory of model running
*
* @par Function
* After the system finishes loading the model,
* the model ID returned is used as a mark to identify the model
* during subsequent operations
* @param model [IN] Model data stored in memory
* @param modelSize [IN] model data size
* @param modelId [OUT] Model ID generated after finishes loading the model
* @param workPtr [IN] A pointer to the working memory
* required by the model on the Device,can be null
* @param workSize [IN] work memory size
* @param weightPtr [IN] Pointer to model weight memory on Device,can be null
* @param weightSize [IN] The amount of weight memory required by the model
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMemWithMem(const void *model, size_t modelSize,
uint32_t *modelId, void *workPtr, size_t workSize,
void *weightPtr, size_t weightSize);
* @ingroup AscendCL
* @brief load model from file with async queue
*
* @param modelPath [IN] model path
* @param modelId [OUT] return model id if load success
* @param inputQ [IN] input queue pointer
* @param inputQNum [IN] input queue num
* @param outputQ [IN] output queue pointer
* @param outputQNum [IN] output queue num
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFileWithQ(const char *modelPath, uint32_t *modelId, const uint32_t *inputQ,
size_t inputQNum, const uint32_t *outputQ, size_t outputQNum);
* @ingroup AscendCL
* @brief load model from memory with async queue
*
* @param model [IN] model memory which user manages
* @param modelSize [IN] model size
* @param modelId [OUT] return model id if load success
* @param inputQ [IN] input queue pointer
* @param inputQNum [IN] input queue num
* @param outputQ [IN] output queue pointer
* @param outputQNum [IN] output queue num
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadFromMemWithQ(const void *model, size_t modelSize, uint32_t *modelId,
const uint32_t *inputQ, size_t inputQNum,
const uint32_t *outputQ, size_t outputQNum);
* @ingroup AscendCL
* @brief Execute model synchronous inference until the inference result is returned
*
* @param modelId [IN] ID of the model to perform inference
* @param input [IN] Input data for model inference
* @param output [OUT] Output data for model inference
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlExecute(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output);
* @ingroup AscendCL
* @brief Execute model synchronous inference until the inference result is returned
*
* @param modelId [IN] ID of the model to perform inference
* @param input [IN] Input data for model inference
* @param output [OUT] Output data for model inference
* @param stream [IN] stream
* @param handle [IN] config of model execute
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlExecuteV2(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output,
aclrtStream stream, const aclmdlExecConfigHandle *handle);
* @ingroup AscendCL
* @brief Execute model asynchronous inference until the inference result is returned
*
* @param modelId [IN] ID of the model to perform inference
* @param input [IN] Input data for model inference
* @param output [OUT] Output data for model inference
* @param stream [IN] stream
* @param handle [IN] config of model execute
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlExecuteAsyncV2(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output,
aclrtStream stream, const aclmdlExecConfigHandle *handle);
* @ingroup AscendCL
* @brief Execute model asynchronous inference until the inference result is returned
*
* @param modelId [IN] ID of the model to perform inference
* @param input [IN] Input data for model inference
* @param output [OUT] Output data for model inference
* @param stream [IN] stream
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem
*/
ACL_FUNC_VISIBILITY aclError aclmdlExecuteAsync(uint32_t modelId, const aclmdlDataset *input,
aclmdlDataset *output, aclrtStream stream);
* @ingroup AscendCL
* @brief unload model with model id
*
* @param modelId [IN] model id to be unloaded
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlUnload(uint32_t modelId);
* @ingroup AscendCL
* @brief Get the weight memory size and working memory size
* required for model execution according to the model file
*
* @param fileName [IN] Model path to get memory information
* @param workSize [OUT] The amount of working memory for model executed
* @param weightSize [OUT] The amount of weight memory for model executed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize);
* @ingroup AscendCL
* @brief Get the size of each partition and working memory size
* required for model execution according to the model file
*
* @param fileName [IN] Model path to get memory information
* @param aclmdlExeOMDesc [OUT] The size of each partition and working memory size
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlQueryExeOMDesc(const char *fileName, aclmdlExeOMDesc *mdlPartitionSize);
* @ingroup AscendCL
* @brief Obtain the weights required for
* model execution according to the model data in memory
*
* @par Restriction
* The execution and weight memory is Device memory,
* and requires user application and release.
* @param model [IN] model memory which user manages
* @param modelSize [IN] model data size
* @param workSize [OUT] The amount of working memory for model executed
* @param weightSize [OUT] The amount of weight memory for model executed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlQuerySizeFromMem(const void *model, size_t modelSize, size_t *workSize,
size_t *weightSize);
* @ingroup AscendCL
* @brief In dynamic batch scenarios,
* it is used to set the number of images processed
* at one time during model inference
*
* @param modelId [IN] model id
* @param dataset [IN|OUT] data for model inference
* @param index [IN] index of dynamic tensor
* @param batchSize [IN] Number of images processed at a time during model
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetDynamicBatchSize(uint32_t modelId, aclmdlDataset *dataset, size_t index,
uint64_t batchSize);
* @ingroup AscendCL
* @brief Sets the H and W of the specified input of the model
*
* @param modelId [IN] model id
* @param dataset [IN|OUT] data for model inference
* @param index [IN] index of dynamic tensor
* @param height [IN] model height
* @param width [IN] model width
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetDynamicHWSize(uint32_t modelId, aclmdlDataset *dataset, size_t index,
uint64_t height, uint64_t width);
* @ingroup AscendCL
* @brief Sets the dynamic dims of the specified input of the model
*
* @param modelId [IN] model id
* @param dataset [IN|OUT] data for model inference
* @param index [IN] index of dynamic dims
* @param dims [IN] value of dynamic dims
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetInputDynamicDims(uint32_t modelId, aclmdlDataset *dataset, size_t index,
const aclmdlIODims *dims);
* @ingroup AscendCL
* @brief get input dims info
*
* @param modelDesc [IN] model description
* @param index [IN] input tensor index
* @param dims [OUT] dims info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlGetInputDimsV2
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetInputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
* @ingroup AscendCL
* @brief get input dims info(version 2), especially for static aipp
* it is the same with aclmdlGetInputDims while model without static aipp
*
* @param modelDesc [IN] model description
* @param index [IN] input tensor index
* @param dims [OUT] dims info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlGetInputDims
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetInputDimsV2(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
* @ingroup AscendCL
* @brief get input dims range info
*
* @param modelDesc [IN] model description
* @param index [IN] input tensor index
* @param dimsRange [OUT] dims range info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetInputDimsRange(const aclmdlDesc *modelDesc, size_t index,
aclmdlIODimsRange *dimsRange);
* @ingroup AscendCL
* @brief get output dims info
*
* @param modelDesc [IN] model description
* @param index [IN] output tensor index
* @param dims [OUT] dims info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
* @ingroup AscendCL
* @brief get current output dims info
*
* @par Function
* The following use cases are supported:
* @li Get current output shape when model is dynamic and
* dynamic shape info is set
* @li Get max output shape when model is dynamic and
* dynamic shape info is not set
* @li Get actual output shape when model is static
*
* @param modelDesc [IN] model description
* @param index [IN] output tensor index
* @param dims [OUT] dims info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetCurOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
* @ingroup AscendCL
* @brief get attr value by op name
*
* @param modelDesc [IN] model description
* @param opName [IN] op name
* @param attr [IN] attr name
*
* @retval the attr value
*/
ACL_FUNC_VISIBILITY const char *aclmdlGetOpAttr(aclmdlDesc *modelDesc, const char *opName, const char *attr);
* @ingroup AscendCL
* @brief get input name by index
*
* @param modelDesc [IN] model description
* @param index [IN] input tensor index
*
* @retval input tensor name,the same life cycle with modelDesc
*/
ACL_FUNC_VISIBILITY const char *aclmdlGetInputNameByIndex(const aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief get output name by index
*
* @param modelDesc [IN] model description
* @param index [IN] output tensor index
*
* @retval output tensor name,the same life cycle with modelDesc
*/
ACL_FUNC_VISIBILITY const char *aclmdlGetOutputNameByIndex(const aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief get input format by index
*
* @param modelDesc [IN] model description
* @param index [IN] input tensor index
*
* @retval input tensor format
*/
ACL_FUNC_VISIBILITY aclFormat aclmdlGetInputFormat(const aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief get output format by index
*
* @param modelDesc [IN] model description
* @param index [IN] output tensor index
*
* @retval output tensor format
*/
ACL_FUNC_VISIBILITY aclFormat aclmdlGetOutputFormat(const aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief get input data type by index
*
* @param modelDesc [IN] model description
* @param index [IN] input tensor index
*
* @retval input tensor data type
*/
ACL_FUNC_VISIBILITY aclDataType aclmdlGetInputDataType(const aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief get output data type by index
*
* @param modelDesc [IN] model description
* @param index [IN] output tensor index
*
* @retval output tensor data type
*/
ACL_FUNC_VISIBILITY aclDataType aclmdlGetOutputDataType(const aclmdlDesc *modelDesc, size_t index);
* @ingroup AscendCL
* @brief get input tensor index by name
*
* @param modelDesc [IN] model description
* @param name [IN] input tensor name
* @param index [OUT] input tensor index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetInputIndexByName(const aclmdlDesc *modelDesc, const char *name, size_t *index);
* @ingroup AscendCL
* @brief get output tensor index by name
*
* @param modelDesc [IN] model description
* @param name [IN] output tensor name
* @param index [OUT] output tensor index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetOutputIndexByName(const aclmdlDesc *modelDesc, const char *name, size_t *index);
* @ingroup AscendCL
* @brief get dynamic batch info
*
* @param modelDesc [IN] model description
* @param batch [OUT] dynamic batch info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetDynamicBatch(const aclmdlDesc *modelDesc, aclmdlBatch *batch);
* @ingroup AscendCL
* @brief get dynamic height&width info
*
* @param modelDesc [IN] model description
* @param index [IN] input tensor index
* @param hw [OUT] dynamic height&width info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetDynamicHW(const aclmdlDesc *modelDesc, size_t index, aclmdlHW *hw);
* @ingroup AscendCL
* @brief get dynamic gear count
*
* @param modelDesc [IN] model description
* @param index [IN] unused, must be -1
* @param gearCount [OUT] dynamic gear count
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetInputDynamicGearCount(const aclmdlDesc *modelDesc, size_t index,
size_t *gearCount);
* @ingroup AscendCL
* @brief get dynamic dims info
*
* @param modelDesc [IN] model description
* @param index [IN] unused, must be -1
* @param dims [OUT] value of dynamic dims
* @param gearCount [IN] dynamic gear count
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetInputDynamicDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims,
size_t gearCount);
* @ingroup AscendCL
* @brief Create data of type aclmdlAIPP
*
* @param batchSize [IN] batchsizes of model
*
* @retval the aclmdlAIPP pointer
*/
ACL_FUNC_VISIBILITY aclmdlAIPP *aclmdlCreateAIPP(uint64_t batchSize);
* @ingroup AscendCL
* @brief destroy data of type aclmdlAIPP
*
* @param aippParmsSet [IN] Pointer for aclmdlAIPP to be destroyed
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlDestroyAIPP(const aclmdlAIPP *aippParmsSet);
* @ingroup AscendCL
* @brief Get dynamic aipp data need size according to batchSize
*
* @param batchSize [IN] batchsizes of model
* @param size [OUT] Pointer of aipp data need size according to batchSize
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetAippDataSize(uint64_t batchSize, size_t *size);
* @ingroup AscendCL
* @brief set InputFormat of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param inputFormat [IN] The inputFormat of aipp
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPInputFormat(aclmdlAIPP *aippParmsSet, aclAippInputFormat inputFormat);
* @ingroup AscendCL
* @brief set cscParms of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param csc_switch [IN] Csc switch
* @param cscMatrixR0C0 [IN] Csc_matrix_r0_c0
* @param cscMatrixR0C1 [IN] Csc_matrix_r0_c1
* @param cscMatrixR0C2 [IN] Csc_matrix_r0_c2
* @param cscMatrixR1C0 [IN] Csc_matrix_r1_c0
* @param cscMatrixR1C1 [IN] Csc_matrix_r1_c1
* @param cscMatrixR1C2 [IN] Csc_matrix_r1_c2
* @param cscMatrixR2C0 [IN] Csc_matrix_r2_c0
* @param cscMatrixR2C1 [IN] Csc_matrix_r2_c1
* @param cscMatrixR2C2 [IN] Csc_matrix_r2_c2
* @param cscOutputBiasR0 [IN] Output Bias for RGB to YUV, element of row 0, unsigned number
* @param cscOutputBiasR1 [IN] Output Bias for RGB to YUV, element of row 1, unsigned number
* @param cscOutputBiasR2 [IN] Output Bias for RGB to YUV, element of row 2, unsigned number
* @param cscInputBiasR0 [IN] Input Bias for YUV to RGB, element of row 0, unsigned number
* @param cscInputBiasR1 [IN] Input Bias for YUV to RGB, element of row 1, unsigned number
* @param cscInputBiasR2 [IN] Input Bias for YUV to RGB, element of row 2, unsigned number
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPCscParams(aclmdlAIPP *aippParmsSet, int8_t cscSwitch,
int16_t cscMatrixR0C0, int16_t cscMatrixR0C1, int16_t cscMatrixR0C2,
int16_t cscMatrixR1C0, int16_t cscMatrixR1C1, int16_t cscMatrixR1C2,
int16_t cscMatrixR2C0, int16_t cscMatrixR2C1, int16_t cscMatrixR2C2,
uint8_t cscOutputBiasR0, uint8_t cscOutputBiasR1,
uint8_t cscOutputBiasR2, uint8_t cscInputBiasR0,
uint8_t cscInputBiasR1, uint8_t cscInputBiasR2);
* @ingroup AscendCL
* @brief set rb/ub swap switch of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param rbuvSwapSwitch [IN] rb/ub swap switch
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPRbuvSwapSwitch(aclmdlAIPP *aippParmsSet, int8_t rbuvSwapSwitch);
* @ingroup AscendCL
* @brief set RGBA->ARGB, YUVA->AYUV swap switch of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param axSwapSwitch [IN] RGBA->ARGB, YUVA->AYUV swap switch
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPAxSwapSwitch(aclmdlAIPP *aippParmsSet, int8_t axSwapSwitch);
* @ingroup AscendCL
* @brief set source image of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param srcImageSizeW [IN] Source image width
* @param srcImageSizeH [IN] Source image height
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPSrcImageSize(aclmdlAIPP *aippParmsSet, int32_t srcImageSizeW,
int32_t srcImageSizeH);
* @ingroup AscendCL
* @brief set resize switch of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param scfSwitch [IN] Resize switch
* @param scfInputSizeW [IN] Input width of scf
* @param scfInputSizeH [IN] Input height of scf
* @param scfOutputSizeW [IN] Output width of scf
* @param scfOutputSizeH [IN] Output height of scf
* @param batchIndex [IN] Batch parameter index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPScfParams(aclmdlAIPP *aippParmsSet,
int8_t scfSwitch,
int32_t scfInputSizeW,
int32_t scfInputSizeH,
int32_t scfOutputSizeW,
int32_t scfOutputSizeH,
uint64_t batchIndex);
* @ingroup AscendCL
* @brief set cropParams of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param cropSwitch [IN] Crop switch
* @param cropStartPosW [IN] The start horizontal position of cropping
* @param cropStartPosH [IN] The start vertical position of cropping
* @param cropSizeW [IN] Crop width
* @param cropSizeH [IN] Crop height
* @param batchIndex [IN] Batch parameter index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPCropParams(aclmdlAIPP *aippParmsSet,
int8_t cropSwitch,
int32_t cropStartPosW,
int32_t cropStartPosH,
int32_t cropSizeW,
int32_t cropSizeH,
uint64_t batchIndex);
* @ingroup AscendCL
* @brief set paddingParams of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param paddingSwitch [IN] Padding switch
* @param paddingSizeTop [IN] Top padding size
* @param paddingSizeBottom [IN] Bottom padding size
* @param paddingSizeLeft [IN] Left padding size
* @param paddingSizeRight [IN] Right padding size
* @param batchIndex [IN] Batch parameter index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPPaddingParams(aclmdlAIPP *aippParmsSet, int8_t paddingSwitch,
int32_t paddingSizeTop, int32_t paddingSizeBottom,
int32_t paddingSizeLeft, int32_t paddingSizeRight,
uint64_t batchIndex);
* @ingroup AscendCL
* @brief set DtcPixelMean of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param dtcPixelMeanChn0 [IN] Mean value of channel 0
* @param dtcPixelMeanChn1 [IN] Mean value of channel 1
* @param dtcPixelMeanChn2 [IN] Mean value of channel 2
* @param dtcPixelMeanChn3 [IN] Mean value of channel 3
* @param batchIndex [IN] Batch parameter index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPDtcPixelMean(aclmdlAIPP *aippParmsSet,
int16_t dtcPixelMeanChn0,
int16_t dtcPixelMeanChn1,
int16_t dtcPixelMeanChn2,
int16_t dtcPixelMeanChn3,
uint64_t batchIndex);
* @ingroup AscendCL
* @brief set DtcPixelMin of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param dtcPixelMinChn0 [IN] Min value of channel 0
* @param dtcPixelMinChn1 [IN] Min value of channel 1
* @param dtcPixelMinChn2 [IN] Min value of channel 2
* @param dtcPixelMinChn3 [IN] Min value of channel 3
* @param batchIndex [IN] Batch parameter index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPDtcPixelMin(aclmdlAIPP *aippParmsSet,
float dtcPixelMinChn0,
float dtcPixelMinChn1,
float dtcPixelMinChn2,
float dtcPixelMinChn3,
uint64_t batchIndex);
* @ingroup AscendCL
* @brief set PixelVarReci of type aclmdlAIPP
*
* @param aippParmsSet [OUT] Pointer for aclmdlAIPP
* @param dtcPixelVarReciChn0 [IN] sfr_dtc_pixel_variance_reci_ch0
* @param dtcPixelVarReciChn1 [IN] sfr_dtc_pixel_variance_reci_ch1
* @param dtcPixelVarReciChn2 [IN] sfr_dtc_pixel_variance_reci_ch2
* @param dtcPixelVarReciChn3 [IN] sfr_dtc_pixel_variance_reci_ch3
* @param batchIndex [IN] Batch parameter index
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPPixelVarReci(aclmdlAIPP *aippParmsSet,
float dtcPixelVarReciChn0,
float dtcPixelVarReciChn1,
float dtcPixelVarReciChn2,
float dtcPixelVarReciChn3,
uint64_t batchIndex);
* @ingroup AscendCL
* @brief set aipp parameters to model
*
* @param modelId [IN] model id
* @param dataset [IN] Pointer of dataset
* @param index [IN] index of input for aipp data(ACL_DYNAMIC_AIPP_NODE)
* @param aippParmsSet [IN] Pointer for aclmdlAIPP
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetInputAIPP(uint32_t modelId,
aclmdlDataset *dataset,
size_t index,
const aclmdlAIPP *aippParmsSet);
* @ingroup AscendCL
* @brief set aipp parameters to model
*
* @param modelId [IN] model id
* @param dataset [IN] Pointer of dataset
* @param index [IN] index of input for data which linked dynamic aipp(ACL_DATA_WITH_DYNAMIC_AIPP)
* @param aippParmsSet [IN] Pointer for aclmdlAIPP
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPByInputIndex(uint32_t modelId,
aclmdlDataset *dataset,
size_t index,
const aclmdlAIPP *aippParmsSet);
* @ingroup AscendCL
* @brief get input aipp type
*
* @param modelId [IN] model id
* @param index [IN] index of input
* @param type [OUT] aipp type for input.refrer to aclmdlInputAippType(enum)
* @param dynamicAttachedDataIndex [OUT] index for dynamic attached data(ACL_DYNAMIC_AIPP_NODE)
* valid when type is ACL_DATA_WITH_DYNAMIC_AIPP, invalid value is ACL_INVALID_NODE_INDEX
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName | aclmdlCreateAIPP
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetAippType(uint32_t modelId,
size_t index,
aclmdlInputAippType *type,
size_t *dynamicAttachedDataIndex);
* @ingroup AscendCL
* @brief get static aipp parameters from model
*
* @param modelId [IN] model id
* @param index [IN] index of tensor
* @param aippInfo [OUT] Pointer for static aipp info
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval ACL_ERROR_MODEL_AIPP_NOT_EXIST The tensor of index is not configured with aipp
* @retval OtherValues Failure
*
* @see aclmdlLoadFromFile | aclmdlLoadFromMem | aclmdlLoadFromFileWithMem |
* aclmdlLoadFromMemWithMem | aclmdlGetInputIndexByName
*/
ACL_FUNC_VISIBILITY aclError aclmdlGetFirstAippInfo(uint32_t modelId, size_t index, aclAippInfo *aippInfo);
* @ingroup AscendCL
* @brief get op description info
*
* @param deviceId [IN] device id
* @param streamId [IN] stream id
* @param taskId [IN] task id
* @param opName [OUT] pointer to op name
* @param opNameLen [IN] the length of op name
* @param inputDesc [OUT] pointer to input description
* @param numInputs [OUT] the number of input tensor
* @param outputDesc [OUT] pointer to output description
* @param numOutputs [OUT] the number of output tensor
*
* @retval ACL_SUCCESS The function is successfully executed
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlCreateAndGetOpDesc(uint32_t deviceId, uint32_t streamId,
uint32_t taskId, char *opName, size_t opNameLen, aclTensorDesc **inputDesc, size_t *numInputs,
aclTensorDesc **outputDesc, size_t *numOutputs);
* @ingroup AscendCL
* @brief load model with config
*
* @param handle [IN] pointer to model config handle
* @param modelId [OUT] pointer to model id
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadWithConfig(const aclmdlConfigHandle *handle, uint32_t *modelId);
* @ingroup AscendCL
* @brief create model config handle of type aclmdlConfigHandle
*
* @retval the aclmdlConfigHandle pointer
*
* @see aclmdlDestroyConfigHandle
*/
ACL_FUNC_VISIBILITY aclmdlConfigHandle *aclmdlCreateConfigHandle();
* @ingroup AscendCL
* @brief destroy data of type aclmdlConfigHandle
*
* @param handle [IN] pointer to model config handle
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclmdlCreateConfigHandle
*/
ACL_FUNC_VISIBILITY aclError aclmdlDestroyConfigHandle(aclmdlConfigHandle *handle);
* @ingroup AscendCL
* @brief set config for model load
*
* @param handle [OUT] pointer to model config handle
* @param attr [IN] config attr in model config handle to be set
* @param attrValue [IN] pointer to model config value
* @param valueSize [IN] memory size of attrValue
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetConfigOpt(aclmdlConfigHandle *handle, aclmdlConfigAttr attr,
const void *attrValue, size_t valueSize);
* @ingroup AscendCL
* @brief set config for model execute
*
* @param handle [OUT] pointer to model execute config handle
* @param attr [IN] config attr in model execute config handle to be set
* @param attrValue [IN] pointer to model execute config value
* @param valueSize [IN] memory size of attrValue
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetExecConfigOpt(aclmdlExecConfigHandle *handle, aclmdlExecConfigAttr attr,
const void *attrValue, size_t valueSize);
* @ingroup AscendCL
* @brief set config for model load
*
* @param handle [IN] pointer to model config handle
* @param weightFileName [IN] external weight file name
* @param devPtr [IN] a pointer to device memory. User should copy external weight data here
* @param size [IN] memory size of devPtr, need 32-byte alignment
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlSetExternalWeightAddress(aclmdlConfigHandle *handle, const char *weightFileName,
void *devPtr, size_t size);
* @ingroup AscendCL
* @brief get real tensor name from modelDesc
*
* @param modelDesc [IN] pointer to modelDesc
* @param name [IN] tensor name
*
* @retval the pointer of real tensor name
* @retval Failure return NULL
*/
ACL_FUNC_VISIBILITY const char *aclmdlGetTensorRealName(const aclmdlDesc *modelDesc, const char *name);
* @ingroup AscendCL
* @brief recover all hccl tasks on target device
*
* @param deviceId [IN] the device id
* @retval ACL_SUCCESS The function is successfully executed.
* @retval ACL_ERROR_INVALID_FILE Failure
*/
ACL_FUNC_VISIBILITY aclError aclRecoverAllHcclTasks(int32_t deviceId);
* @ingroup AscendCL
* @brief load model from compiled models
* @param model [IN] compiled model
* @param handle [IN] config handle
* @param modelId [IN] model id
* @retval ACL_SUCCESS The function is successfully executed.
* @retval otherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclmdlLoadFromModel(const aclmdlModel *model, const aclmdlConfigHandle *handle, uint32_t *modelId);
#ifdef __cplusplus
}
#endif
#endif