Function: get_input_dims

Applicable Products

  • Ascend 950PR&950DT products: Supported
  • Atlas A3 products: Supported
  • Atlas A2 products: Supported
  • Atlas 200I/500 A2 inference products: Supported
  • Atlas inference products: Supported
  • Atlas training products: Supported

Function

Obtains dimension information of the input tensor based on the model description.

If the model contains static AIPP configuration, call acl.mdl.get_input_dims or acl.mdl.get_input_dims_v2 to obtain the shape as required. The differences between the two APIs are as follows:

  • acl.mdl.get_input_dims: The obtained dimension values are consistent with those of the input image. For details, see Table 1.

  • acl.mdl.get_input_dims_v2: The obtained value of the H dimension is that of the input image multiplied by a coefficient, and the value of the C dimension varies according to the image format. For details, see Table 1 in acl.mdl.get_input_dims_v2. The multiplied dimension values are consistent with those obtained by calling acl.mdl.get_input_size_by_index.

Prototype

  • C Prototype

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

    dims, ret = acl.mdl.get_input_dims(model_desc, index)
    

Parameters

Parameter Description
model_desc Int, pointer address of the data of the aclmdlDesc type. Call the acl.mdl.create_desc API to create data of the aclmdlDesc type in advance.
index Int, sequence number of the input whose dims is to be obtained, starting at 0.

Return Values

Return Value Description
dims Dict, maximum supported combinations for dynamic-batch or dynamic-size scenarios based on the dictionary array. For details, see aclmdlIODims. 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 a tensor name exceeds 127, the API replaces it with the format acl_modelId_${id}_input_${index}_${random string} when outputting dims.name. If the converted name conflicts with an existing tensor name, a random string (_${random string}) is appended; otherwise, no random string is added. The API also maintains a mapping between the converted and original names. You can call acl.mdl.get_tensor_real_name to retrieve the original name by passing the converted one (or simply pass the original name to get it back unchanged). For a tensor name that has a length of 127 or fewer, dims.name directly reflects the original tensor name.
ret Int, error code.
0: success
Other values: failure

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