diff options
author | Maksim Levental <maksim.levental@gmail.com> | 2025-09-23 13:54:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-23 10:54:22 -0700 |
commit | 0d08ffd22cde12434fa3c56996d68818b25030b9 (patch) | |
tree | b0a95bb333155500269bcac3f78f7b251bfc4b83 /mlir/lib/Bindings/Python/IRModule.h | |
parent | 4feb0925b0869bd42f0dfba76c06c2e4a400f93a (diff) | |
download | llvm-0d08ffd22cde12434fa3c56996d68818b25030b9.zip llvm-0d08ffd22cde12434fa3c56996d68818b25030b9.tar.gz llvm-0d08ffd22cde12434fa3c56996d68818b25030b9.tar.bz2 |
[MLIR][Python] use nb::typed for return signatures (#160221)
https://github.com/llvm/llvm-project/pull/160183 removed `nb::typed`
annotation to fix bazel but it turned out to be simply a matter of not
using the correct version of nanobind (see
https://github.com/llvm/llvm-project/pull/160183#issuecomment-3321429155).
This PR restores those annotations but (mostly) moves to the return
positions of the actual methods.
Diffstat (limited to 'mlir/lib/Bindings/Python/IRModule.h')
-rw-r--r-- | mlir/lib/Bindings/Python/IRModule.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mlir/lib/Bindings/Python/IRModule.h b/mlir/lib/Bindings/Python/IRModule.h index 6e97c00..598ae01 100644 --- a/mlir/lib/Bindings/Python/IRModule.h +++ b/mlir/lib/Bindings/Python/IRModule.h @@ -671,7 +671,7 @@ public: /// Creates a PyOperation from the MlirOperation wrapped by a capsule. /// Ownership of the underlying MlirOperation is taken by calling this /// function. - static nanobind::object createFromCapsule(nanobind::object capsule); + static nanobind::object createFromCapsule(const nanobind::object &capsule); /// Creates an operation. See corresponding python docstring. static nanobind::object @@ -1020,7 +1020,7 @@ public: /// Note that PyAttribute instances are uniqued, so the returned object /// may be a pre-existing object. Ownership of the underlying MlirAttribute /// is taken by calling this function. - static PyAttribute createFromCapsule(nanobind::object capsule); + static PyAttribute createFromCapsule(const nanobind::object &capsule); nanobind::object maybeDownCast(); @@ -1101,10 +1101,12 @@ public: return DerivedTy::isaFunction(otherAttr); }, nanobind::arg("other")); - cls.def_prop_ro("type", [](PyAttribute &attr) { - return PyType(attr.getContext(), mlirAttributeGetType(attr)) - .maybeDownCast(); - }); + cls.def_prop_ro( + "type", + [](PyAttribute &attr) -> nanobind::typed<nanobind::object, PyType> { + return PyType(attr.getContext(), mlirAttributeGetType(attr)) + .maybeDownCast(); + }); cls.def_prop_ro_static( "static_typeid", [](nanobind::object & /*class*/) -> PyTypeID { |