[Mlir-commits] [mlir] [MLIR][Python] Support `has_trait` for operations (PR #188492)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Mar 26 08:32:23 PDT 2026


================
@@ -3963,7 +3964,13 @@ void populateIRCore(nb::module_ &m) {
              Args:
                callback: A callable that takes an Operation and returns a WalkResult.
                walk_order: The order of traversal (PRE_ORDER or POST_ORDER).
-               op_class: If provided, only operations of this type are passed to the callback.)");
+               op_class: If provided, only operations of this type are passed to the callback.)")
+      .def("has_trait", [](PyOperationBase &self, nb::type_object &traitCls) {
----------------
PragmaTwice wrote:

Now it can works as a classmethod for `OpView` and a normal method for `_OperationBase`.

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


More information about the Mlir-commits mailing list