aclmdlSetInputDynamicDims

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Function Usage

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

1
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 and output

Pointer to the input data for model inference. For the type definition, see aclmdlDataset.

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

index

Input

Index of the dynamic dimension size 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 dimension information of a specific profile. For details about the type definition, see aclmdlIODims.

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

0 on success; else, failure. For details, see aclError.

Example

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