Function: execute
|
C Prototype |
aclError aclmdlExecute(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output) |
|---|---|
|
Python Function |
ret = acl.mdl.execute(model_id, input, output) |
|
Function Usage |
Executes model inference until the result is returned. |
|
Input Description |
model_id: int, ID of the model to be inferred. You can obtain the model ID after the model is successfully loaded by calling the following APIs:
input: int, pointer address of the input data for model inference. For details, see aclmdlDataset. output: int, pointer address of the output data for model inference. For details, see aclmdlDataset. When calling acl.create_data_buffer to create an ACL data buffer for storing the output data of the corresponding index, you can set data to 0 and set size to 0 to create an empty ACL data buffer. During model execution, the system calculates and allocates the memory for the index output. 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: data_buffer = acl.mdl.get_dataset_buffer(output, 0) // Obtain the corresponding data buffer based on the index. data_addr = acl.get_data_buffer_addr(data_buffer) // Obtain the device pointer address of the data. acl.rt.free(data_addr) // Release the device memory. acl.update_data_buffer(data_buffer, 0, 0) // Reset the data buffer for next inference. |
|
Return Value |
ret: int, error code.
|
|
Restrictions |
|
|
Reference |
For details about the API call sequence and sample code, see Executing a Model. |