aclmdlQuerySize

Description

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

Restrictions

The workspace and weight memory are all device memory, which needs to be allocated and freed by the user.

If the memory is managed by the user, before the allocation, you need to call this API 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 aclmdlQuerySize to query the memory size. As a result, you cannot manage the memory during model loading. Therefore, you need to call aclmdlLoadFromFile or aclmdlLoadFromMem to allow the system to manage the memory.

Prototype

aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize)

Parameters

Parameter

Input/Output

Description

fileName

Input

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

The .om file is an offline model adapted to the Ascend AI Processor.

NOTE:

For details about how to obtain the .om file, see --mode Parameters in ATC Instructions.

workSize

Output

Pointer to the workspace size required for model execution, in bytes.

weightSize

Output

Pointer to the weight memory size required for model execution, in bytes.

Returns

The value 0 indicates success, and other values indicate failure. For details, see aclError.

See Also

For details about the API call sequence and sample code, see Loading a Model.