Function: get_output_dims

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Function Usage

Obtains tensor dimension information of an output based on the model description.

  • Static-shape: This API is used to obtain the shape of the output tensors of a model.
  • In the dynamic-shape scenario, this API is used to obtain the shape of the maximum batch/image size profile.

Prototype

  • C Prototype
    1
    aclError aclmdlGetOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims)
    
  • Python Function
    1
    dims, ret = acl.mdl.get_output_dims(model_desc, index)
    

Parameter Description

Parameter

Description

model_desc

Int, pointer address of the data of the aclmdlDesc type.

Call acl.mdl.create_desc to create data of the aclmdlDesc type in advance.

index

Int, sequence number of the input to obtain, indexed starting at 0

Return Value Description

Return Value

Description

dims

Dict, maximum supported combinations for dynamic-batch or dynamic-size scenarios based on the dictionary array. For details, see aclmdlIODims.

dims = {
        "name": xxx, #tensor name
        "dimCount":xxx, # Number of dimensions in the shape
        "dims": [xx, xx, xx]   # Shape
        }
  • If the length of the tensor name is greater than 127, when dims["name"] is output, it converts the tensor name to the acl_modelId_${id}_input_${index}_${random character string} format and establishes a mapping between the converted name and the original name, you can call acl.mdl.get_tensor_real_name to transfer the converted name and obtain the original name. (If the original name is passed to the API, the original name is obtained.)
    NOTE:

    If the name of the converted tensor conflicts with the name of an existing tensor in the model, _${random string} is added to the end of the converted name. Otherwise, no random string is added.

  • If the length of the tensor name is no longer than 127 characters, the tensor name is output when dims["name"] is output.

ret

Int, error code.