|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932 |
- /**
- * @file acl_mdl.h
- *
- * Copyright (C) Huawei Technologies Co., Ltd. 2019-2020. All Rights Reserved.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
- #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_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_DYNAMIC_TENSOR_NAME "ascend_mbatch_shape_data"
- #define ACL_DYNAMIC_AIPP_NAME "ascend_dynamic_aipp_data"
-
- typedef struct aclmdlDataset aclmdlDataset;
- typedef struct aclmdlDesc aclmdlDesc;
- typedef struct aclmdlAIPP aclmdlAIPP;
- typedef struct aclAippExtendInfo aclAippExtendInfo;
-
- typedef enum {
- ACL_YUV420SP_U8 = 1,
- ACL_XRGB8888_U8,
- ACL_RGB888_U8,
- ACL_YUV400_U8,
- ACL_NC1HWC0DI_FP16,
- ACL_NC1HWC0DI_S8,
- ACL_ARGB8888_U8,
- ACL_YUYV_U8,
- ACL_YUV422SP_U8,
- ACL_AYUV444_U8,
- ACL_RAW10,
- ACL_RAW12,
- ACL_RAW16,
- ACL_RAW24,
- ACL_AIPP_RESERVED = 0xffff,
- } aclAippInputFormat;
-
- typedef struct aclmdlIODims {
- char name[ACL_MAX_TENSOR_NAME_LEN]; /**< tensor name */
- size_t dimCount; /**< dim array count */
- int64_t dims[ACL_MAX_DIM_CNT]; /**< dim data array */
- } aclmdlIODims;
-
- typedef struct aclAippDims {
- aclmdlIODims srcDims; /**< input dims before model transform */
- size_t srcSize; /**< input size before model transform */
- aclmdlIODims aippOutdims; /**< aipp output dims */
- size_t aippOutSize; /**< aipp output size */
- } aclAippDims;
-
- typedef struct aclmdlBatch {
- size_t batchCount; /**< batch array count */
- uint64_t batch[ACL_MAX_BATCH_NUM]; /**< batch data array */
- } aclmdlBatch;
-
- typedef struct aclmdlHW {
- size_t hwCount; /**< height&width array count */
- uint64_t hw[ACL_MAX_HW_NUM][2]; /**< height&width data array */
- } 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; /**< reserved parameters, current version needs to be null */
- } aclAippInfo;
-
- /**
- * @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_ERROR_NONE 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_ERROR_NONE The function is successfully executed.
- * @retval OtherValues Failure
- */
- ACL_FUNC_VISIBILITY aclError aclmdlGetDesc(aclmdlDesc *modelDesc, uint32_t modelId);
-
- /**
- * @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 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_ERROR_NONE 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 [IN|OUT] aclmdlDataset address of aclDataBuffer to be added
- * @param dataBuffer [IN] aclDataBuffer address to be added
- * @retval ACL_ERROR_NONE The function is successfully executed.
- * @retval OtherValues Failure
- */
- ACL_FUNC_VISIBILITY aclError aclmdlAddDatasetBuffer(aclmdlDataset *dataset,
- aclDataBuffer *dataBuffer);
-
- /**
- * @ingroup AscendCL
- * @brief Get the number of aclDataBuffer in aclmdlDataset
- *
- * @param dataset [IN] aclmdlDataset poiter
- * @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 poiter
- * @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_ERROR_NONE The function is successfully executed.
- * @retval OtherValues Failure
- */
- ACL_FUNC_VISIBILITY aclError aclmdlLoadFromFile(const char *modelPath, 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_ERROR_NONE 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_ERROR_NONE 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_ERROR_NONE 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_ERROR_NONE 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_ERROR_NONE 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_ERROR_NONE 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 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_ERROR_NONE 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_ERROR_NONE 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_ERROR_NONE 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 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_ERROR_NONE 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] 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_ERROR_NONE 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] data for model inference
- * @param index [IN] index of dynamic tensor
- * @param height [IN] model height
- * @param width [IN] model width
- * @retval ACL_ERROR_NONE 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 get input dims info
- *
- * @param modelDesc [IN] model description
- * @param index [IN] input tensor index
- * @param dims [OUT] dims info
- * @retval ACL_ERROR_NONE 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_ERROR_NONE 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 output dims info
- *
- * @param modelDesc [IN] model description
- * @param index [IN] output tensor index
- * @param dims [OUT] dims info
- * @retval ACL_ERROR_NONE 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_ERROR_NONE 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 input name by index
- *
- * @param modelDesc [IN] model description
- * @param index [IN] intput 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] intput 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] intput 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] intput tensor name
- * @param index [OUT] intput tensor index
- * @retval ACL_ERROR_NONE 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_ERROR_NONE 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_ERROR_NONE 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_ERROR_NONE The function is successfully executed.
- * @retval OtherValues Failure
- */
- ACL_FUNC_VISIBILITY aclError aclmdlGetDynamicHW(const aclmdlDesc *modelDesc, size_t index, aclmdlHW *hw);
-
- /**
- * @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_ERROR_NONE The function is successfully executed.
- * @retval OtherValues Failure
- */
- ACL_FUNC_VISIBILITY aclError aclmdlDestroyAIPP(const aclmdlAIPP *aippParmsSet);
-
- /**
- * @ingroup AscendCL
- * @brief set InputFormat of type aclmdlAIPP
- *
- * @param aippParmsSet [IN] Pointer for aclmdlAIPP
- * @param inputFormat [IN] The inputFormat of aipp
- * @retval ACL_ERROR_NONE 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 [IN] 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_ERROR_NONE The function is successfully executed.
- * @retval OtherValues Failure
- *
- * @see aclmdlCreateAIPP
- */
- ACL_FUNC_VISIBILITY aclError aclmdlSetAIPPCscParams(aclmdlAIPP *aippParmsSet, int8_t csc_switch,
- 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 [IN] Pointer for aclmdlAIPP
- * @param rbuvSwapSwitch [IN] rb/ub swap switch
- * @retval ACL_ERROR_NONE 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 [IN] Pointer for aclmdlAIPP
- * @param axSwapSwitch [IN] RGBA->ARGB, YUVA->AYUV swap switch
- * @retval ACL_ERROR_NONE 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 [IN] Pointer for aclmdlAIPP
- * @param srcImageSizeW [IN] Source image width
- * @param srcImageSizeH [IN] Source image height
- * @retval ACL_ERROR_NONE 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 [IN] 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_ERROR_NONE 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 [IN] 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_ERROR_NONE 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 [IN] 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_ERROR_NONE 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 [IN] 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_ERROR_NONE 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 [IN] 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_ERROR_NONE 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 [IN] 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_ERROR_NONE 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 dataSize
- * @param index [IN] index of dataBuffer
- * @param aippParmsSet [IN] Pointer for aclmdlAIPP
- * @retval ACL_ERROR_NONE 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 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_ERROR_NONE 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);
- #ifdef __cplusplus
- }
- #endif
-
- #endif // INC_EXTERNAL_ACL_ACL_MODEL_H_
|