Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions mlir/lib/Bindings/Python/IRCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1550,8 +1550,8 @@ nb::typed<nb::object, PyOpView> 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<nanobind::typed<nanobind::object, PyOpView>>(PyOpView::constructDerived(*operationCls, getRef().getObject()));
return nanobind::cast<nanobind::typed<nanobind::object, PyOpView>>(nb::cast(PyOpView(getRef().getObject())));
}

void PyOperation::erase() {
Expand Down Expand Up @@ -2143,8 +2143,8 @@ nb::typed<nb::object, PyAttribute> 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<nanobind::typed<nanobind::object, PyAttribute>>(thisObj);
return nanobind::cast<nanobind::typed<nanobind::object, PyAttribute>>(typeCaster.value()(thisObj));
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -2189,8 +2189,8 @@ nb::typed<nb::object, PyType> 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<nanobind::typed<nanobind::object, PyType>>(thisObj);
return nanobind::cast<nanobind::typed<nanobind::object, PyType>>(typeCaster.value()(thisObj));
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -2230,8 +2230,8 @@ nanobind::typed<nanobind::object, PyValue> 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<nanobind::typed<nanobind::object, PyValue>>(thisObj);
return nanobind::cast<nanobind::typed<nanobind::object, PyValue>>(valueCaster.value()(thisObj));
}

PyValue PyValue::createFromCapsule(nb::object capsule) {
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Bindings/Python/IRModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ template <typename T>
class PyObjectRef {
public:
PyObjectRef(T *referrent, nanobind::object object)
: referrent(referrent), object(std::move(object)) {
: referrent(referrent), object(nanobind::cast<nanobind::typed<nanobind::object, T>>(object)) {
assert(this->referrent &&
"cannot construct PyObjectRef with null referrent");
assert(this->object && "cannot construct PyObjectRef with null object");
Expand Down Expand Up @@ -96,7 +96,7 @@ class PyObjectRef {

private:
T *referrent;
nanobind::object object;
nanobind::typed<nanobind::object, T> object;
};

/// Tracks an entry in the thread context stack. New entries are pushed onto
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Bindings/Python/NanobindUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<nanobind::object, ElementTy> getItem(intptr_t index) {
nanobind::object getItem(intptr_t index) {
// Negative indices mean we count from the end.
index = wrapIndex(index);
if (index < 0) {
Expand Down
15 changes: 0 additions & 15 deletions utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -75,13 +67,6 @@ filegroup(
],
)

filegroup(
name = "PassManagerPyIFiles",
srcs = [
"mlir/_mlir_libs/_mlir/passmanager.pyi",
],
)

filegroup(
name = "RewritePyFiles",
srcs = [
Expand Down
Loading