ModelLoadOptV2
Description
Functions as a data structure that allows users to select one of the supported input modes for inputting data to inference models.
Select a configuration based on the actual requirements. If the configuration differs from the actual inputs, an exception will be thrown at Model. If the catch operation is not performed on the exception, a core dump error will occur in the program.
Structure Definition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | struct ModelLoadOptV2 { enum ModelLoadType { LOAD_MODEL_FROM_FILE = 1, LOAD_MODEL_FROM_FILE_WITH_MEM, LOAD_MODEL_FROM_MEM, LOAD_MODEL_FROM_MEM_WITH_MEM }; enum ModelType { MODEL_TYPE_OM = 0, MODEL_TYPE_MINDIR }; ModelType modelType = MODEL_TYPE_OM; ModelLoadType loadType = LOAD_MODEL_FROM_FILE; std::string modelPath = ""; void* modelPtr = nullptr; void* modelWorkPtr = nullptr; void* modelWeightPtr = nullptr; size_t modelSize = 0; size_t workSize = 0; size_t weightSize = 0; }; |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
modelType |
Input |
Inference model type. The options are as follows:
|
loadType |
Input |
Input type of the inference model. You can select an input mode by setting the following parameters:
|
modelPath |
Input |
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.
|
modelPtr |
Input |
Pointer to the memory address of the inference model. This parameter takes effect only in the following modes. The default value is nullptr. Enter the memory address as required.
|
modelWorkPtr |
Input |
Pointer to the workspace address of the inference model. This parameter takes effect only in the following modes. The default value is nullptr, indicating that the system manages the memory.
|
modelWeightPtr |
Input |
Pointer to the weight memory address of the inference model. This parameter takes effect only in the following modes. The default value is nullptr, indicating that the system manages the memory.
|
modelSize |
Input |
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.
|
workSize |
Input |
Workspace size of the inference model, in bytes. The default value is 0. This parameter is invalid when modelWorkPtr is nullptr. |
weightSize |
Input |
Weight memory size of the inference model, in bytes. The default value is 0. This parameter is invalid when modelWeightPtr is nullptr. |