[Mlir-commits] [mlir] [MLIR][Python] Impl XOpInterface(s) from Python, with X=Transform and X=MemoryEffects (PR #176920)
Maksim Levental
llvmlistbot at llvm.org
Tue Feb 3 09:53:07 PST 2026
================
@@ -22,6 +24,219 @@ namespace mlir {
namespace python {
namespace MLIR_BINDINGS_PYTHON_DOMAIN {
namespace transform {
+
+//===----------------------------------------------------------------------===//
+// TransformRewriter
+//===----------------------------------------------------------------------===//
+class PyTransformRewriter : public PyRewriterBase<PyTransformRewriter> {
+public:
+ static constexpr const char *pyClassName = "TransformRewriter";
+
+ PyTransformRewriter(MlirTransformRewriter rewriter)
+ : PyRewriterBase(mlirTransformRewriterAsBase(rewriter)) {}
+};
+
+//===----------------------------------------------------------------------===//
+// TransformResults
+//===----------------------------------------------------------------------===//
+class PyTransformResults {
+public:
+ PyTransformResults(MlirTransformResults results) : results(results) {}
+
+ MlirTransformResults get() const { return results; }
+
+ void setOps(MlirValue result, const nanobind::list &ops) {
----------------
makslevental wrote:
we should not use `Mlir*` at the API level after https://github.com/llvm/llvm-project/pull/171775 - they trigger an implicit imports when crossing the boundary via the `type_caster`s in `NanobindAdaptors.h`: https://github.com/llvm/llvm-project/blob/572dabdbf637e006f666fd069fe1aebf151c7a5f/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h#L341-L345
Please change all of these to be in terms of `PyValue` and `nb::list<PyOperationBase>`. You can use this pattern:
https://github.com/llvm/llvm-project/blob/0e4be262f4d0e74462b3f3d75e638e4ba3c56a4f/mlir/lib/Bindings/Python/DialectLLVM.cpp#L50-L51
https://github.com/llvm/llvm-project/pull/176920
More information about the Mlir-commits
mailing list