[Mlir-commits] [mlir] [mlir][Python] fix IRInterfaces.h (PR #181522)
Maksim Levental
llvmlistbot at llvm.org
Sat Feb 14 19:45:16 PST 2026
https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/181522
>From 9cf307b30cd3bdcb8b8417f7aa1e132d06a928ac Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Sat, 14 Feb 2026 19:26:59 -0800
Subject: [PATCH 1/2] [mlir][Python] fix IRInterfaces.h
---
mlir/{lib => include/mlir}/Bindings/Python/IRInterfaces.h | 0
mlir/lib/Bindings/Python/DialectTransform.cpp | 2 +-
mlir/lib/Bindings/Python/IRInterfaces.cpp | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
rename mlir/{lib => include/mlir}/Bindings/Python/IRInterfaces.h (100%)
diff --git a/mlir/lib/Bindings/Python/IRInterfaces.h b/mlir/include/mlir/Bindings/Python/IRInterfaces.h
similarity index 100%
rename from mlir/lib/Bindings/Python/IRInterfaces.h
rename to mlir/include/mlir/Bindings/Python/IRInterfaces.h
diff --git a/mlir/lib/Bindings/Python/DialectTransform.cpp b/mlir/lib/Bindings/Python/DialectTransform.cpp
index 62c6185dab15e..0d9877a1d2a0a 100644
--- a/mlir/lib/Bindings/Python/DialectTransform.cpp
+++ b/mlir/lib/Bindings/Python/DialectTransform.cpp
@@ -8,12 +8,12 @@
#include <string>
-#include "IRInterfaces.h"
#include "Rewrite.h"
#include "mlir-c/Dialect/Transform.h"
#include "mlir-c/IR.h"
#include "mlir-c/Support.h"
#include "mlir/Bindings/Python/IRCore.h"
+#include "mlir/Bindings/Python/IRInterfaces.h"
#include "nanobind/nanobind.h"
#include <nanobind/trampoline.h>
diff --git a/mlir/lib/Bindings/Python/IRInterfaces.cpp b/mlir/lib/Bindings/Python/IRInterfaces.cpp
index 147f2022b2948..ea795dde875c1 100644
--- a/mlir/lib/Bindings/Python/IRInterfaces.cpp
+++ b/mlir/lib/Bindings/Python/IRInterfaces.cpp
@@ -12,12 +12,12 @@
#include <utility>
#include <vector>
-#include "IRInterfaces.h"
#include "mlir-c/BuiltinAttributes.h"
#include "mlir-c/IR.h"
#include "mlir-c/Interfaces.h"
#include "mlir-c/Support.h"
#include "mlir/Bindings/Python/IRCore.h"
+#include "mlir/Bindings/Python/IRInterfaces.h"
namespace nb = nanobind;
>From 1391fe57387f45d3ca278fa3aa5e3afcd415a62c Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Sat, 14 Feb 2026 19:45:04 -0800
Subject: [PATCH 2/2] move comments
---
.../mlir/Bindings/Python/IRInterfaces.h | 26 +++++++------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/mlir/include/mlir/Bindings/Python/IRInterfaces.h b/mlir/include/mlir/Bindings/Python/IRInterfaces.h
index 7d0bcc25da210..fb30e030b6c32 100644
--- a/mlir/include/mlir/Bindings/Python/IRInterfaces.h
+++ b/mlir/include/mlir/Bindings/Python/IRInterfaces.h
@@ -20,18 +20,6 @@ namespace mlir {
namespace python {
namespace MLIR_BINDINGS_PYTHON_DOMAIN {
-constexpr static const char *constructorDoc =
- R"(Creates an interface from a given operation/opview object or from a
-subclass of OpView. Raises ValueError if the operation does not implement the
-interface.)";
-
-constexpr static const char *operationDoc =
- R"(Returns an Operation for which the interface was constructed.)";
-
-constexpr static const char *opviewDoc =
- R"(Returns an OpView subclass _instance_ for which the interface was
-constructed)";
-
/// CRTP base class for Python classes representing MLIR Op interfaces.
/// Interface hierarchies are flat so no base class is expected here. The
/// derived class is expected to define the following static fields:
@@ -97,10 +85,16 @@ class PyConcreteOpInterface {
nanobind::class_<ConcreteIface> cls(m, ConcreteIface::pyClassName);
cls.def(nanobind::init<nanobind::object, DefaultingPyMlirContext>(),
nanobind::arg("object"),
- nanobind::arg("context") = nanobind::none(), constructorDoc)
- .def_prop_ro("operation", &PyConcreteOpInterface::getOperationObject,
- operationDoc)
- .def_prop_ro("opview", &PyConcreteOpInterface::getOpView, opviewDoc);
+ nanobind::arg("context") = nanobind::none(),
+ "Creates an interface from a given operation/opview object or from "
+ "a subclass of OpView. Raises ValueError if the operation does not "
+ "implement the interface.")
+ .def_prop_ro(
+ "operation", &PyConcreteOpInterface::getOperationObject,
+ "Returns an Operation for which the interface was constructed.")
+ .def_prop_ro("opview", &PyConcreteOpInterface::getOpView,
+ "Returns an OpView subclass _instance_ for which the "
+ "interface was constructed");
ConcreteIface::bindDerived(cls);
}
More information about the Mlir-commits
mailing list