使用工具进行算子调测时,支持DumpTensor功能,默认从Tensor的第0位元素开始打印指定长度的元素值。
DumpTensor(srcLocal, 5, dataNum);
compile_npu_options = ascendebug.CompileNpuOptions(dump_mode='normal') name, kernel_file, extern = op_executor.compile_custom_npu(customize_path, tiling_info.tiling_key, compile_npu_options) npu_compile_info = ascendebug.NpuCompileInfo(syncall=extern['cross_core_sync'], task_ration=extern['task_ration'], dump_mode='normal') run_npu_options = ascendebug.RunNpuOptions() op_executor.run_npu(kernel_file, run_npu_options, npu_compile_info=npu_compile_info, tiling_info=tiling_info)
Dump的Tensor数据存放在${root}/${work_dir}/npu路径下,其中${root}表示当前操作路径,${work_dir}表示调测工作空间,默认为/debug_workspace/${op_type}目录,${op_type}为算子名。目录结构示例如下:
├ ${op_type} // 算子名 ├── npu │ ├── dump │ ├── PARSER_${timestamp} │ ├── dump_data │ ├──0 // core number │ ├──index_5 // index是dump接口的desc唯一标识值 │ ├──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 // 存放每个dump Tensor的数据类型
其中core_${core_id}_index_${index}_loop_${loop}.txt是工具根据bin文件自动解析的Dump结果,其命名规则为:
函数原型 |
|
|
函数功能 |
从Tensor的第0位元素开始打印指定长度的元素值。 |
|
参数(IN) |
tensor |
用户需要Dump的Tensor。多个DumpTensor调用时,不可重复。
|
desc |
用户自定义附加信息(行号或其他自定义数字)。 |
|
dumpNum |
需要Dump的元素个数。 |
|
shapeInfo |
如果有Tensor的shape信息,工具可解析shapeInfo并进行打印。 |
|
参数(OUT) |
NA |
- |
返回值 |
NA |
- |
使用约束 |
|
|
调用示例 |
|