Obtains the shape of an input tensor based on the model description. This API is synchronous.
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:
aclError aclmdlGetInputDimsV2(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims)
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. |
Image Format |
Format |
Shape |
YUV420SP_U8 |
NHWC |
n,h*1.5,w,1 |
XRGB8888_U8 |
NHWC |
n,h,w,4 |
RGB888_U8 |
NHWC |
n,h,w,3 |
YUV400_U8 |
NHWC |
n,h,w,1 |
ARGB8888_U8 |
NHWC |
n,h,w,4 |
YUYV_U8 |
NHWC |
n,h,w,2 |
YUV422SP_U8 |
NHWC |
n,h*2,w,1 |
AYUV444_U8 |
NHWC |
n,h,w,4 |
0 on success; else, failure.