aclmdlSetInputDynamicDims

Description

Sets the runtime dimensions for model inference before model execution, assuming that the input shape is dynamic and the input data format is ND (supporting any format).

Prototype

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

Parameters

Parameter

Input/Output

Description

modelId

Input

Model ID.

A successful aclmdlLoadFromFile, aclmdlLoadFromMem, aclmdlLoadFromFileWithMem, or aclmdlLoadFromMemWithMem call returns a model ID.

dataset

Input/Output

Pointer to the input data for model inference.

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

index

Input

Index of the dynamic dimension input.

The input index is obtained by the aclmdlGetInputIndexByName call. The input name is fixed to ACL_DYNAMIC_TENSOR_NAME.

dims

Input

Pointer to all dimensions of a specified profile.

The configured dimensions must be among the dimension profiles set during model building.

For example, if input_shape="data:1,1,40,-1;label:1,-1;mask:-1,-1" and dynamic_dims="20,20,1,1; 40,40,2,2; 80,60,4,4" are passed for ATC model conversion and the runtime shape is (1, 1, 40, 20, 1, 20, 1, 1), the dims struct is defined as follows (with the name field reserved):

dims.dimCount = 8

dims.dims[0] = 1

dims.dims[1] = 1

dims.dims[2] = 40

dims.dims[3] = 20

dims.dims[4] = 1

dims.dims[5] = 20

dims.dims[6] = 1

dims.dims[7] = 1

If you do not know the dynamic dimension profiles set during model building, you can call aclmdlGetInputDynamicDims to obtain the dynamic dimension profiles supported by a specified model and the dimensions of each profile.

Returns

The value 0 indicates success, and other values indicate failure. For details, see aclError.

See Also

For details about the API call sequence and example, see Model Inference with Dynamic-Shape Inputs.