aclmdlLoadFromFileWithQ

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Function Usage

Loads offline model data from a file. The inputs and outputs of the model are stored in queues. This API can be used to load only models with static-shape inputs.

The file specified by modelPath is an offline model in the format of *.om. For details about how to obtain the OM model file, see Command-Line Options > Basic Options > General Options > --mode in ATC.

If the size of the OM model file is limited, this API can also load an external weight file. You need to save the weight in a separate file during model building. For example, when you use ATC to generate an .om file, set --external_weight to 1, indicating that the weight of the Const/Constant node on the original network is saved in a separate file in the weight directory. Ensure that the weight directory is at the same level as the .om file so that the API can automatically search for the weight file in the weight directory when you call this API to load the .om file. Otherwise, the weight file may fail to be loaded.

Prototype

1
aclError aclmdlLoadFromFileWithQ(const char *modelPath, uint32_t *modelId, const uint32_t *inputQ, size_t inputQNum, const uint32_t *outputQ, size_t outputQNum)

Parameters

Parameter

Input/Output

Description

modelPath

Input

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

modelId

Output

Pointer to the model ID.

Returns the model ID after the model is successfully loaded. The model ID is used for model identification in subsequent operations.

inputQ

Input

Pointer to the queue ID. Each input model corresponds to a queue ID.

inputQNum

Input

Number of input queues.

outputQ

Input

Pointer to the queue ID. Each output model corresponds to a queue ID.

outputQNum

Input

Number of output queues.

Returns

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

Reference

The aclmdlSetConfigOpt and aclmdlLoadWithConfig APIs are provided for model loading. The caller needs to set the attributes in the configuration object passed to the API call to decide how the model will be loaded and who will manage the memory.