Function: init

Applicable Products

Product

Supported (√/x)

Ascend 950PR / Ascend 950DT

√

Atlas A3 training products / Atlas A3 inference products

√

Atlas A2 training products / Atlas A2 inference products

√

Atlas training products

√

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Performs initialization.

Prototype

Parameters

Parameter

Description

config_path

Path of the configuration file, including the file name.

The configuration file is in JSON format. A JSON file allows up to 10 levels of curly brackets and square brackets, respectively. To use the default configurations, directly call the acl.init interface without passing any parameter or set the configuration file to an empty JSON string (that is, only {} exists in the configuration file).

The configuration file is in JSON format. The following configurations are supported:

  • Dump configuration: includes the following configurations. (If the operator input or output contains sensitive user information, information leakage may occur.)
    • Model dump configuration (used to export the input and output data of operators at each layer in the model) and single-operator dump configuration (used to export the input and output data of an operator). The exported data is used to compare with that of a specified model or operator to locate accuracy issues. For details about the configuration example, description, and restrictions, see Examples of Model Dump Configuration and Single-Operator Dump Configuration. This dump configuration is disabled by default.
    • Dump configuration of the exception operator (used to export the input and output data, workspace information, and tiling information of the exception operator). The exported data is used to analyze AI Core errors. For details about the configuration example, see Example of Dump Configuration for Exception Operators. This dump configuration is disabled by default.
    • Dump configuration of the overflow/underflow operator (used to export the input and output data of the overflow/underflow operator in the model). The exported data is used to analyze overflow/underflow causes and locate model accuracy problems. For details about the configuration example, description, and restrictions, see Example of Overflow/Underflow Operator Dump Configuration. This dump configuration is disabled by default.
    • Operator Dump Watch mode configuration (enables the observation mode for the output data of a specified operator). If you suspect that the memory is overwritten by other operators after locating the accuracy issues of some operators and excluding the computation issues of the operators, you can enable the Dump Watch mode. For details about the configuration example and restrictions, see Dump Watch Configuration for Operators. The dump watch mode is disabled by default.
    • Operator kernel debugging information dump configuration is used to export the kernel debugging information of Ascend C operators to locate operator problems. This dump configuration is disabled by default.

      This configuration is only available for the following models:

      Ascend 950PR / Ascend 950DT

      Atlas A3 training products / Atlas A3 inference products

      Atlas A2 training products / Atlas A2 inference products

      Atlas 200I/500 A2 inference products

      Atlas inference products

  • Profiling configuration. For the configuration example, description, and restrictions, see Performance Tuning Tool. Profiling is disabled by default.
  • Operator cache aging configuration. To save memory and balance the calling performance, you can use the max_opqueue_num parameter to configure the maximum length of the "operator type and single-operator model" mapping queue. If the length of the mapping queue reaches the maximum, the least used mapping information and single-operator models in the cache are deleted before the most recent mapping information and the corresponding single-operator model are loaded. The default maximum length of the mapping queue is 20000. For details about the examples and restrictions, see Example of Operator Cache Aging Configuration.
  • Error information report mode configuration, which is used to control the acl.get_recent_err_msg API to obtain error information by process or thread level. By default, error information is obtained by thread level. For details about the example, see Example of Error Information Report Mode Configuration.
  • Default device configuration (used to configure the default compute device). For details about configuration example and description, see Example (Default Device Configuration).

    If the device is specified through set_device, aclrtSetDevice has a high priority.

    If you want to explicitly create a context after enabling the default device configuration, you need to call set_device. Otherwise, service exceptions may occur.

  • AI Core stack size configuration, which is used to control the size of the stack space allocated to each AI Core during kernel execution in a process. The default value is 32 KB. For details about the configuration example and usage description, see Example of AI Core Stack Size Configuration. When compiling AI Core operators, the configured AI Core stack size is valid only when the O0 switch is enabled. This restriction does not apply to the Ascend 950PR / Ascend 950DT .

    This configuration is only available for the following models:

    Ascend 950PR / Ascend 950DT

    Atlas A3 training products / Atlas A3 inference products

    Atlas A2 training products / Atlas A2 inference products

    Atlas 200I/500 A2 inference products

  • Single Instruction Multiple Thread (SIMT) stack size configuration, which is used to control the stack size of the SIMT operator and the branch (divergence) stack size of the SIMT operator in each thread. The unit is byte. Only the Ascend 950PR / Ascend 950DT supports this configuration.
  • Single Instruction Multiple Thread (SIMT) Printf maintenance and test space size configuration, which is used to control the size of the space for the SIMT operator to print information. The unit is byte. Only the Ascend 950PR / Ascend 950DT supports this configuration.
  • Single Instruction Multiple Data (SIMD) Printf maintenance and test space size configuration, which is used to control the size of the space for the SIMD operator to print information on each core. The unit is byte. This configuration is only available for the following models:

    Ascend 950PR / Ascend 950DT

    Atlas A3 training products / Atlas A3 inference products

    Atlas A2 training products / Atlas A2 inference products

