Function: set_input_dynamic_dims

C Prototype

aclError aclmdlSetInputDynamicDims(uint32_t modelId, aclmdlDataset *dataset, size_t index, const aclmdlIODims *dims)

Python Function

ret = acl.mdl.set_input_dynamic_dims(model_id, dataset_in, index, dims)

Function Usage

Sets the dimension values for model inference before the model is executed when the input shape of a model is dynamic and the input data is in ND format (ND indicates any format).

Input Description

model_id: int, model ID.

You can obtain the model ID after the model is successfully loaded by calling the following APIs:

dataset_in: int, input data of a model.

Data of type aclmdlDataset describes the input data for model inference, while data of type aclDataBuffer describes the input buffer size and address. For details, see aclmdlDataset.

index: int, index of the input configured with dynamic dimensions.

The input index is obtained by the acl.mdl.get_input_index_by_name API. The input name is fixed to ascend_mbatch_shape_data.

dims: dict, dimension size for model inference. For details, see aclmdlIODims.

You can call the acl.mdl.get_input_dynamic_dims API to obtain the number of dimension size profiles as well as the size of each profile supported by the model.

Example: Use the following parameters to convert a model with ATC: input_shap="data:1,1,40,-1;label:1,-1;mask:-1,-1", dynamic_dims="20,20,1,1; 40,40,2,2; 80,60,4,4"

If the actual dimension of the input data is (1,1,40,20,1,20,1,1), input dims as follows (name is not required):

dims = {'dimCount': 8, 'name': '', 'dims': [1,1,40,20,1,20,1,1]}

Return Value

ret: int, error code.

Restrictions

None

Reference

For details about the API call sequence and example, see Dynamic Batch/Dynamic Image Size/Dynamic Dimension (Setting Multi-Dimension Profiles).