aclmdlBundleLoadModelWithMem

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

√

Atlas A3 training products / Atlas A3 inference products

√

Atlas A2 training products / Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

√

Atlas inference products

√

Atlas training products

√

Function Usage

Loads a graph from the model based on the graph index. The model workspace is managed by the user.

Prototype

1
aclError aclmdlBundleLoadModelWithMem(uint32_t bundleId, size_t index, void *workPtr, size_t workSize, void *weightPtr, size_t weightSize, uint32_t *modelId)

Parameters

Parameter

Input/Output

Description

bundleId

Input

Bundle ID returned after the model is successfully initialized by calling aclmdlBundleInitFromFile or aclmdlBundleInitFromMem.

index

Input

Index.

After aclmdlBundleGetQueryModelNum is called to obtain the total number of graphs, the value range of the index is [0, total_number_of_graphs – 1].

workPtr

Input

Pointer to the address of the workspace (for storing temporary data during model execution) required by the model on the device. The workspace is managed by the user and cannot be freed during model execution.

If a null pointer is passed to workPtr, the workspace is managed by the system.

In the event where the memory is managed by the user, if multiple models are executed in serial, the models can share a workspace. However, you need to guarantee the serial execution sequence of the models and the workspace size (the same as the total size of the workspaces needed by all the models). Refer to the following description to ensure serial execution: Lock the model during execution to ensure that tasks are executed in serial.

workSize

Input

Workspace size required for model execution, in bytes. Invalid when workPtr is a null pointer.

weightPtr

Input

Pointer to the address of the model weight memory (for storing weight data) on the device. The memory is managed by the user and cannot be freed during model execution.

If a null pointer is passed, the memory is managed by the system.

In the multithreaded scenario where the weight memory is managed by the user, if a model is loaded once in each thread, weightPtr can be shared because the weight memory is read-only at inference time. Note that weightPtr cannot be freed when the sharing is in progress.

weightSize

Input

Weight memory size required for model execution, in bytes. Invalid when weightPtr is a null pointer.

modelId

Output

ID of the executable graph.

Returns

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

Example

For details about the API call sequence and sample code, see Weight Update (User-managed Memory).