昇腾社区首页
中文
注册

通过torch生成数据

用户可以通过torch框架生成Tensor数据作为输入数据/标杆数据,然后调用tensor_xxx接口导入,output数据落盘文件名为{name}_output.bin便于区分input数据。

  • 输入/输出不同地址(非原地算子
    import torch
    import ascendebug
    # 生成输入/标杆数据
    x = torch.rand(size=(1, 16384), dtype=torch.float16)
    y = torch.rand(size=(1, 16384), dtype=torch.float16)
    z = x + y
    # 配置输入数据
    debug_op = ascendebug.create_debug_op('add_custom').tensor_input('x', x) .tensor_input('y', y).tensor_output('z', z)
  • 输入/输出同地址(原地算子
    import torch
    import ascendebug
    # 生成输入/标杆数据
    x = torch.rand(size=(1, 16384), dtype=torch.float16)
    y = torch.rand(size=(1, 16384), dtype=torch.float16)
    z = x + y
    # 配置输入数据
    debug_op = ascendebug.create_debug_op('add_custom').tensor_input('x', x) .tensor_input('y', y).tensor_output('x', z)