-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir] Fix bazel after efd96af. #160158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[mlir] Fix bazel after efd96af. #160158
Conversation
d6536f7
to
a33521d
Compare
a33521d
to
2e82e38
Compare
@llvm/pr-subscribers-mlir Author: Bart Chrzaszcz (bartchr808) ChangesFull diff: https://github.com/llvm/llvm-project/pull/160158.diff 4 Files Affected:
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<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() {
@@ -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));
}
//------------------------------------------------------------------------------
@@ -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));
}
//------------------------------------------------------------------------------
@@ -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) {
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 <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");
@@ -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
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<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) {
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 = [
|
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions h,cpp -- mlir/lib/Bindings/Python/IRCore.cpp mlir/lib/Bindings/Python/IRModule.h mlir/lib/Bindings/Python/NanobindUtils.h
View the diff from clang-format here.diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 9e60bc6a6..70058d8ca 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1550,8 +1550,10 @@ nb::typed<nb::object, PyOpView> PyOperation::createOpView() {
auto operationCls = PyGlobals::get().lookupOperationClass(
StringRef(identStr.data, identStr.length));
if (operationCls)
- 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())));
+ 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() {
@@ -2143,8 +2145,10 @@ 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 nanobind::cast<nanobind::typed<nanobind::object, PyAttribute>>(thisObj);
- return nanobind::cast<nanobind::typed<nanobind::object, PyAttribute>>(typeCaster.value()(thisObj));
+ return nanobind::cast<nanobind::typed<nanobind::object, PyAttribute>>(
+ thisObj);
+ return nanobind::cast<nanobind::typed<nanobind::object, PyAttribute>>(
+ typeCaster.value()(thisObj));
}
//------------------------------------------------------------------------------
@@ -2190,7 +2194,8 @@ nb::typed<nb::object, PyType> PyType::maybeDownCast() {
nb::object thisObj = nb::cast(this, nb::rv_policy::move);
if (!typeCaster)
return nanobind::cast<nanobind::typed<nanobind::object, PyType>>(thisObj);
- return nanobind::cast<nanobind::typed<nanobind::object, PyType>>(typeCaster.value()(thisObj));
+ return nanobind::cast<nanobind::typed<nanobind::object, PyType>>(
+ typeCaster.value()(thisObj));
}
//------------------------------------------------------------------------------
@@ -2231,7 +2236,8 @@ nanobind::typed<nanobind::object, PyValue> PyValue::maybeDownCast() {
nb::object thisObj = nb::cast(this, nb::rv_policy::move);
if (!valueCaster)
return nanobind::cast<nanobind::typed<nanobind::object, PyValue>>(thisObj);
- return nanobind::cast<nanobind::typed<nanobind::object, PyValue>>(valueCaster.value()(thisObj));
+ return nanobind::cast<nanobind::typed<nanobind::object, PyValue>>(
+ 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 633b11f6f..c4e87e5ea 100644
--- a/mlir/lib/Bindings/Python/IRModule.h
+++ b/mlir/lib/Bindings/Python/IRModule.h
@@ -53,7 +53,8 @@ template <typename T>
class PyObjectRef {
public:
PyObjectRef(T *referrent, nanobind::object object)
- : referrent(referrent), object(nanobind::cast<nanobind::typed<nanobind::object, T>>(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");
|
No description provided.