文档
注册

快速入门

对于标准自定义算子工程场景,调测流程如图1所示,支持的调测功能有Tiling调测、CPU孪生调试、NPU编译生成kernel bin文件、NPU上板精度比对、NPU上板Profiling数据采集、性能仿真流水图等。

图1 标准自定义算子工程场景API调用流程
  1. 环境准备的具体步骤参见环境准备
  2. 基于标准自定义算子工程,完成Ascend C自定义算子的开发和部署,具体指导参见Ascend C自定义算子开发指南中“算子开发 > 矢量编程(基于自定义算子工程)”章节。
  3. 准备好输入数据和标杆数据。可使用现成的bin格式数据文件,也可使用torch/numpy生成Tensor数据(具体参见API方式下数据准备说明)。
  4. 构建算子信息。

    调用ascendebug.create_debug_op接口构造算子DebugOp对象 ,并设置输入/输出信息,示例如下:

    import ascendebug
    debug_op = ascendebug.create_debug_op('AddCustom', 'VectorCore', 'Ascendxxx') \
            .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)
  5. 创建算子调试器对象,示例如下:
    op_executor = ascendebug.create_op_executor(debug_op=debug_op, work_dir='./debug_workspace', install_path='/usr/local/Ascend')
  6. 构造输入参数,调用调测功能API,以Tiling调测接口为例。
    customize_path ="/usr/local/Ascend/latest/opp/vendors/${custom_name}"
    tiling_info = op_executor.run_custom_tiling(customize_path)

使用的API接口列表

本场景涉及的所有调测API如表1所示。

表1 标准自定义工程场景的调测API列表

调测使用的API

说明

create_debug_op

根据输入的op_type、core_type等信息构造DebugOp对象,管理算子相关描述信息。

create_op_executor

构建调测对象,完成工作空间初始化,设置环境变量等调测相关的操作。

run_custom_tiling

标准自定义算子工程场景的Tiling调测接口。

run_custom_cpu

标准自定义算子工程场景下算子CPU侧编译和运行接口。

compile_custom_npu

标准自定义算子工程场景下算子NPU侧编译接口,生成kernel.o编译产物。

run_npu

通用的算子NPU上板运行接口。

run_camodel

通用的CAModel运行接口。

run_profiling

通用的Profiling运行接口。

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

当前产品无相关内容

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