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

Martin Paul Lücke llvmlistbot at llvm.org
Tue Feb 20 23:21:15 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)
+
+
----------------
martin-luecke wrote:

Nit:
```suggestion

# CHECK-LABEL: TEST: print_self
```

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


More information about the Mlir-commits mailing list