Function: query_size
Function Usage
Obtains the weight memory size and workspace size required for model execution.
Prototype
- C Prototype
1aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize)
- Python Function
1work_size, weight_size, ret = acl.mdl.query_size(file_name)
Parameters
|
Parameter |
Description |
|---|---|
|
file_name |
Str, path of the model whose memory information needs to be obtained, including the file name. The user who runs the app must have the permission to access the path. |
Returns
|
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 indicates success, and other values indicate 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. You need to call acl.mdl.load_from_file or acl.mdl.load_from_mem to allow the system to manage the memory.