Function: get_output_size_by_index

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 the output size in bytes based on data of the aclmdlDesc type.

Prototype

  • C Prototype
    1
    size_t aclmdlGetOutputSizeByIndex(aclmdlDesc *modelDesc, size_t index)
    
  • Python Function
    1
    size = acl.mdl.get_output_size_by_index(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 output to obtain, indexed starting at 0

Return Value Description

Return Value

Description

size

Int, size of the output, in bytes

  • If dynamic batch/image size (width and height) is enabled, the input size of the maximum profile is returned.
  • In other (static) cases, the size of the specified output is returned. The unit is byte.

Restrictions

If the size obtained from this call is 0, the possible cause is that the range of the output shape is unknown. Currently, the following two processing methods are available:

  • The system internally allocates output buffer of the corresponding index to save the memory. However, after the buffer data is used, free it in a timely manner. In addition, memory copy is involved in allocation, which may cause performance loss.

    When calling acl.create_data_buffer to create the aclDataBuffer type for storing output data of the corresponding index, you can pass 0 to the data parameter to create an empty aclDataBuffer type. During model execution, the system automatically calculates and allocates the index output buffer.

  • Estimate the size of the output buffer and allocate it. You can manage it by yourself. However, the buffer size may be insufficient or exceed the threshold. If the buffer size is insufficient, the system reports an error. If it exceeds the threshold, a waste is caused.

    You need to estimate a large output buffer as needed. During model execution, the system checks whether the specified output buffer size meets the requirement. If no, an error message is returned, with the size of the desired output buffer displayed. You can use either of the following methods to view the error message: