[Mlir-commits] [mlir] [MLIR][Python] Register `OpAttributeMap` as `Mapping` for `match` compatibility (PR #174292)
Maksim Levental
llvmlistbot at llvm.org
Fri Jan 9 13:31:38 PST 2026
================
@@ -2388,6 +2388,16 @@ PyOpAttributeMap::dunderGetItemNamed(const std::string &name) {
return PyAttribute(operation->getContext(), attr).maybeDownCast();
}
+nb::object PyOpAttributeMap::getWithDefaultNamed(const std::string &key,
+ nb::object defaultValue) {
+ MlirAttribute attr =
+ mlirOperationGetAttributeByName(operation->get(), toMlirStringRef(key));
+ if (mlirAttributeIsNull(attr)) {
+ return defaultValue;
+ }
----------------
makslevental wrote:
nit:
```suggestion
if (mlirAttributeIsNull(attr))
return defaultValue;
```
https://github.com/llvm/llvm-project/pull/174292
More information about the Mlir-commits
mailing list