快速入门
对于标准自定义算子工程场景,调测流程如图1所示,支持的调测功能有Tiling调测、CPU孪生调试、NPU编译生成kernel bin文件、NPU上板精度比对、NPU上板Profiling数据采集、性能仿真流水图等。
- 环境准备的具体步骤参见环境准备。
- 基于标准自定义算子工程,完成Ascend C自定义算子的开发和部署,具体指导参见《Ascend C自定义算子开发指南》中“算子开发 > 矢量编程(基于自定义算子工程)”章节。
- 准备好输入数据和标杆数据。可使用用户自行提供的bin格式数据文件,也可使用torch/numpy生成Tensor数据(具体参见API方式下数据准备说明)。
- 构建算子信息。
调用ascendebug.create_debug_op接口构造算子DebugOp对象 ,并设置输入/输出信息,示例如下:
import ascendebug debug_op = ascendebug.create_debug_op('AddCustom', 'VectorCore', 'Ascend910B1') \ .custom_input('x', 'int32', [32], '/path_to/x.bin') \ .custom_input('y', 'int32', [32], '/path_to/y.bin') \ .custom_output('z', 'int32', [32], '/path_to/z.bin') \ .attr('mask', 'list_int', [0,0]) \ .attr('memory', 'int', 0)
- 创建算子调试器对象,示例如下:
op_executor = ascendebug.create_op_executor(debug_op=debug_op, work_dir='./debug_workspace', install_path='/usr/local/Ascend')
- 构造调测接口输入参数,调用调测API接口,此处以Tiling调测功能为例。
customize_path ="${install_path}/latest/opp/vendors/${custom_name}" tiling_info = op_executor.run_custom_tiling(customize_path)
使用的API接口列表
调测使用的API |
说明 |
---|---|
根据输入的op_type、core_type等信息构造DebugOp对象,管理算子相关描述信息。 |
|
构建调测对象,完成工作空间初始化,设置环境变量等调测相关的操作。 |
|
标准自定义算子工程场景的Tiling调测接口。 |
|
标准自定义算子工程场景的算子CPU侧编译和运行接口。 |
|
标准自定义算子工程场景的算子NPU侧编译接口,生成kernel.o编译产物。 |
|
通用的算子NPU上板运行接口。 |
|
通用的CAModel运行接口。 |
|
通用的Profiling运行接口。 |
父主题: 标准自定义算子工程场景的算子调测示例