[Mlir-commits] [mlir] bca8895 - [mlir][python] add a todo to replace throw in dense array iterator
Jeff Niu
llvmlistbot at llvm.org
Fri Aug 12 20:35:51 PDT 2022
Author: Jeff Niu
Date: 2022-08-12T23:35:38-04:00
New Revision: bca889524a23a10d7a32024b80d687e2b3a1360c
URL: https://github.com/llvm/llvm-project/commit/bca889524a23a10d7a32024b80d687e2b3a1360c
DIFF: https://github.com/llvm/llvm-project/commit/bca889524a23a10d7a32024b80d687e2b3a1360c.diff
LOG: [mlir][python] add a todo to replace throw in dense array iterator
Added:
Modified:
mlir/lib/Bindings/Python/IRAttributes.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index d8fc568b73f71..cb59893b46dc6 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -183,7 +183,6 @@ class PyDenseArrayAttribute
c.def("__iter__", [](const PyDenseArrayAttribute<EltTy, DerivedT> &arr) {
return PyDenseArrayIterator(arr);
});
- // Bind a concat.
c.def("__add__", [](PyDenseArrayAttribute<EltTy, DerivedT> &arr,
py::list extras) {
std::vector<EltTy> values;
@@ -278,9 +277,9 @@ class PyArrayAttribute : public PyConcreteAttribute<PyArrayAttribute> {
PyArrayAttributeIterator &dunderIter() { return *this; }
PyAttribute dunderNext() {
- if (nextIndex >= mlirArrayAttrGetNumElements(attr.get())) {
+ // TODO: Throw is an inefficient way to stop iteration.
+ if (nextIndex >= mlirArrayAttrGetNumElements(attr.get()))
throw py::stop_iteration();
- }
return PyAttribute(attr.getContext(),
mlirArrayAttrGetElement(attr.get(), nextIndex++));
}
More information about the Mlir-commits
mailing list