Function: bundle_load_from_file
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
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 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, aclgrphBundleBuildModel is called to build the model, and aclgrphBundleSaveModel is called to save the model. For details about the APIs, see Graph Mode Development Guide.
- 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
1aclError aclmdlBundleLoadFromFile(const char *modelPath, uint32_t *bundleId)
- Python Function
1bundle_id, ret = acl.mdl.bundle_load_from_file(model_path)
Parameter Description
Return Value Description
|
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. |