对于标准自定义算子工程场景,调测流程如图1所示,支持的调测功能有Tiling调测、CPU孪生调试、NPU编译生成kernel bin文件、NPU上板精度比对、NPU上板Profiling数据采集、性能仿真流水图等。
调用ascendebug.create_debug_op接口构造算子DebugOp对象 ,并设置输入/输出信息,示例如下:
import ascendebug debug_op = ascendebug.create_debug_op('AddCustom', 'VectorCore', '${chip_version}') \ .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/ascend-toolkit')
customize_path ="/usr/local/Ascend/ascend-toolkit/latest/opp/vendors/${custom_name}" tiling_info = op_executor.run_custom_tiling(customize_path)
本场景涉及的所有调测API如表1所示。