2020-11-21 09:03:23 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
# This file is licensed under a pytorch-style license
|
|
|
|
# See frontends/pytorch/LICENSE for license information.
|
|
|
|
|
|
|
|
import torch
|
|
|
|
import torch_mlir
|
|
|
|
|
|
|
|
# RUN: %PYTHON %s | FileCheck %s
|
|
|
|
|
2020-11-24 06:41:30 +08:00
|
|
|
mb = torch_mlir.ModuleBuilder()
|
|
|
|
|
2021-03-02 09:24:15 +08:00
|
|
|
# CHECK-LABEL: func @__torch__.add3
|
2020-11-24 06:41:30 +08:00
|
|
|
# Note that line-level debug information for parts unannotated in the Torch
|
|
|
|
# graph are ascribed to the first op that carries source information. Presently
|
|
|
|
# this includes naked constants, return and the function itself. This heuristic
|
|
|
|
# likely needs to be improved and this test should be reworked when it is.
|
|
|
|
@mb.import_function
|
2020-11-21 09:03:23 +08:00
|
|
|
@torch.jit.script
|
|
|
|
def add3(t0, t1, t2):
|
2020-12-15 00:42:42 +08:00
|
|
|
# TODO: Checks for debug info are quite hard with the new trailing debug
|
|
|
|
# attribute print. See if this can be improved.
|
2021-02-02 09:01:18 +08:00
|
|
|
# CHECK: loc({{.*}}debug-info.py":[[# @LINE + 1]]
|
2020-11-21 09:03:23 +08:00
|
|
|
intermediate = t0 + t1
|
2021-02-02 09:01:18 +08:00
|
|
|
# CHECK: loc({{.*}}debug-info.py":[[# @LINE + 1]]
|
2020-11-21 09:03:23 +08:00
|
|
|
final = intermediate + t2
|
|
|
|
return final
|
|
|
|
|
|
|
|
# Verify again with debug info present. Just checking that it makes it in there.
|
|
|
|
mb.module.operation.print(enable_debug_info=True)
|
|
|
|
print()
|