Skip to content

Commit

Permalink
Add more debug info to DaCe (pass SourceLocation from past/foast to i…
Browse files Browse the repository at this point in the history
…tir, and from itir to the SDFG): Preserve Location through Visitors
  • Loading branch information
kotsaloscv committed Jan 12, 2024
1 parent 6fb28a1 commit 3f4e9d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/gt4py/next/iterator/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@noninstantiable
class Node(eve.Node):
location: Optional[SourceLocation] = None
location: Optional[SourceLocation] = eve.field(default=None, repr=False)

def __str__(self) -> str:
from gt4py.next.iterator.pretty_printer import pformat
Expand Down
18 changes: 9 additions & 9 deletions src/gt4py/next/iterator/transforms/inline_lifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def _generate_unique_symbol(
else:
desired_name = f"__arg{arg_idx}"

new_symbol = desired_name
new_symbol = ir.Sym(id=desired_name)
# make unique
while new_symbol.id in occupied_names or new_symbol in occupied_symbols:
new_symbol = new_symbol + "_"
new_symbol = ir.Sym(id=new_symbol.id + "_")
return new_symbol


Expand Down Expand Up @@ -73,7 +73,7 @@ def _is_scan(node: ir.FunCall):
def _transform_and_extract_lift_args(
node: ir.FunCall,
symtable: dict[eve.SymbolName, ir.Sym],
extracted_args: dict[eve.SymbolName, ir.Expr],
extracted_args: dict[ir.Sym, ir.Expr],
):
"""
Transform and extract non-symbol arguments of a lifted stencil call.
Expand All @@ -89,8 +89,8 @@ def _transform_and_extract_lift_args(
new_args = []
for i, arg in enumerate(node.args):
if isinstance(arg, ir.SymRef):
sym = arg.id
assert sym not in extracted_args or extracted_args[sym].id == arg.id
sym = ir.Sym(id=arg.id)
assert sym not in extracted_args or extracted_args[sym] == arg
extracted_args[sym] = arg
new_args.append(arg)
else:
Expand All @@ -101,7 +101,7 @@ def _transform_and_extract_lift_args(
)
assert new_symbol not in extracted_args
extracted_args[new_symbol] = arg
new_args.append(ir.SymRef(id=new_symbol))
new_args.append(ir.SymRef(id=new_symbol.id))

itir_node = im.lift(inner_stencil)(*new_args)
itir_node.location = node.location
Expand Down Expand Up @@ -226,7 +226,7 @@ def visit_FunCall(
# TODO(tehrengruber): we currently only inlining opcount preserving, but what we
# actually want is to inline whenever the argument is not shifted. This is
# currently beyond the capabilities of the inliner and the shift tracer.
new_arg_exprs: dict[eve.SymbolName, ir.Expr] = {}
new_arg_exprs: dict[ir.Sym, ir.Expr] = {}
inlined_args = []
for i, (arg, eligible) in enumerate(zip(node.args, eligible_lifted_args)):
if eligible:
Expand All @@ -237,7 +237,7 @@ def visit_FunCall(
inlined_args.append(inlined_arg)
else:
if isinstance(arg, ir.SymRef):
new_arg_sym = arg.id
new_arg_sym = ir.Sym(id=arg.id)
else:
new_arg_sym = _generate_unique_symbol(
desired_name=(stencil, i),
Expand All @@ -246,7 +246,7 @@ def visit_FunCall(
)

new_arg_exprs[new_arg_sym] = arg
inlined_args.append(ir.SymRef(id=new_arg_sym))
inlined_args.append(ir.SymRef(id=new_arg_sym.id))

inlined_call = self.visit(
inline_lambda(
Expand Down

0 comments on commit 3f4e9d1

Please sign in to comment.