Function: query_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

Obtains the weight memory size and workspace size required for model execution.

Prototype

  • C Prototype
    1
    aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize)
    
  • Python Function
    1
    work_size, weight_size, ret = acl.mdl.query_size(file_name)
    

Parameter Description

Parameter

Description

file_name

Str, directory of the model file, including the file name. The user who runs the app must have the permission to access the path.

Return Value Description

Return Value

Description

work_size

Int, workspace size required for model execution, in bytes.

weight_size

Int, weight memory size required for model execution, in bytes.

ret

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

Restrictions

If the memory is managed by the user, you need to call acl.mdl.query_size to query the sizes of the workspace and weight memory required for model execution to avoid memory waste.

If the shape of the input data is uncertain, you cannot call acl.mdl.query_size to query the memory size. As a result, you cannot manage the memory during model loading. Therefore, you need to call acl.mdl.load_from_file or acl.mdl.load_from_mem to allow the system to manage the memory.

Reference

For the API call sequence, see Loading a Model.