ModelLoadOptV2

Select the corresponding configuration as required. If the configuration is different from the actual input, RuntimeError is thrown at Model.

Table 1 Model loading options

Property Name

Type

Description

modelType

ModelType enumerations

Inference model type. The options are as follows: (The default value is base.model_type_om.)

  • base.model_type_om
  • base.model_type_mindir(For MindIR models, only static shapes and dynamic batches are supported.)

loadType

ModelLoadType enumerations

Input type of the inference model. You can select an input mode by setting the following parameters: (The default value is base.load_model_from_file.)

  • base.load_model_from_file: loads offline model data from a file. The memory is managed by the system.
  • base.load_model_from_file_with_mem: loads offline model data from a file. The memory (including the workspace for storing temporary data during model execution and weight memory for storing the model weight data) is managed by the user.
  • base.load_model_from_mem: loads offline model data from the memory. The memory is managed by the system.
  • base.load_model_from_mem_with_mem:

    loads offline model data from the memory. The memory (including the workspace and weight memory) is managed by the user.

  • When modelType is set to base.model_type_mindir, only the base.load_model_from_file and base.load_model_from_mem input types are supported.

modelPath

str

Path of the inference model file. This parameter takes effect only in the following modes. (The default value is "". A model with a maximum size of 4 GB is supported, and it is recommended that the model owner be the current user. The permission on the model file must be less than or equal to 640.)

  • base.load_model_from_file
  • base.load_model_from_file_with_mem

modelPtr

int

Memory address of the inference model. This parameter takes effect only in the following modes. (The default value is 0. Enter the memory address as required.)

  • base.load_model_from_mem
  • base.load_model_from_mem_with_mem

modelSize

int

Data length of the inference model, in bytes. This parameter takes effect only in the following modes. (The default value is 0. A model with a maximum size of 4 GB is supported.)

  • base.load_model_from_mem
  • base.load_model_from_mem_with_mem

modelWorkPtr

int

Workspace address of the inference model. This parameter takes effect only in the following modes. (The default value is 0, indicating that the system manages the workspace.)

  • base.load_model_from_file_with_mem
  • base.load_model_from_mem_with_mem

modelWeightPtr

int

Weight memory address of the inference model. This parameter takes effect only in the following modes. (The default value is 0, indicating that the system manages the memory.)

  • base.load_model_from_file_with_mem
  • base.load_model_from_mem_with_mem

workSize

int

Workspace size of the inference model, in bytes. (The default value is 0. This parameter is invalid when modelWorkPtr is 0.)

weightSize

int

Weight memory size of the inference model, in bytes. (The default value is 0. This parameter is invalid when modelWeightPtr is 0.)