Skip to content

Commit 2e82e38

Browse files
committed
[mlir] Fix bazel after efd96af.
1 parent 7c8b3f3 commit 2e82e38

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

mlir/lib/Bindings/Python/IRCore.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,8 @@ nb::typed<nb::object, PyOpView> PyOperation::createOpView() {
15501550
auto operationCls = PyGlobals::get().lookupOperationClass(
15511551
StringRef(identStr.data, identStr.length));
15521552
if (operationCls)
1553-
return PyOpView::constructDerived(*operationCls, getRef().getObject());
1554-
return nb::cast(PyOpView(getRef().getObject()));
1553+
return nanobind::cast<nanobind::typed<nanobind::object, PyOpView>>(PyOpView::constructDerived(*operationCls, getRef().getObject()));
1554+
return nanobind::cast<nanobind::typed<nanobind::object, PyOpView>>(nb::cast(PyOpView(getRef().getObject())));
15551555
}
15561556

15571557
void PyOperation::erase() {
@@ -2143,8 +2143,8 @@ nb::typed<nb::object, PyAttribute> PyAttribute::maybeDownCast() {
21432143
// contents into a new instance that will be owned by Python.
21442144
nb::object thisObj = nb::cast(this, nb::rv_policy::move);
21452145
if (!typeCaster)
2146-
return thisObj;
2147-
return typeCaster.value()(thisObj);
2146+
return nanobind::cast<nanobind::typed<nanobind::object, PyAttribute>>(thisObj);
2147+
return nanobind::cast<nanobind::typed<nanobind::object, PyAttribute>>(typeCaster.value()(thisObj));
21482148
}
21492149

21502150
//------------------------------------------------------------------------------
@@ -2189,8 +2189,8 @@ nb::typed<nb::object, PyType> PyType::maybeDownCast() {
21892189
// contents into a new instance that will be owned by Python.
21902190
nb::object thisObj = nb::cast(this, nb::rv_policy::move);
21912191
if (!typeCaster)
2192-
return thisObj;
2193-
return typeCaster.value()(thisObj);
2192+
return nanobind::cast<nanobind::typed<nanobind::object, PyType>>(thisObj);
2193+
return nanobind::cast<nanobind::typed<nanobind::object, PyType>>(typeCaster.value()(thisObj));
21942194
}
21952195

21962196
//------------------------------------------------------------------------------
@@ -2230,8 +2230,8 @@ nanobind::typed<nanobind::object, PyValue> PyValue::maybeDownCast() {
22302230
// contents into a new instance that will be owned by Python.
22312231
nb::object thisObj = nb::cast(this, nb::rv_policy::move);
22322232
if (!valueCaster)
2233-
return thisObj;
2234-
return valueCaster.value()(thisObj);
2233+
return nanobind::cast<nanobind::typed<nanobind::object, PyValue>>(thisObj);
2234+
return nanobind::cast<nanobind::typed<nanobind::object, PyValue>>(valueCaster.value()(thisObj));
22352235
}
22362236

22372237
PyValue PyValue::createFromCapsule(nb::object capsule) {

mlir/lib/Bindings/Python/IRModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ template <typename T>
5353
class PyObjectRef {
5454
public:
5555
PyObjectRef(T *referrent, nanobind::object object)
56-
: referrent(referrent), object(std::move(object)) {
56+
: referrent(referrent), object(nanobind::cast<nanobind::typed<nanobind::object, T>>(object)) {
5757
assert(this->referrent &&
5858
"cannot construct PyObjectRef with null referrent");
5959
assert(this->object && "cannot construct PyObjectRef with null object");
@@ -96,7 +96,7 @@ class PyObjectRef {
9696

9797
private:
9898
T *referrent;
99-
nanobind::object object;
99+
nanobind::typed<nanobind::object, T> object;
100100
};
101101

102102
/// Tracks an entry in the thread context stack. New entries are pushed onto

mlir/lib/Bindings/Python/NanobindUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class Sliceable {
276276
/// Returns the element at the given slice index. Supports negative indices
277277
/// by taking elements in inverse order. Returns a nullptr object if out
278278
/// of bounds.
279-
nanobind::typed<nanobind::object, ElementTy> getItem(intptr_t index) {
279+
nanobind::object getItem(intptr_t index) {
280280
// Negative indices mean we count from the end.
281281
index = wrapIndex(index);
282282
if (index < 0) {

utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ filegroup(
5353
]),
5454
)
5555

56-
filegroup(
57-
name = "IRPyIFiles",
58-
srcs = [
59-
"mlir/_mlir_libs/_mlir/__init__.pyi",
60-
"mlir/_mlir_libs/_mlir/ir.pyi",
61-
],
62-
)
63-
6456
filegroup(
6557
name = "MlirLibsPyFiles",
6658
srcs = [
@@ -75,13 +67,6 @@ filegroup(
7567
],
7668
)
7769

78-
filegroup(
79-
name = "PassManagerPyIFiles",
80-
srcs = [
81-
"mlir/_mlir_libs/_mlir/passmanager.pyi",
82-
],
83-
)
84-
8570
filegroup(
8671
name = "RewritePyFiles",
8772
srcs = [

0 commit comments

Comments
 (0)