Skip to content

Commit 98b50d6

Browse files
debug
1 parent 9bccfb3 commit 98b50d6

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

tripy/tripy/backend/mlir/compiler.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def layer_metadata_callback(op):
119119
if name in flat_ir.tensor_map:
120120
tensor = flat_ir.tensor_map[name]
121121
# TODO: Decide what to use here:
122-
# return _make_stack_info_message(tensor.stack_info, enable_color=False)
122+
return _make_stack_info_message(tensor.stack_info, enable_color=False)
123123
return ""
124124
user_frame_index = tensor.stack_info.get_first_user_frame_index()
125125
last_tp_frame = tensor.stack_info[user_frame_index - 1]
@@ -136,7 +136,10 @@ def _layer_meta_callback(op):
136136
# print(out)
137137
return out
138138

139-
opts = self._make_mlir_opts(self.trt_builder_opt_level, _layer_meta_callback)
139+
# opts = self._make_mlir_opts(self.trt_builder_opt_level, _layer_meta_callback)
140+
opts = self._make_mlir_opts(self.trt_builder_opt_level, layer_metadata_callback)
141+
# ================= 1764 passed, 53 skipped, 2842 deselected in 71.40s (0:01:11) =================
142+
# opts = self._make_mlir_opts(self.trt_builder_opt_level)
140143

141144
try:
142145
with redirect_stderr() as outfile:

tripy/tripy/utils/stack_info.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,40 +49,42 @@ def is_user_frame(self):
4949
module = self.module or ""
5050
return "tripy" not in module.split(".")
5151

52+
def fetch_source_code(self):
53+
if self.code is not None:
54+
return
55+
56+
# Note that in some cases, e.g. when code is being provided via the interactive shell, we may not be able to retrieve it.
57+
# In that case we just leave it empty.
58+
try:
59+
lines = open(self.file, "r").readlines()
60+
except OSError:
61+
self.code = ""
62+
else:
63+
self.code = lines[self.line - 1].rstrip()
64+
5265

5366
class StackInfo(list):
5467
def __init__(self, lst, include_code_index: Optional[int] = None):
5568
super().__init__(lst)
5669
self.include_code_index = include_code_index
57-
self.code_fetched = False
70+
self._code_fetched = False
5871

5972
def fetch_source_code(self):
60-
if self.code_fetched:
73+
if self._code_fetched:
6174
return
6275

6376
first_user_frame_found = False
6477
for index, source_info in enumerate(self):
65-
66-
def add_code():
67-
# Note that in some cases, e.g. when code is being provided via the interactive shell, we may not be able to retrieve it.
68-
# In that case we just leave it empty.
69-
try:
70-
lines = open(source_info.file, "r").readlines()
71-
except OSError:
72-
return
73-
74-
source_info.code = lines[source_info.line - 1].rstrip()
75-
7678
if not first_user_frame_found:
7779
if source_info.is_user_frame():
78-
add_code()
80+
source_info.fetch_source_code()
7981
first_user_frame_found = True
8082
elif self.include_code_index is not None and index >= self.include_code_index:
81-
add_code()
83+
source_info.fetch_source_code()
8284

83-
self.code_fetched = True
85+
self._code_fetched = True
8486

85-
def get_first_user_frame_index(self) -> int:
87+
def get_first_user_frame_index(self) -> Optional[int]:
8688
for index, source_info in enumerate(self):
8789
if source_info.is_user_frame():
8890
return index

0 commit comments

Comments
 (0)