目录

DumpTensor

Function Description

When the tool is used for operator debugging, the DumpTensor function is supported. By default, the element value of a specified length is printed starting from element 0 of the tensor.

  • DumpTensor in the simulator debugging scenario is controlled by the dump mode parameter.

  • The maximum available space allocated to each core for printing data is fixed at 1 MB. If the printing size exceeds 1 MB, the printed content will not be displayed. Therefore, the amount of data to be printed needs to be controlled.

Procedure (CLI-based)

  1. Call the DumpTensor API at the target position in the kernel code as required. For details about the API description, see Table 1. The following is an example:

    DumpTensor(srcLocal, 5, dataNum);
  2. In the simulator debugging scenario, run the following command to enable the dump function:

    ascendebug kernel --backend simulator --dump-mode normal ... {other simulator debugging parameters}

    --Set dump-mode to normal to enable the general printing Tensor mode. Set other parameters by referring to NPU Debugging Parameters.

  3. View the dump result. For details, see Artifact Description.

API Description

The DumpTensor API is described as follows:

Artifact Description

The dumped tensor data is stored in the ${root}/${work_dir}/simulator directory. ${root} indicates the current operation path, ${work_dir} indicates the debugging workspace, and the default directory is /debug_workspace/${op_type}. ${op_type} indicates the operator name. The directory structure is as follows:

├ ${op_type} // Operator name
├── simulator
│   ├── dump
│       ├── PARSER_${timestamp}
│           ├── dump_data
│               ├──0 // Core ID
│                   ├──index_5 // **index** is the unique identifier of the dump API description.
│                       ├──core_0_index_5_loop_0.bin
│                       ├──core_0_index_5_loop_0.txt
│                       ├──core_0_index_5_loop_1.bin
│                       ├──core_0_index_5_loop_1.txt
│               ├──index_dtype.json // Storing the data type of each dump tensor

core_${core_id}_index_${index}_loop_${loop}.txt is the dump result automatically parsed by the tool based on the .bin file. The naming rules are as follows: