Skip to content

Commit

Permalink
Use all frames of the stack trace when importing
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinath Avadhanula committed Mar 4, 2025
1 parent 32feea5 commit 5d83f60
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/torch_mlir/extras/fx_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,12 @@ def get_node_location(self, node: torch_fx.Node) -> Optional[Location]:
# https://github.com/pytorch/pytorch/issues/91000
stack_trace = node.stack_trace
if stack_trace:
m = re.search(r"""File "([^"]+)", line ([0-9]+),""", stack_trace)
if m:
filename, line = m.group(1), int(m.group(2))
return Location.file(filename, line, col=0, context=self._c)
matches = re.findall(r"""File "([^"]+)", line ([0-9]+),""", stack_trace)
locations = [Location.file(m[0], int(m[1]), col=0, context=self._c) for m in matches]
if len(locations) > 1:
return Location.callsite(locations[-1], locations[-2::-1], context=self._c)
elif len(locations) == 1:
return locations[0]
return Location.unknown(context=self._c)

def set_symbolic_guards(
Expand Down

0 comments on commit 5d83f60

Please sign in to comment.