NOTE:

Dump configuration and profiling configuration should not be both set. The dump operation could affect the system performance, resulting in inaccurate profile data collected by Profiling.

Return Values

Return Value

Description

ret

Int, error code. 0 on success; else, failure.

Restrictions

Example of Overflow/Underflow Operator Dump Configuration

Set dump_debug to on to enable the overflow/underflow operator configuration. The following is an example of the configuration file:
{
    "dump":{
        "dump_path":"output",
        "dump_debug":"on"
    }
}
The details are as follows:
  • If dump_debug is not set or set to off, the overflow/underflow operator configuration is disabled.
  • If the overflow/underflow operator configuration is enabled, dump_path must be set to specify the path for storing exported dump files.

    After obtaining the exported data files, parse the files by referring to Collecting and Analyzing Data of Overflow/Underflow Operators in Accuracy Analyzer.

    dump_path can be set to an absolute path or a relative path.
    • An absolute path starts with a slash (/), for example, /home.
    • A relative path starts with a directory name, for example, output.
  • This function cannot be enabled when model or single-operator dump configuration is enabled. Otherwise, an error is returned.
  • Only overflow/underflow data of AI Core operators can be collected.

Dump Watch Configuration for Operators

Set dump_scene to watcher to enable the operator dump watch mode. The following is an example of the configuration file: (1) After operators A and B are executed, the output of operators C and D is dumped. (2) After the C and D operators are executed, the output of the C and D operators is also dumped. Compare the dump files of operators C and D in (1) and (2) to check whether operators A and B overwrite the output memory of operators C and D.
{
    "dump":{
        "dump_list":[
            {
                "layer":["A", "B"],
                "watcher_nodes":["C", "D"]
            }
        ],
        "dump_path":"/home/",
        "dump_mode":"output",
        "dump_level":"op",
        "dump_scene":"watcher"
    }
}

The details are as follows:

Dump configuration of the operator kernel debugging information

Configure the dump_kernel_data parameter to enable the operator kernel debugging information dump function. The following is an example of the configuration file:

{
    "dump":{
        "dump_kernel_data":"printf,assert",
        "dump_path":"/home/"
    }
}

The details are as follows:

Example (Default Device Configuration)

Set the device ID in default_device, which can be 0 or a decimal positive integer. You can call aclrtGetDeviceCount to obtain the number of available devices. The value range of the device ID is [0, (Number of available devices – 1)].

The following gives a configuration example:

{
    "defaultDevice":{
        "default_device":"0"
    }
}

Example of AI Core Stack Size Configuration

Use aicore_stack_size to set the stack size, in bytes. The value must meet the following requirements:

The following gives a configuration example:

{
    "StackSize":{
        "aicore_stack_size":32768
    }
}

Configuration example of the SIMT operator stack size

simt_stack_size specifies the stack size of each thread of the SIMT operator. The unit is byte.

The simt_divergence_stack_size parameter is used to set the size of the branch (Divergence) stack space of the SIMT operator. The unit is byte.

The values of simt_stack_size and simt_divergence_stack_size must be an integer multiple of 128. If the input value is not a multiple of 128, the API automatically rounds up the value to ensure that it is a multiple of 128.

The following gives a configuration example:

{
  "StackSize": {      
    "simt_stack_size": 1024,            
    "simt_divergence_stack_size": 512   
  }
}

Example of configuring the size of the SIMT Printf maintenance and test space

The simt_printf_fifo_size parameter is used to set the size of the Printf maintenance and test space of the SIMT operator. The unit is byte. The value must be an integer multiple of 8. If the input value is not an integer multiple of 8, the API automatically rounds up the value to ensure that it is an integer multiple of 8.

The default value of simt_printf_fifo_size is 2 MB. The minimum value is 1 MB and the maximum value is 64 MB.

The following gives a configuration example:

{
  "simt_printf_fifo_size": 1048576
}

Example of configuring the size of the SIMD Printf maintenance and test space

The simd_printf_fifo_size_per_core parameter is used to set the size of the Printf maintenance and test space of the SIMD operator. The unit is byte. The value must be an integer multiple of 8. If the input value is not an integer multiple of 8, the API automatically rounds up the value to ensure that it is an integer multiple of 8.

The default value of simd_printf_fifo_size_per_core is 32 KB. The minimum value is 1 KB and the maximum value is 64 MB.

The following gives a configuration example:

{
  "simd_printf_fifo_size_per_core": 1048576
}

Reference

For the API call example, see Initialization and Deinitialization.

More flexible APIs are provided for enabling dump or profiling. Unlike aclInit, these APIs can be called repeatedly in a process, allowing varied dump/profiling configurations with each call.