From 2e82e380c29a6a6115aa2b99ba354e849e1111ae Mon Sep 17 00:00:00 2001 From: Bart Chrzaszcz Date: Mon, 22 Sep 2025 18:44:17 +0100 Subject: [PATCH] [mlir] Fix bazel after efd96af. --- mlir/lib/Bindings/Python/IRCore.cpp | 16 ++++++++-------- mlir/lib/Bindings/Python/IRModule.h | 4 ++-- mlir/lib/Bindings/Python/NanobindUtils.h | 2 +- .../llvm-project-overlay/mlir/python/BUILD.bazel | 15 --------------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp index 609502041f4ae..9e60bc6a65bcd 100644 --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -1550,8 +1550,8 @@ nb::typed PyOperation::createOpView() { auto operationCls = PyGlobals::get().lookupOperationClass( StringRef(identStr.data, identStr.length)); if (operationCls) - return PyOpView::constructDerived(*operationCls, getRef().getObject()); - return nb::cast(PyOpView(getRef().getObject())); + return nanobind::cast>(PyOpView::constructDerived(*operationCls, getRef().getObject())); + return nanobind::cast>(nb::cast(PyOpView(getRef().getObject()))); } void PyOperation::erase() { @@ -2143,8 +2143,8 @@ nb::typed PyAttribute::maybeDownCast() { // contents into a new instance that will be owned by Python. nb::object thisObj = nb::cast(this, nb::rv_policy::move); if (!typeCaster) - return thisObj; - return typeCaster.value()(thisObj); + return nanobind::cast>(thisObj); + return nanobind::cast>(typeCaster.value()(thisObj)); } //------------------------------------------------------------------------------ @@ -2189,8 +2189,8 @@ nb::typed PyType::maybeDownCast() { // contents into a new instance that will be owned by Python. nb::object thisObj = nb::cast(this, nb::rv_policy::move); if (!typeCaster) - return thisObj; - return typeCaster.value()(thisObj); + return nanobind::cast>(thisObj); + return nanobind::cast>(typeCaster.value()(thisObj)); } //------------------------------------------------------------------------------ @@ -2230,8 +2230,8 @@ nanobind::typed PyValue::maybeDownCast() { // contents into a new instance that will be owned by Python. nb::object thisObj = nb::cast(this, nb::rv_policy::move); if (!valueCaster) - return thisObj; - return valueCaster.value()(thisObj); + return nanobind::cast>(thisObj); + return nanobind::cast>(valueCaster.value()(thisObj)); } PyValue PyValue::createFromCapsule(nb::object capsule) { diff --git a/mlir/lib/Bindings/Python/IRModule.h b/mlir/lib/Bindings/Python/IRModule.h index 414f37cc97f2a..633b11f6fe96e 100644 --- a/mlir/lib/Bindings/Python/IRModule.h +++ b/mlir/lib/Bindings/Python/IRModule.h @@ -53,7 +53,7 @@ template class PyObjectRef { public: PyObjectRef(T *referrent, nanobind::object object) - : referrent(referrent), object(std::move(object)) { + : referrent(referrent), object(nanobind::cast>(object)) { assert(this->referrent && "cannot construct PyObjectRef with null referrent"); assert(this->object && "cannot construct PyObjectRef with null object"); @@ -96,7 +96,7 @@ class PyObjectRef { private: T *referrent; - nanobind::object object; + nanobind::typed object; }; /// Tracks an entry in the thread context stack. New entries are pushed onto diff --git a/mlir/lib/Bindings/Python/NanobindUtils.h b/mlir/lib/Bindings/Python/NanobindUtils.h index 40b3215f6f5fe..64ea4329f65f1 100644 --- a/mlir/lib/Bindings/Python/NanobindUtils.h +++ b/mlir/lib/Bindings/Python/NanobindUtils.h @@ -276,7 +276,7 @@ class Sliceable { /// Returns the element at the given slice index. Supports negative indices /// by taking elements in inverse order. Returns a nullptr object if out /// of bounds. - nanobind::typed getItem(intptr_t index) { + nanobind::object getItem(intptr_t index) { // Negative indices mean we count from the end. index = wrapIndex(index); if (index < 0) { diff --git a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel index a6e8c515f0874..3daf9290921e7 100644 --- a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel @@ -53,14 +53,6 @@ filegroup( ]), ) -filegroup( - name = "IRPyIFiles", - srcs = [ - "mlir/_mlir_libs/_mlir/__init__.pyi", - "mlir/_mlir_libs/_mlir/ir.pyi", - ], -) - filegroup( name = "MlirLibsPyFiles", srcs = [ @@ -75,13 +67,6 @@ filegroup( ], ) -filegroup( - name = "PassManagerPyIFiles", - srcs = [ - "mlir/_mlir_libs/_mlir/passmanager.pyi", - ], -) - filegroup( name = "RewritePyFiles", srcs = [