[Mlir-commits] [mlir] [MLIR][Python] Support dynamic traits in python-defined dialects (PR #179705)

Rolf Morel llvmlistbot at llvm.org
Mon Feb 9 06:45:13 PST 2026


================
@@ -2521,6 +2522,119 @@ void PyOpAdaptor::bind(nb::module_ &m) {
           "Returns the attributes of the adaptor.");
 }
 
+static MlirLogicalResult verifyTraitByMethod(MlirOperation op, void *userData,
+                                             const char *methodName) {
+  nb::handle targetObj(static_cast<PyObject *>(userData));
+  if (!nb::hasattr(targetObj, methodName)) {
+    return mlirLogicalResultSuccess();
+  }
----------------
rolfmorel wrote:

```suggestion
  if (!nb::hasattr(targetObj, methodName))
    return mlirLogicalResultSuccess();
```

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


More information about the Mlir-commits mailing list