Function: query_size
Applicable Products
- Ascend 950PR&950DT products: Supported
- Atlas A3 products: Supported
- Atlas A2 products: Supported
- Atlas 200I/500 A2 inference products: Supported
- Atlas inference products: Supported
- Atlas training products: Supported
Function
Obtains the weight memory size and workspace size required for model execution based on the model file.
Prototype
-
C Prototype
aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize) -
Python Function
work_size, weight_size, ret = acl.mdl.query_size(file_name)
Parameters
| 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 Values
| 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. |
Constraints
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 details about the API calling process, see Model Loading.