核函数NPU上板打印
- 核函数NPU上板验证时,支持打印Scalar和Tensor数据。
- 打印Scalar数据
- 在核函数代码中目标位置按需加上printf或PRINTF语句,以printf为例:
printf("1 fmt string d %d\n", 6666); printf("1 fmt string lf %lf\n", double(61.556));
- 执行如下命令,使能Dump开关。
ascendebug kernel --backend npu --json-file ${op_config_json_file} --chip-version ${chip_version} --repo-type customize --customize-path ${cann_install_path}/latest/opp/vendors/${vendor_name} --core-type ${core_type} --dump-mode normal
其中--dump-mode用于设置上板打印模式,此处设为normal,开启通用打印方式,其他命令参数的配置与核函数NPU上板精度验证保持一致。
- 在核函数代码中目标位置按需加上printf或PRINTF语句,以printf为例:
- 打印Tensor数据
- 在核函数代码中调用DumpTensor接口说明,样例如下:
DumpTensor(srcLocal,5, dataNum);
- 执行如下命令,使能Dump开关。
ascendebug kernel --backend npu --json-file ${op_config_json_file} --chip-version ${chip_version} --repo-type customize --customize-path ${cann_install_path}/latest/opp/vendors/${vendor_name} --core-type ${core_type} --dump-mode normal
其中--dump-mode用于设置上板打印模式,此处设为normal,开启通用打印方式,其他命令参数的配置与核函数NPU上板精度验证保持一致。
- 在核函数代码中调用DumpTensor接口说明,样例如下:
- 打印Scalar数据
- 查看打印结果。
父主题: 精度调试