Function: query_size
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
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)
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.