aclmdlConfigAttr

typedef enum {
    ACL_MDL_PRIORITY_INT32 = 0,    
    ACL_MDL_LOAD_TYPE_SIZET,       
    ACL_MDL_PATH_PTR,              
    ACL_MDL_MEM_ADDR_PTR,          
    ACL_MDL_MEM_SIZET,             
    ACL_MDL_WEIGHT_ADDR_PTR,        
    ACL_MDL_WEIGHT_SIZET,          
    ACL_MDL_WORKSPACE_ADDR_PTR,     
    ACL_MDL_WORKSPACE_SIZET,        
    ACL_MDL_INPUTQ_NUM_SIZET,      
    ACL_MDL_INPUTQ_ADDR_PTR,        
    ACL_MDL_OUTPUTQ_NUM_SIZET,     
    ACL_MDL_OUTPUTQ_ADDR_PTR,      
    ACL_MDL_WORKSPACE_MEM_OPTIMIZE,
    ACL_MDL_WEIGHT_PATH_PTR,
    ACL_MDL_MODEL_DESC_PTR, 
    ACL_MDL_MODEL_DESC_SIZET,
    ACL_MDL_KERNEL_PTR, 
    ACL_MDL_KERNEL_SIZET,
    ACL_MDL_KERNEL_ARGS_PTR, 
    ACL_MDL_KERNEL_ARGS_SIZET,
    ACL_MDL_STATIC_TASK_PTR, 
    ACL_MDL_STATIC_TASK_SIZET,
    ACL_MDL_DYNAMIC_TASK_PTR,
    ACL_MDL_DYNAMIC_TASK_SIZET,
    ACL_MDL_MEM_MALLOC_POLICY_SIZET
} aclmdlConfigAttr;
Table 1 Model loading options

Option

Description

ACL_MDL_PRIORITY_INT32

(Optional) Priority of model execution. The value of this option is of the int32 type.

A smaller value indicates a higher priority. The value range is [0,7]. The default value is 0.

For the Atlas Training Series Product , this enumeration does not take effect when CANN is installed in a Docker container with computing power allocation configured.

ACL_MDL_LOAD_TYPE_SIZET

(Required) Model loading mode. The value of this option is of the size_t type.

ACL_MDL_LOAD_TYPE_SIZET (model loading mode) supports the following values:

  • ACL_MDL_LOAD_FROM_FILE
    #define ACL_MDL_LOAD_FROM_FILE 1
  • ACL_MDL_LOAD_FROM_FILE_WITH_MEM
    #define ACL_MDL_LOAD_FROM_FILE_WITH_MEM 2
  • ACL_MDL_LOAD_FROM_MEM
    #define ACL_MDL_LOAD_FROM_MEM 3
  • ACL_MDL_LOAD_FROM_MEM_WITH_MEM
    #define ACL_MDL_LOAD_FROM_MEM_WITH_MEM 4
  • ACL_MDL_LOAD_FROM_FILE_WITH_Q
    #define ACL_MDL_LOAD_FROM_FILE_WITH_Q 5
  • ACL_MDL_LOAD_FROM_MEM_WITH_Q
    #define ACL_MDL_LOAD_FROM_MEM_WITH_Q 6

Note: If ACL_MDL_LOAD_TYPE_SIZET is set to ACL_MDL_LOAD_FROM_MEM, model data is loaded from the memory. You can also use the ACL_MDL_WEIGHT_PATH_PTR option to specify the weight file directory.

ACL_MDL_PATH_PTR

(Required if the model is loaded from a file) Pointer to the path of the offline model file.

ACL_MDL_MEM_ADDR_PTR

(Required if the model is loaded from memory) Start address of the model in the memory.

ACL_MDL_MEM_SIZET

Size of the model in the memory. This parameter is mandatory if the model is loaded from memory. It must be used in conjunction with ACL_MDL_MEM_ADDR_PTR. The value of this option is of the size_t type.

ACL_MDL_WEIGHT_ADDR_PTR

(Required if the weight memory is managed by the user) Pointer to the weight memory (storing weight data) on the device. If this parameter is not set, the system manages the memory.

ACL_MDL_WEIGHT_SIZET

(Required if the weight memory is managed by the user) Size of the weight memory on the device, in bytes. If this parameter is not set, the system manages the memory. Must be used in conjunction with ACL_MDL_WEIGHT_ADDR_PTR. The value of this option is of the size_t type.

ACL_MDL_WORKSPACE_ADDR_PTR

(Required if the workspace is managed by the user) Pointer to the workspace (storing temporary data during model execution) on the device. If this parameter is not set, the system manages the memory.

ACL_MDL_WORKSPACE_SIZET

(Required if the workspace is managed by the user) Size of the workspace required by the model, in bytes. Must be used in conjunction with ACL_MDL_WORKSPACE_ADDR_PTR. The value of this option is of the size_t type.

ACL_MDL_INPUTQ_NUM_SIZET

