目录

Tiling Debugging

Function Description

Tiling is an independent and essential part of operator development, which describes the input/output data tiling of operators, block computing, and AI Core parallelism on the NPU IP accelerator of the Kirin AI SoC. It meets on-chip storage restrictions and computing pipeline requirements and maximizes computing parallelism and data locality (or data reuse), achieving ultimate hardware performance.

For single-operator, tiling computation is performed based on the tiling .so file to generate a tiling .bin file.

Currently, tiling debugging is required only for standard custom operator projects, ops_adv operator projects, built-in projects, and inner-source framework projects.

Procedure (CLI-based)

The key steps for performing tiling debugging on the CLI are as follows. For details, see the tiling debugging function.

  1. Set up the environment and prepare the input/golden data file.

  2. Run the following command to perform tiling debugging. Only key parameters are provided. For details about other parameters, see Tiling Debugging Parameters.

    Standard custom operator scenario:

    ascendebug tiling --json-file {op_config_json_file } --chip-version ${chip_version} --work-dir ${work_dir} ... {other parameters}

    To view all parameters involved in tiling debugging, you can use ascendebug tiling -h or ascendebug tiling --help.

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

Artifact Description

The tiling debugging result is stored in the ${root}/${work_dir}/tiling directory. ${root} indicates the current operation path, ${work_dir} indicates the debugging workspace which defaults to the /debug_workspace/${op_type} directory, and ${op_type} indicates the operator name. The artifacts generally include the tiling data bin file (binary) and structure parsing file. The following is an example of the directory structure. For details about the result files, see Table 1.

├ ${op_type} // Operator name
├── tiling
│   ├── attrs.json
│   ├── inputs.json
│   ├── outputs.json
│   ├── tiling_data_tiling_key_2_block_dim_1_workspace_106258432.bin
│   ├── tiling_parse_result.json
│   ├── tiling_run_info.bin

Table 1 Tiling debugging result description

File Name Description
attrs.json Intermediate files generated based on operator attributes and input/output information.
inputs.json Intermediate files generated based on operator attributes and input/output information.
outputs.json Intermediate files generated based on operator attributes and input/output information.
tiling_data_tiling_key_2_block_dim_1_workspace_106258432.bin

Tiling data .bin file, used for CPU and simulator debugging.

Note: The file name tiling_key_2_block_dim_1_workspace_106258432 indicates tiling_key=2, block_num=1, and workspace=106258432. This information can be used for subsequent kernel compilation and running (for example, --block-num equals block_dim).

tiling_parse_result.json Parsing result file of tiling data. A tiling structure file is generated, which displays dtype and value of each tiling data.
tiling_run_info.bin Information file generated by tiling debugging, including block_dim, workspace size, and tiling_key. The key information of this file has been mapped to the name of the tiling data .bin file.