Function: bundle_load_from_file
Applicable Products
- Ascend 950PR&950DT products: Supported
- Atlas A3 products: Supported
- Atlas A2 products: Supported
- Atlas 200I/500 A2 inference products: Supported
- Atlas inference products: Supported
- Atlas training products: Supported
Function
If variables need to be dynamically updated during model execution, this API can be called to load offline model data (AI processor-adapted offline model) from a file. The memory is managed by the system.
This API must be used with other APIs to dynamically update variables. The process of calling the key APIs is as follows:
-
Build and save the model based on graph build methods. The model contains multiple graphs, such as the inference graph, variable initialization graph, and variable update graph.
In this section,
aclgrphBundleBuildModelis called to build the model, andaclgrphBundleSaveModelis called to save the model. For details about the APIs, see Graph Development. -
Call acl.mdl.bundle_load_from_file or acl.mdl.bundle_load_from_mem to load the model.
-
Call acl.mdl.bundle_get_model_id to obtain the IDs of multiple graphs.
-
Call the model execution APIs (for example, acl.mdl.execute) to execute each graph based on the IDs of those graphs.
If variable update is involved, call acl.mdl.set_dataset_tensor_desc 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.
-
After the inference is complete, call acl.mdl.bundle_unload to unload the model.
Prototype
-
C Prototype
aclError aclmdlBundleLoadFromFile(const char *modelPath, uint32_t *bundleId) -
Python Function
bundle_id, ret = acl.mdl.bundle_load_from_file(model_path)
Parameters
| Parameter | Description |
|---|---|
| model_path | Str, character string of the model file path. The path contains the file name. The user who runs the app must have the permission to access the storage path. The model file is built in graph mode. Call aclgrphBundleBuildModel to compile the model, and call aclgrphBundleSaveModel to save the model. For details about the APIs, see Graph Development. |
Return Values
| Return Value | Description |
|---|---|
| bundle_id | Int. After the system successfully loads the model, bundle_id is returned as the flag for identifying the model in subsequent operations. |
| ret | Int, error code: 0 on success; else, failure. |
Reference
For details about the API call sequence and sample code, see Weight Update.