文档
注册

核函数CPU孪生调试

CPU孪生调试支持自动精度比对、仿真内存校验和异常检测(npucheck)等功能,全量功能和参数介绍参见CPU调测功能

本场景以AddCustom算子为例,假设输入数据和标杆数据是用户自行提供的bin文件,核函数CPU调测过程如下。请根据自身实际情况,按需修改示例代码。

import torch
import numpy as np
import ascendebug

# 设置和清理日志文件
ascendebug.set_log_file('test.log', clean=True)

# 1.导入输入/标杆数据,构建算子信息
debug_op = ascendebug.create_debug_op('AddCustom', 'VectorCore', 'Ascendxxx') \
	.custom_input('x', 'int32', [32], '/data_path/x.bin') \
	.custom_input('y', 'int32', [32], '/data_path/y.bin') \
	.custom_output('z', 'int32', [32], '/data_path/z.bin') \
	.attr('mask', 'list_int', [0,0]) \
	.attr('repeatTimes', 'int', 1) \
	.attr('dstBlkStride', 'int', 1) \
	.attr('src0BlkStride', 'int', 1) \
	.attr('src1BlkStride', 'int', 1) \
	.attr('dstRepStride', 'int', 8) \
	.attr('src0RepStride', 'int', 8) \
	.attr('src1RepStride', 'int', 8) \
	.attr('calCount', 'int', 3) \
	.attr('memory', 'int', 0)

# 2.创建调试对象并初始化工作空间
install_pkg = "/usr/local/Ascend/"
customize_path = "/usr/local/Ascend/latest/opp/vendors/add_custom"
op_executor = ascendebug.create_op_executor(debug_op=debug_op, install_path=install_pkg)

# 3.调用Tiling调测接口(可选,若已有Tiling bin文件可跳过本步骤)
tiling_info = op_executor.run_custom_tiling(customize_path)

# 4.调用CPU编译运行接口,在CPU上仿真运行核函数,完成精度比对
cpu_options = ascendebug.CpuOptions()
op_executor.run_custom_cpu(customize_path, tiling_info, cpu_options)

算子在CPU侧的孪生调试结果示例可以参见“CPU调测功能 > 调测产物”。

搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词