Description
Initializes AscendCL. This API is synchronous.
Restrictions
- aclInit can be called only once per process.
- aclInit must be called before app development using AscendCL APIs. Otherwise, errors may occur during the initialization of internal resources, causing service exceptions.
Prototype
aclError aclInit(const char *configPath)
Parameters
Parameter |
Input/Output |
Description |
configPath |
Input |
Pointer to the 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 initial configurations, pass NULL or an empty JSON configuration file with only a pair of curly brackets {} to the aclInit call. The configuration file is in JSON format. The following configurations are supported:
- Dump configuration involves the model, single-operators, and overflow/underflow operators.
- 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 "Data Preparation > Inference Scenarios > Preparing Dump Data of an Offline Model (AscendCL) in Model Accuracy Analyzer Instructions. The dump configuration is disabled by default.
- Overflow/Underflow operator dump configuration (used to export the input and output data of overflow/underflow operators in the model): The exported data is used to analyze overflow/underflow operator causes and locate model accuracy issues. For details about the configuration example, description, and restrictions, see Configuration File Example (Overflow/Underflow Operator Dump Configuration). The dump configuration is disabled by default. Reserved.
- Profiling configuration. For the configuration example, description, and restrictions, see Profiling Instructions. Profiling is disabled by default.
- Operator cache aging configuration. To reduce the memory footprint and balance the call 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 10000. For the configuration example and restrictions, see Configuration File Example (Operator Cache Aging Configuration).
Dump configuration and profiling configuration are mutually exclusive. The dump operation could affect system performance, resulting in inaccurate profile data collected by Profiling. |
Returns
0 on success; else, failure.
Configuration File Example (Overflow/Underflow Operator Dump Configuration)
Note the following restrictions on the overflow/underflow operator dump configuration:
The following gives a configuration example.
{
"dump":{
"dump_path":"output",
"dump_debug":"on"
}
}
Configuration File Example (Operator Cache Aging Configuration)
Note the following restrictions on the operator cache aging configuration:
- For an operator that is statically loaded, when aclopSetModelDir is called to load a single-operator model in the specified directory, or aclopLoad is called to load a single-operator model, the aging configuration is invalid. That is, the operator information is not aged.
- For online operator compilation, when the aclopCompile API is called to compile an operator or the aclopCompileAndExecute API is called to compile and execute an operator, the API call loads the single-operator model based on the passed arguments, and the aging configuration takes effect.
If an operator is compiled and executed by using aclopCompile and aclopExecute/aclopExecuteV2, promptly execute the operator in case the operator information is aged. In this case, you will need to recompile the operator. You are advised to use aclopCompileAndExecute instead, which completes operator compilation and execution as one action.
- AscendCL maintains two mapping queues, one for static-shape and the other for dynamic-shape operators. However, their maximum lengths are both determined by the max_opqueue_num parameter.
- The value of max_opqueue_num is the sum of the number of single-operator models with statically loaded operators and the number of single-operator models with operators compiled online. Therefore, the value of max_opqueue_num must be greater than the number of single-operator models with statically loaded operators that are available in the current process; otherwise, the information about operators compiled online cannot be aged.
The following gives a configuration example.
{
"max_opqueue_num": "10000"
}
Related APIs
AscendCL provides more flexible APIs for enabling Dump or Profiling. Unlike aclInit, these APIs can be called repeatedly in a process, allowing varied Dump/Profiling configurations with each call.