[Mlir-commits] [mlir] [mlir] expose transform interpreter to Python (PR #82365)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Wed Feb 21 01:25:39 PST 2024


================
@@ -0,0 +1,55 @@
+# RUN: %PYTHON %s | FileCheck %s
+
+from mlir import ir
+from mlir.dialects.transform import interpreter as interp
+
+
+def test_in_context(f):
+    print("\nTEST:", f.__name__)
+    with ir.Context(), ir.Location.unknown():
+        f()
+    return f
+
+
+print_root_module = """
+module attributes {transform.with_named_sequence} {
+  transform.named_sequence @__transform_main(%root: !transform.any_op) {
+    transform.print %root { name = \"from interpreter\" }: !transform.any_op
+    transform.yield
+  }
+}"""
+
+
+ at test_in_context
+def print_self():
+    m = ir.Module.parse(print_root_module)
+    interp.apply_named_sequence(m, m.body.operations[0], m)
+
+
----------------
ftynse wrote:

Unfortunately, python and C output get mixed in an unpredictable way, so this won't work. I used a different method to get labels.

https://github.com/llvm/llvm-project/pull/82365


More information about the Mlir-commits mailing list