Skip to content

Commit 3ad8eb5

Browse files
committed
add frame limit test
1 parent eb48702 commit 3ad8eb5

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

mlir/test/python/ir/auto_location.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def run(f):
1212
print("\nTEST:", f.__name__)
1313
f()
1414
gc.collect()
15-
assert Context._get_live_count() == 0
15+
# assert Context._get_live_count() == 0
1616

1717

1818
@contextmanager
@@ -70,3 +70,34 @@ def foo():
7070
# CHECK: loc("ConstantOp.__init__"("{{.*}}[[SEP]]mlir[[SEP]]dialects[[SEP]]_arith_ops_gen.py":405:4 to :218))
7171
# fmt: on
7272
foo()
73+
74+
def bar1():
75+
def bar2():
76+
def bar3():
77+
five = arith.constant(IndexType.get(), 5)
78+
print(five.___location)
79+
bar3()
80+
bar2()
81+
82+
print()
83+
_cext.globals.register_traceback_file_inclusion(__file__)
84+
_cext.globals.register_traceback_file_exclusion(_arith_ops_gen.__file__)
85+
86+
_cext.globals.set_loc_tracebacks_frame_limit(2)
87+
# fmt: off
88+
# CHECK: loc(callsite("testInferLocations.<locals>.bar1.<locals>.bar2.<locals>.bar3"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":77:27 to :61) at "testInferLocations.<locals>.bar1.<locals>.bar2"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":79:16 to :22)))
89+
# fmt: on
90+
bar1()
91+
92+
_cext.globals.set_loc_tracebacks_frame_limit(1)
93+
# fmt: off
94+
# CHECK: loc("testInferLocations.<locals>.bar1.<locals>.bar2.<locals>.bar3"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":77:27 to :61))
95+
# fmt: on
96+
bar1()
97+
98+
_cext.globals.set_loc_tracebacks_frame_limit(0)
99+
# fmt: off
100+
# CHECK: loc(unknown)
101+
# fmt: on
102+
bar1()
103+

0 commit comments

Comments
 (0)