Function: load_from_mem

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

Loads OM model file data from memory. The model workspace is managed by the system.

For details about how to obtain the OM model file, see "--mode" in the [Ascend Tensor Compiler (ATC).

Prototype

  • 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)
    

Parameters

Parameter Description
model Int, pointer address of the memory address of the model data.
model_size Int, size of the model data in the memory, in bytes.

Return Values

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.

Constraints

In Ascend EP form, allocate memory on the host for the model parameter.

In Ascend RC form, allocate memory on the device for the model parameter.

In Ctrl CPU form, allocate memory on the device for the model parameter.

Reference

The acl.mdl.set_config_opt and acl.mdl.load_with_config APIs are also provided 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.