文档
注册

上板Profiling数据采集

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

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', 'Ascend310P') \
	.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/ascend-toolkit/"
customize_path = "/usr/local/Ascend/ascend-toolkit/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.调用NPU编译接口
compile_npu_options = ascendebug.CompileNpuOptions()
name, kernel_file, extern = op_executor.compile_custom_npu(customize_path, tiling_info.tiling_key, compile_npu_options)

# 5.完成Profiling的Options配置,调用Profiling运行接口
profiling_options = ascendebug.RunProfilingOptions(block_num=24, loop=10)
npu_compile_info = ascendebug.NpuCompileInfo(syncall=extern['cross_core_sync'], task_ration=extern['task_ration'])
op_executor.run_profiling(kernel_file, profiling_options, npu_compile_info=npu_compile_info, tiling_info=tiling_info)

关于算子在NPU板端执行Profiling以及最终采集结果的分析,可以参见“Profiling数据采集功能 > 调测产物”。

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

当前产品无相关内容

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