aclmdlSetDump
Description
Sets dump parameters.
- To execute two different models, you need to set dump configurations differently. The API call sequence is as follows: aclInit --> aclmdlInitDump --> aclmdlSetDump --> model 1 loading --> model 1 execution --> aclmdlFinalizeDump --> model 1 unloading --> aclmdlInitDump --> aclmdlSetDump --> model 2 loading --> model 2 execution --> aclmdlFinalizeDump --> model 2 unloading --> execution of other tasks --> aclFinalize
- To execute the same model twice, you only need to perform the dump operation for the first execution. The API call sequence is as follows: aclInit --> aclmdlInitDump --> aclmdlSetDump --> model loading --> model execution --> aclmdlFinalizeDump --> model unloading --> model loading --> model execution --> execution of other tasks --> aclFinalize
Restrictions
- The configured dump information is valid only when the model is loaded after the dump function is enabled by calling this API. The dump configuration does not take effect on a model loaded before this API call unless you reload the model after this API call.
For example, in the following API call sequence, the dump configuration is valid only for model 2:
aclmdlInitDump --> model 1 loading --> aclmdlSetDump --> model 2 loading --> aclmdlFinalizeDump
- If this API is called repeatedly to set dump configuration for the same model, the most recent configuration is applied.
For example, in the following API call sequence, the dump configuration of the later call overwrites that of the previous call.
aclmdlInitDump --> aclmdlSetDump --> aclmdlSetDump --> model 1 loading --> aclmdlFinalizeDump
Prototype
aclError aclmdlSetDump(const char *dumpCfgPath)
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
dumpCfgPath |
Input |
Pointer to the configuration file path, including the file name. The configuration file is in JSON format.
Currently, the following dump information can be configured:
|
Configuration File Example (Model Dump and Single-Operator Dump)
Model dump configuration example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
{ "dump":{ "dump_list":[ { "model_name":"ResNet-101" }, { "model_name":"ResNet-50", "layer":[ "conv1conv1_relu", "res2a_branch2ares2a_branch2a_relu", "res2a_branch1", "pool1" ] } ], "dump_path":"$HOME/output", "dump_mode":"output", "dump_op_switch":"off", "dump_data":"tensor" } } |
The following is an example of dump configuration of the single-operator model execution mode in the single-operator dump scenario:
1 2 3 4 5 6 7 8 |
{ "dump":{ "dump_path":"output", "dump_list":[], "dump_op_switch":"on", "dump_data":"tensor" } } |
The following is an example of dump configuration of the single-operator API execution mode in the single-operator dump scenario:
1 2 3 4 5 6 7 |
{ "dump":{ "dump_path":"output", "dump_list":[], "dump_data":"tensor" } } |
Configuration File Example (Exception Operator Dump Configuration)
If dump_scene is set to lite_exception or lite_exception_with_shape, the dump function of abnormal operators is enabled. In addition, the ASCEND_WORK_PATH environment variable can be used to configure the dump path. Otherwise, the dump path is the current execution directory of the application.
Note:
- The dump configuration of the abnormal operator cannot be enabled together with the model dump configuration or single-operator dump configuration. Otherwise, the model dump or single-operator dump does not take effect.
- lite_exception_with_shape is a trial feature and may be changed in later versions. It cannot be used in commercial products. The difference between lite_exception_with_shape and lite_exception is that in the graph scenario, lite_exception_with_shape can be used to export a dump file with the operator shape information.
The following gives a configuration example:
{
"dump":{
"dump_scene":"lite_exception"
}
}
The collected dump files cannot be viewed using a text tool. To view the dump file content, convert the dump file to a NumPy file and then view the NumPy file using Python. For details about the conversion procedure, see ""Viewing Dump Files" " in Accuracy Debugging Tool Guide.
Configuration File Example (Overflow/Underflow Operator Dump Configuration)
- If dump_debug is set to on, the overflow/underflow operator configuration is enabled. If dump_debug is not set or set to off, the overflow/underflow operator configuration is disabled.
- If this configuration is enabled, dump_path, which is the directory for storing exported data files, must be set.
The path can be either absolute or relative.
- An absolute path starts with a slash (/), for example, /home.
- A relative path starts with a directory name, for example, output.
- The overflow/underflow operator configuration cannot be enabled if the model dump configuration or single-operator dump configuration is enabled. Otherwise, an error is returned.
- Only overflow/underflow data of AI Core operators can be collected.
{
"dump":{
"dump_path":"output",
"dump_debug":"on"
}
}
For details about how to parse the exported data file, see Overflow/Underflow Operator Data Collection and Analysis in Accuracy Debugging Tool Guide.
Configuration File Example (Configuration for Operator Dump Watch Mode)
Set dump_scene to watcher to enable the operator dump watch mode. The configuration description and restrictions are as follows:
- If the operator dump watch mode is enabled, the overflow/underflow operator dump (by configuring the dump_debug parameter) or the single-operator model dump (by configuring the dump_op_switch parameter) cannot be enabled. Otherwise, an error will be reported. This mode does not take effect in the single-operator API dump scenario.
- In dump_list, the layer parameter is used to configure the names of the operators that may overwrite the memory of other operators, and the watcher_nodes parameter is used to configure the names of the operators with accuracy issues possibly due to output memory being overwritten by other operators.
- If layer is specified, the output of the operators configured for watcher_nodes is dumped after all operators that support dump in the model are executed.
- If an operator configured for layer and watcher_node is not in the static graph and static subgraph, the configuration does not take effect.
- If an operator name configured for layer and watcher_node is duplicate, or an operator configured for layer is a collective communication operator (the operator type starts with Hcom, for example, HcomAllReduce), no dump file will be exported.
- For a fusion operator, its name configured for watcher_node must be the name of the operator after fusion. If the name of an operator before fusion is configured, no dump file will be exported.
- Currently, model_name cannot be configured in dump_list.
- If the operator dump watch mode is enabled, dump_path, which is the path for storing the exported dump file, must be configured.
The path can be either absolute or relative.
- An absolute path starts with a slash (/), for example, /home.
- A relative path starts with a directory name, for example, output.
- dump_mode is used to specify the data of the operators configured for watcher_nodes to be exported. Currently, only output can be configured.
The following is an example of the content in the configuration file. The configuration effect is as follows: After operators A and B are executed, the output of operators C and D is dumped, and the following four dump files are dumped to check whether operator A or B overwrites the output memory of operator C or D: opType.A_To_C.* (operator C), opType.A_To_D.* (operator D), opType.B_To_C.* (operator C), and opType.B_To_D.* (operator D).
{
"dump":{
"dump_list":[
{
"layer":["A", "B"],
"watcher_nodes":["C", "D"]
}
],
"dump_path":"/home/",
"dump_mode":"output",
"dump_scene":"watcher"
}
}
The collected dump files cannot be viewed using a text tool. To view the dump file content, convert the dump file to a NumPy file and then view the NumPy file using Python. For details about the conversion procedure, see "Viewing Dump Files" in Accuracy Debugging Tool Guide.
Returns
The value 0 indicates success, and other values indicate failure. For details, see aclError.
Related APIs
AscendCL also provides the aclInit API. During AscendCL initialization, the dump configuration is passed as a JSON configuration file to dump the app data at run time. In this mode, aclInit can be called only once in a process. To change the dump configuration, modify the JSON configuration file.