aclmdlQuerySize

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Function Usage

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

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 this API 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

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

Parameters

Parameter

Input/Output

Description

fileName

Input

Pointer to the model file path, which contains the file name. The user who runs the app must have the permission to access the path.

The model file is an OM model file.

For details about how to obtain the OM model file, see "Command-Line Options > Basic Options > General Options > --mode" in Ascend Tensor Compiler (ATC).

workSize

Output

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

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

weightSize

Output

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

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

Returns

0 on success; else, failure. For details, see aclError.

Example

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