aclmdlLoadFromFile

Description

Loads offline model data (offline model adapted to the Ascend AI Processor) from a file. The memory is managed by the system.

Restrictions

The operations of loading, executing, and unloading a model must be performed in the same context. For details about how to create a context, see aclrtSetDevice or aclrtCreateContext. Before loading the model file, check whether the memory space is sufficient based on the size of the model file. If the memory space is insufficient, the application will be abnormal.

Prototype

aclError aclmdlLoadFromFile(const char *modelPath, uint32_t *modelId)

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.

NOTE:
  • The .om model file is an offline model adapted to the Ascend AI Processor. For details about how to obtain the .om file, see --mode Parameters in ATC Instructions.
  • If the size of each .om model file is limited, this API supports the function of externalizing weight files. The specific usage is as follows: 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 AscendCL 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.

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.

Returns

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

Related APIs

AscendCL also provides the aclmdlSetConfigOpt and aclmdlLoadWithConfig APIs 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.

See Also

For the API call sequence, see Loading a Model.