aclmdlExecuteV2
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
Performs model inference based on the attributes configured by the aclmdlSetExecConfigOpt API until the inference result is returned. This API is enhanced based on aclmdlExecute. It allows you to control configuration parameters during model inference.
- Call aclmdlCreateExecConfigHandle to create a configuration object for model execution.
- Call aclmdlSetExecConfigOpt multiple times to set the value of each attribute in the configuration object.
- Call aclmdlExecuteV2 to specify the configuration required for model execution and execute the model.
- After the model is successfully loaded, call aclmdlDestroyExecConfigHandle to destroy the configuration object.
Prototype
1
|
aclError aclmdlExecuteV2(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output, aclrtStream stream, const aclmdlExecConfigHandle *handle) |
Parameters
|
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
|
modelId |
Input |
Model ID for inference. After a model loading API (such as aclmdlLoadFromFile or aclmdlLoadFromMem) is successfully called, the model ID is returned. This ID is used as the input of this API. |
||
|
input |
Input |
Pointer to the input data for model inference. For details about the type definition, see aclmdlDataset. |
||
|
output |
Output |
Pointer to the output data for model inference. For details about the type definition, see aclmdlDataset. When calling aclCreateDataBuffer to create the aclDataBuffer type for storing output data of the corresponding index, you can pass nullptr to the data parameter and set size to 0 to create an empty aclDataBuffer type. During model execution, the system automatically calculates and allocates the index output memory. This method saves memory. However, you need to free the memory and reset the aclDataBuffer after using the data. In addition, memory copy is involved when the system allocates memory, which may cause performance loss.
The sample code for freeing the memory and resetting the aclDataBuffer is as follows:
|
||
|
stream |
Input |
Stream. For details about the type definition, see aclrtStream. If NULL is passed, the attribute value configured by the aclmdlSetExecConfigOpt API does not take effect. |
||
|
handle |
Input |
Pointer to the configuration object executed by the model. For details about the type definition, see aclmdlExecConfigHandle. The value must be the same as that of handle in aclmdlSetExecConfigOpt. |
Returns
0 on success; else, failure. For details, see aclError.
Restrictions
The restrictions are the same as those of aclmdlExecute.