[Mlir-commits] [mlir] c5f445d - [mlir][python] Temporarily disable test for converting unsupported DenseElementsAttr types to a buffer.
Stella Laurenzo
llvmlistbot at llvm.org
Thu Oct 7 11:51:09 PDT 2021
Author: Stella Laurenzo
Date: 2021-10-07T11:50:57-07:00
New Revision: c5f445d143485f898353df6d422eea1dea22c7a8
URL: https://github.com/llvm/llvm-project/commit/c5f445d143485f898353df6d422eea1dea22c7a8
DIFF: https://github.com/llvm/llvm-project/commit/c5f445d143485f898353df6d422eea1dea22c7a8.diff
LOG: [mlir][python] Temporarily disable test for converting unsupported DenseElementsAttr types to a buffer.
* Need to investigate the proper solution to https://github.com/pybind/pybind11/issues/3336 or engineer something different.
* The attempt to produce an empty buffer_info as a workaround triggers asan/ubsan.
* Usage of this API does not arise naturally in practice yet, and it is more important to be asan/crash clean than have a solution right now.
* Switching back to raising an exception, even though that triggers terminate().
Added:
Modified:
mlir/lib/Bindings/Python/IRAttributes.cpp
mlir/test/python/ir/array_attributes.py
Removed:
################################################################################
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index 47f73ecae4784..066350a0a8728 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -497,9 +497,10 @@ class PyDenseElementsAttribute
py::buffer_info accessBuffer() {
if (mlirDenseElementsAttrIsSplat(*this)) {
- // TODO: Raise an exception.
+ // TODO: Currently crashes the program.
// Reported as https://github.com/pybind/pybind11/issues/3336
- return py::buffer_info();
+ throw std::invalid_argument(
+ "unsupported data type for conversion to Python buffer");
}
MlirType shapedType = mlirAttributeGetType(*this);
@@ -557,12 +558,10 @@ class PyDenseElementsAttribute
}
}
- // TODO: Currently crashes the program. Just returning an empty buffer
- // for now.
+ // TODO: Currently crashes the program.
// Reported as https://github.com/pybind/pybind11/issues/3336
- // throw std::invalid_argument(
- // "unsupported data type for conversion to Python buffer");
- return py::buffer_info();
+ throw std::invalid_argument(
+ "unsupported data type for conversion to Python buffer");
}
static void bindDerived(ClassTy &c) {
diff --git a/mlir/test/python/ir/array_attributes.py b/mlir/test/python/ir/array_attributes.py
index 13c7c215484b4..b618802e52436 100644
--- a/mlir/test/python/ir/array_attributes.py
+++ b/mlir/test/python/ir/array_attributes.py
@@ -98,8 +98,10 @@ def testRepeatedValuesSplat():
print(attr)
# CHECK: is_splat: True
print("is_splat:", attr.is_splat)
- # CHECK: ()
- print(np.array(attr))
+ # TODO: Re-enable this once a solution is found to raising an exception
+ # from buffer protocol.
+ # Reported as https://github.com/pybind/pybind11/issues/3336
+ # print(np.array(attr))
# CHECK-LABEL: TEST: testNonSplat
More information about the Mlir-commits
mailing list