[Mlir-commits] [mlir] [mlir][python] automatic location inference (PR #151246)
Anatoly Myachev
llvmlistbot at llvm.org
Wed Sep 3 05:34:23 PDT 2025
================
@@ -0,0 +1,101 @@
+# RUN: %PYTHON %s | FileCheck %s
+# REQUIRES: python-ge-311
+import gc
+from contextlib import contextmanager
+
+from mlir.ir import *
+from mlir.dialects._ods_common import _cext
+from mlir.dialects import arith, _arith_ops_gen
+
+
+def run(f):
+ print("\nTEST:", f.__name__)
+ f()
+ gc.collect()
+ assert Context._get_live_count() == 0
+
+
+ at contextmanager
+def with_infer_location():
+ _cext.globals.set_loc_tracebacks_enabled(True)
+ yield
+ _cext.globals.set_loc_tracebacks_enabled(False)
+
+
+# CHECK-LABEL: TEST: testInferLocations
+ at run
+def testInferLocations():
+ with Context() as ctx, with_infer_location():
+ ctx.allow_unregistered_dialects = True
+
+ op = Operation.create("custom.op1")
+ one = arith.constant(IndexType.get(), 1)
+ _cext.globals.register_traceback_file_exclusion(arith.__file__)
+ two = arith.constant(IndexType.get(), 2)
+
+ # fmt: off
+ # CHECK: loc(callsite("testInferLocations"("{{.*}}[[SEP:[/\\]]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":31:13 to :43) at callsite("run"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":13:4 to :7) at "<module>"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":26:1 to :4))))
----------------
anmyachev wrote:
Hi @makslevental
I recently faced the following error: `******************** TEST 'MLIR :: python/ir/auto_location.py' FAILED ********************` when LLVM was compiled for windows in OpenAI Triton project: https://github.com/triton-lang/triton/actions/runs/17419518063/job/49454994952.
More logs:
```txt
******************** TEST 'MLIR :: python/ir/auto_location.py' FAILED ********************
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 1
"C:/hostedtoolcache/windows/Python/3.11.9/x64/python3.exe" D:\a\triton\triton\llvm-project\mlir\test\python\ir\auto_location.py | d:\a\triton\triton\llvm-project\build\bin\filecheck.exe D:\a\triton\triton\llvm-project\mlir\test\python\ir\auto_location.py
# executed command: C:/hostedtoolcache/windows/Python/3.11.9/x64/python3.exe 'D:\a\triton\triton\llvm-project\mlir\test\python\ir\auto_location.py'
# executed command: 'd:\a\triton\triton\llvm-project\build\bin\filecheck.exe' 'D:\a\triton\triton\llvm-project\mlir\test\python\ir\auto_location.py'
# .---command stderr------------
# | D:\a\triton\triton\llvm-project\mlir\test\python\ir\auto_location.py:37:11: error: CHECK: expected string not found in input
# | # CHECK: loc(callsite("testInferLocations"("{{.*}}[[SEP:[/\\]]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":31:13 to :43) at callsite("run"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":13:4 to :7) at "<module>"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":26:1 to :4))))
# | ^
# | <stdin>:2:25: note: scanning from here
# | TEST: testInferLocations
# | ^
# |
# | Input file: <stdin>
# | Check file: D:\a\triton\triton\llvm-project\mlir\test\python\ir\auto_location.py
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# | 1:
# | 2: TEST: testInferLocations
# | check:37 X error: no match found
# | 3: loc(callsite("testInferLocations"("D:\\a\\triton\\triton\\llvm-project\\mlir\\test\\python\\ir\\auto_location.py":31:13 to :43) at callsite("run"("D:\\a\\triton\\triton\\llvm-project\\mlir\\test\\python\\ir\\auto_location.py":13:4 to :7) at "<module>"("D:\\a\\triton\\triton\\llvm-project\\mlir\\test\\python\\ir\\auto_location.py":26:1 to :4))))
# | check:37
```
Probably this line should be changed `[[SEP:[/\\]]]` -> `[[SEP]]`?
https://github.com/llvm/llvm-project/pull/151246
More information about the Mlir-commits
mailing list