(Required if the model is loaded by using a queue) Size of the model input queue. Must be used in conjunction with ACL_MDL_INPUTQ_ADDR_PTR. The value of this option is of the size_t type.

ACL_MDL_INPUTQ_ADDR_PTR

(Required if the model is loaded by using a queue) Pointer to the model input queue ID. One model input corresponds to one queue ID.

ACL_MDL_OUTPUTQ_NUM_SIZET

(Required if the model is loaded by using a queue) Size of the model output queue. Must be used in conjunction with ACL_MDL_OUTPUTQ_ADDR_PTR. The value of this option is of the size_t type.

ACL_MDL_OUTPUTQ_ADDR_PTR

(Required if the model is loaded by using a queue) Pointer to the model output queue ID. One model output corresponds to one queue ID.

ACL_MDL_WORKSPACE_MEM_OPTIMIZE

Whether to enable model buffer optimization. The value 1 indicates that the function is enabled, and the value 0 indicates that the function is disabled.

If buffer planning is considered or resources are limited, you are advised to load the model in system-managed buffer mode and enable the buffer optimization function to reduce the buffer size. In this case, the buffer does not contain the part for storing the input and output data of the model.

Before model execution, you need to allocate the buffer for storing the input and output data of the model. Therefore, even if buffer optimization is enabled during model loading, subsequent model execution is not affected.

ACL_MDL_WEIGHT_PATH_PTR

Pointer to the directory where weight files are located. If the size of an .om model file is limited, this parameter can be used to implement the function of externalizing weight files.

If ACL_MDL_LOAD_TYPE_SIZET is set to ACL_MDL_LOAD_FROM_MEM, model data is loaded from the memory. You can also use ACL_MDL_WEIGHT_PATH_PTR to specify the weight file directory.

Generally, if the size of an .om model file is limited or the model file is encrypted, you need to specify the weight file directory separately. The prerequisite is that when using the ATC tool to generate the .om file, set the --external_weight parameter to 1 (1 indicates that the weights of the Const/Constant nodes on the original network are saved in a separate file).

ACL_MDL_MODEL_DESC_PTR

Pointer to the buffer for storing model description information.

Not supported in the current version.

ACL_MDL_MODEL_DESC_SIZET

Size of the buffer required for storing the model description information, in bytes. The value of this option is of the size_t type.

You can call aclmdlQueryExeOMDesc to obtain the buffer size required for storing the model description information in advance. This option must be used in conjunction with ACL_MDL_MODEL_DESC_PTR.

Not supported in the current version.

ACL_MDL_KERNEL_PTR

Pointer to the buffer for storing the TBE operator kernel (*.o and *.json files).

Not supported in the current version.

ACL_MDL_KERNEL_SIZET

Buffer size required for storing the TBE operator kernel (*.o and *.json files), in bytes. The value of this option is of the size_t type.

You can call aclmdlQueryExeOMDesc to obtain the buffer size required for storing the TBE operator kernel (*.o and *.json files) in advance. This option must be used in conjunction with ACL_MDL_KERNEL_PTR.

Not supported in the current version.

ACL_MDL_KERNEL_ARGS_PTR

Pointer to the buffer for storing the TBE operator kernel parameters.

Not supported in the current version.

ACL_MDL_KERNEL_ARGS_SIZET

Buffer size required for storing the TBE operator kernel parameters, in bytes. The value of this option is of the size_t type.

You can call aclmdlQueryExeOMDesc to obtain the buffer size required for storing the TBE operator kernel parameters in advance. This option must be used in conjunction with ACL_MDL_KERNEL_ARGS_PTR.

Not supported in the current version.

ACL_MDL_STATIC_TASK_PTR

Pointer to the buffer for storing the description of a static shape task.

Not supported in the current version.

ACL_MDL_STATIC_TASK_SIZET

Size of the buffer required for storing the description of a static shape task, in bytes. The value of this option is of the size_t type.

You can call aclmdlQueryExeOMDesc to obtain the buffer size required for storing the description of a static shape task in advance. This option must be used in conjunction with ACL_MDL_STATIC_TASK_PTR.

Not supported in the current version.

ACL_MDL_DYNAMIC_TASK_PTR

Pointer to the buffer for storing the description of a dynamic shape task.

Not supported in the current version.

ACL_MDL_DYNAMIC_TASK_SIZET

Size of the buffer required for storing the description of a dynamic shape task, in bytes. The value of this option is of the size_t type.

You can call aclmdlQueryExeOMDesc to obtain the buffer size required for storing the description of a dynamic shape task in advance. This option must be used in conjunction with ACL_MDL_DYNAMIC_TASK_PTR.

Not supported in the current version.

ACL_MDL_MEM_MALLOC_POLICY_SIZET

Memory allocation rule, whose value is of the size_t type.

Not supported in the current version.

For details about how to obtain the .om file, see --mode Parameters in ATC Instructions.