Function: set_dump
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
Sets dump parameters.
Prototype
- C Prototype
1aclError aclmdlSetDump(const char *dumpCfgPath)
- Python Function
1ret = acl.mdl.set_dump(dump_cfg_path)
Parameter Description
|
Parameter |
Description |
|---|---|
|
dump_cfg_path |
Currently, the following dump information can be configured: (If the operator input or output contains sensitive user information, information leakage may occur.)
|
Return Value Description
|
Return Value |
Description |
|---|---|
|
ret |
Int, error code: 0 on success; else, failure. |
Restrictions
- acl.mdl.init_dump needs to be called in conjunction with acl.mdl.set_dump and acl.mdl.finalize_dump to dump data to files. These APIs can be called for multiple times in a single process to obtain dump data of different Dump configurations.
- Example scenario:
- To execute two models, you need to set dump information differently. The API call sequence is as follows: acl.init --> acl.mdl.init_dump --> acl.mdl.set_dump --> model loading --> model execution --> acl.mdl.finalize_dump --> model unloading --> acl.mdl.init_dump --> acl.mdl.set_dump --> model loading --> model execution --> acl.mdl.finalize_dump --> model unloading --> execution of other tasks --> acl.finalize.
- 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: acl.init --> acl.mdl.init_dump --> acl.mdl.set_dump --> model loading --> model execution --> acl.mdl.finalize_dump --> model unloading --> model loading --> model execution --> execution of other tasks --> acl.finalize
- 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 models loaded before this API call unless you reload the models after this API call.
For example, in the following API calling sequence, the dump configuration is valid only for model 2.
acl.mdl.init_dump --> model 1 loading --> acl.mdl.set_dump --> model 2 loading --> acl.mdl.finalize_dump
- If this API is called repeatedly to set the dump configuration for the same model, the most recent configuration is applied.
For example, in the following API call sequence, the second dump configuration call overwrites the first call:
acl.mdl.init_dump --> acl.mdl.set_dump --> acl.mdl.set_dump --> model 1 loading --> acl.mdl.finalize_dump
Reference
The acl.init API is also provided. During initialization, the dump configuration is passed as a JSON configuration file to dump the app data at run time. In this mode, the acl.init API can be called only once in a process. To modify the dump configuration, you need to modify the configuration in the JSON file.
Dump Watch Configuration for Operators
Set dump_scene to watcher to enable dump watch for operators. Below is an example of the content in the configuration file. The configuration effect is as follows: (1) After operators A and B are executed, the output of operators C and D is dumped; (2) After operators C and D are executed, the output of operators C and D is also dumped. The dump files of operators C and D in (1) will be compared with those in (2) to check whether operator A or B overwrites the output memory of operator C or D.
{
"dump":{
"dump_list":[
{
"layer":["A", "B"],
"watcher_nodes":["C", "D"]
}
],
"dump_path":"/home/",
"dump_mode":"output",
"dump_scene":"watcher"
}
}
The details 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. Dump watch cannot be applied 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 unspecified, 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), only the dump file of the operator configured for watcher_node is 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 exported dump files cannot be viewed using a text tool. To view the content of a dump file, 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.
dump_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.