Function: set_dynamic_hw_size

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

Sets the runtime image size for dynamic-shape model inference.

Prototype

  • C Prototype
    1
    aclError aclmdlSetDynamicHWSize(uint32_t modelId, aclmdlDataset *dataset, size_t index, uint64_t height, uint64_t width)
    
  • Python Function
    1
    ret = acl.mdl.set_dynamic_hw_size(model_id, dataset, index, height, width)
    

Parameter Description

Parameter

Description

model_id

Int, model ID.

You can obtain the model ID after the model is successfully loaded by calling the following APIs:

dataset

Int, model input data.

Data of type aclmdlDataset describes the input data for model inference, while data of type aclDataBuffer describes the input buffer size and address. For details, see aclmdlDataset.

index

Int, index of the input dynamic batch, obtained by calling acl.mdl.get_input_index_by_name. For dynamic batch and image size, the input name is fixed to ascend_mbatch_shape_data. For dynamic AIPP, the input name is fixed to ascend_dynamic_aipp_data.

height

Int, height to set.

width

Int, width to set.

The configured image size (height and width) must be among the image size profiles set during model building. You can also call acl.mdl.get_dynamic_hw to obtain the number of image size profiles supported by a specified model and the width and height of each profile.

Return Value Description

Return Value

Description

ret

Int, error code: 0 on success; else, failure.

Reference

For details about the API call sequence and example, see Dynamic Batch/Dynamic Image Size/Dynamic Dimension (Setting Multi-Dimension Profiles).