aclmdlGetInputDims

Description

Obtains the shape of an input tensor based on the model description.

If the model contains static AIPP configuration information, call aclmdlGetInputDims or aclmdlGetInputDimsV2 to obtain the shape as required. The differences between the two APIs are as follows:

Prototype

aclError aclmdlGetInputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims)

Parameters

Parameter

Input/Output

Description

modelDesc

Input

Pointer to data of the aclmdlDesc type.

Call aclmdlCreateDesc to create data of the aclmdlDesc type in advance.

index

Input

Sequence number of the input whose dims information to obtain, indexed starting at 0.

dims

Output

Pointer to the input shape.

In dynamic batch/image size scenarios, if the batch size is -1 or the width and height are -1, the tensor shape is dynamic. For example, if the format of the input tensor is NCHW, then the tensor shape [–1,3,224,224] indicates that the batch size is dynamic, and the tensor shape [1,3,–1,–1] indicates that the image size is dynamic. The italic numbers are examples only.

If the length of the original tensor name is less than or equal to 127, the original tensor name is retained in the output dims.name. If the length of the original tensor name is greater than 127, AscendCL converts the tensor name into the format of "acl_modelId_${id}_input_${index}_${random string}" in the output dims.name. If the name of the converted tensor conflicts with that of an existing tensor in the model, the converted tensor name is suffixed with another random string, formatted as _${random string}. In addition, a mapping between the converted tensor name and the original tensor name is created, which allows you to obtain the original name by passing the converted name to the aclmdlGetTensorRealName call. (If the original name is passed to the API call, the original name is returned.)

In the static AIPP scenario, this API applies only to the NHWC format. Table 1 describes the mapping between the supported input image formats and dims shapes.

Table 1 Mapping between the supported image formats and dims shapes with static AIPP

Image Format

Format

Shape

YUV420SP_U8

NHWC

n,h,w,c

XRGB8888_U8

NHWC

n,h,w,c

RGB888_U8

NHWC

n,h,w,c

YUV400_U8

NHWC

n,h,w,c

ARGB8888_U8

NHWC

n,h,w,c

YUYV_U8

NHWC

n,h,w,c

YUV422SP_U8

NHWC

n,h,w,c

AYUV444_U8

NHWC

n,h,w,c

Returns

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