Function: load_from_mem

C Prototype

aclError aclmdlLoadFromMem(const void* model, size_t modelSize, uint32_t* modelId)

Python Function

model_id, ret = acl.mdl.load_from_mem(model, model_size)

Function Usage

Loads an offline model from memory. The model workspace is managed by the system.

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

Input Description

model: int, pointer address of the memory address of the model data.

  • If the app runs on the host, allocate the memory of the host.
  • If the app runs on the device, allocate device memory.

For details about the memory allocation API, see Memory Management.

model_size: int, length of the model data in the memory, in bytes.

Return Value

model_id: int, model ID generated after the model is loaded.

ret: int, error code.

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 acl.rt.set_device and acl.rt.create_context.

API

pyACL also provides the acl.mdl.set_config_opt and acl.mdl.load_with_config 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.

Reference

For details about the API call sequence, see Loading a Model.