chore: optimize sparse matrix casting with python tuple (#4064)

* optimize casting of sparse Eigen arrays

* move array

* Revert for safety
This commit is contained in:
Aaron Gokaslan 2022-07-13 19:27:00 -04:00 committed by GitHub
parent 6b60d97d30
commit bc9315fe38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -692,9 +692,9 @@ struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
array outerIndices((rowMajor ? src.rows() : src.cols()) + 1, src.outerIndexPtr()); array outerIndices((rowMajor ? src.rows() : src.cols()) + 1, src.outerIndexPtr());
array innerIndices(src.nonZeros(), src.innerIndexPtr()); array innerIndices(src.nonZeros(), src.innerIndexPtr());
return matrix_type(std::make_tuple( return matrix_type(pybind11::make_tuple(
std::move(data), std::move(innerIndices), std::move(outerIndices)), std::move(data), std::move(innerIndices), std::move(outerIndices)),
std::make_pair(src.rows(), src.cols())) pybind11::make_tuple(src.rows(), src.cols()))
.release(); .release();
} }