aclmdlBundleLoadFromFile

Description

If variables need to be dynamically updated during model execution, this API can be called to load offline model data (offline model adapted to the Ascend AI Processor) from a file. The memory is managed by the system.

This API needs to be used with other APIs to dynamically update variables. The process of calling the key APIs is as follows:

  1. Compile and save the model in Ascend Graph mode. The model contains multiple graphs, such as the inference graph, variable initialization graph, and variable update graph.

    The aclgrphBundleBuildModel API is called to build the model, and the aclgrphBundleSaveModel API is called to save the model. For details about the APIs, see aclgrphBundleBuildModel and aclgrphBundleSaveModel .

  2. Call aclmdlBundleLoadFromFile or aclmdlBundleLoadFromMem to load the model.
  3. Call aclmdlBundleGetModelId to obtain the IDs of the graphs.
  4. Call the model execution APIs (for example, aclmdlExecute) to execute each graph based on the IDs of those graphs.

    If variable update is involved, call aclmdlSetDatasetTensorDesc to set the tensor description of the graph before updating the variable update graph. After you have executed the variable update graph, execute the inference graph again.

  5. After the inference is complete, call aclmdlBundleUnload to unload the model.

Prototype

aclError aclmdlBundleLoadFromFile(const char *modelPath, uint32_t *bundleId)

Command-Line Options

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.

The model file is built in Ascend Graph mode. Call the aclgrphBundleBuildModel API to build the model, and call the aclgrphBundleSaveModel API to save the model. For details about the APIs, see aclgrphBundleBuildModel .

bundleId

Output

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

Returns

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

Reference

For details about the API call sequence and sample code, see Weight Update.