MxInitFromConfig

Function Usage

Performs global initialization such as allocating device and log resources, and preloading operators using the input preloading configuration file (JSON). Rules for compiling the configuration file are listed below. Example of the Preloading File of the Initialization Operator is an example of the configuration file. After all Vision SDK APIs are executed, call MxDeInit() to deinitialize the initialized global resources. For details, see Initialization and Deinitialization.

This API is not supported by the Atlas 200/300/500 inference product and Atlas 800I A2 inference product.

  • Preloaded operator configuration must contain the following fields:
    • Operator name (name)
    • Operator preload list (preload_list)
    • Operator type (type): This field is reserved and is not recommended currently.
  • The preload list must contain the following fields:
    • Operator input shape (input_shape)
    • Input type (input_type)
    • Output shape (output_shape)
    • Output type (output_type)
      If properties are required for operator preloading, the following fields must also be included:
      • Attribute name (attr_name)
      • Attribute data type (attr_type)
      • Attribute value (attr_val)
  • For details about the restrictions on the input and output shapes and data types of each operator, see the restrictions of the corresponding operator in TensorOperations. Tensor shapes must be consistent with the number of types and be separated by semicolons (;). Use comma (,) to separate the dimensions of each tensor.
  • After MxInitFromConfig is called, the DVPP resource pool will be initialized when APIs of ImageProcessor and TensorOperations are called for the first time. When the APIs are called again, the DVPP resource pool is directly used. The size of the DVPP resource pool can be set by calling globalCfg or globalCfgExtra. When APIs of ImageProcessor and TensorOperations are called for the first time, it takes a longer time because the DVPP resource pool needs to be initialized.
  • MxInitFromConfig can be called only once per process.
  • The underlying channel resources requested by the DVPP resource pool are shared by processes. In multi-process scenarios, resources may be exhausted. Therefore, exercise caution when using the DVPP resource pool.
  • The DVPP resource pool shares bottom-layer channel resources with VideoEncoder and VideoDecoder. In extreme scenarios, resources may be used up. You are advised to initialize the resource pool size based on the actual situation.
  • This API registers the threads for monitoring the number of logs and log time. The threads are named log_filenum and log_time respectively.

Prototype

1
APP_ERROR MxInitFromConfig(const std::string &configFile);
1
APP_ERROR MxInitFromConfig(const std::string &configFile, const AppGlobalCfg &globalCfg);
1
APP_ERROR MxInitFromConfig(const std::string &configFile, const AppGlobalCfgExtra &globalCfgExtra); 

Parameters

Parameter

Input/Output

Description

configFile

Input

std::string type, indicating the path of the JSON file to be preloaded. The JSON file owner must be the current user, with the 640 or lower permission.

globalCfg

Input

AppGlobalCfg type that applies to global configuration.

globalCfgExtra

Input

AppGlobalCfgExtra type that applies to global configuration.

Response Parameters

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.