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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Main
- Fix performance for non-contiguous NumPy array conversion in pybind vector converters. This change removes restrictive `py::array::c_style` flags and adds a runtime contiguity check, improving Pandas-to-Open3D conversion speed by up to ~50×. (issue #5250)(PR #7343).
- Corrected documentation for Link Open3D in C++ projects (broken links).
- Fix DLLs not being found in Python-package. Also prevent PATH from being searched for DLLs, except CUDA (PR #7108)
- Fix MSAA sample count not being copied when FilamentView is copied
Expand Down
22 changes: 18 additions & 4 deletions cpp/pybind/utility/eigen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ py::class_<Vector, holder_type> bind_vector_without_repr(
// bindings for each py array types.
template <typename EigenVector>
std::vector<EigenVector> py_array_to_vectors_double(
py::array_t<double, py::array::c_style | py::array::forcecast> array) {
py::array_t<double> array) { // remove the restrictive flags here
// Ensure array is contiguous (C-style)
if (!(array.flags() & (py::array::c_style))) {
// Make a contiguous copy if necessary
array = py::array_t<double, py::array::c_style>(array);
}
int64_t eigen_vector_size = EigenVector::SizeAtCompileTime;
if (array.ndim() != 2 || array.shape(1) != eigen_vector_size) {
throw py::cast_error();
Expand All @@ -54,7 +59,10 @@ std::vector<EigenVector> py_array_to_vectors_double(

template <typename EigenVector>
std::vector<EigenVector> py_array_to_vectors_int(
py::array_t<int, py::array::c_style | py::array::forcecast> array) {
py::array_t<int> array) {
if (!(array.flags() & (py::array::c_style))) {
array = py::array_t<int, py::array::c_style>(array);
}
int64_t eigen_vector_size = EigenVector::SizeAtCompileTime;
if (array.ndim() != 2 || array.shape(1) != eigen_vector_size) {
throw py::cast_error();
Expand All @@ -71,7 +79,10 @@ template <typename EigenVector,
typename EigenAllocator = Eigen::aligned_allocator<EigenVector>>
std::vector<EigenVector, EigenAllocator>
py_array_to_vectors_int_eigen_allocator(
py::array_t<int, py::array::c_style | py::array::forcecast> array) {
py::array_t<int> array) {
if (!(array.flags() & (py::array::c_style))) {
array = py::array_t<int, py::array::c_style>(array);
}
int64_t eigen_vector_size = EigenVector::SizeAtCompileTime;
if (array.ndim() != 2 || array.shape(1) != eigen_vector_size) {
throw py::cast_error();
Expand All @@ -88,7 +99,10 @@ template <typename EigenVector,
typename EigenAllocator = Eigen::aligned_allocator<EigenVector>>
std::vector<EigenVector, EigenAllocator>
py_array_to_vectors_int64_eigen_allocator(
py::array_t<int64_t, py::array::c_style | py::array::forcecast> array) {
py::array_t<int64_t> array) {
if (!(array.flags() & (py::array::c_style))) {
array = py::array_t<int64_t, py::array::c_style>(array);
}
int64_t eigen_vector_size = EigenVector::SizeAtCompileTime;
if (array.ndim() != 2 || array.shape(1) != eigen_vector_size) {
throw py::cast_error();
Expand Down