Function: load_from_mem

Applicability

Product

Supported (√/x)

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

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.

Prototype

  • C Prototype
    1
    aclError aclmdlLoadFromMem(const void* model, size_t modelSize, uint32_t* modelId)
    
  • Python Function
    1
    model_id, ret = acl.mdl.load_from_mem(model, model_size)
    

Parameter Description

Parameter

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 APIs, see Memory Management.

model_size

Int, size of the model data in the memory, in bytes.

Return Value Description

Return Value

Description

model_id

Int, pointer address of the model ID generated after the system loads the model.

ret

Int, error code: 0 on success; else, failure.

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.

Reference

For the API call sequence, see Loading a Model.