Skip to content
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

Fix performance regression in hictk::balance #95

Merged
merged 2 commits into from
Dec 23, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,9 @@ inline void ICE::min_nnz_filtering(MargsVector& marg, const MatrixT& matrix,
nonstd::span<double> biases, std::size_t min_nnz,
BS::thread_pool* tpool) {
matrix.marginalize_nnz(marg, tpool);
const auto marg_ = marg();
for (std::size_t i = 0; i < biases.size(); ++i) {
if (marg()[i] < static_cast<double>(min_nnz)) {
if (marg_[i] < static_cast<double>(min_nnz)) {
biases[i] = 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,10 @@ inline void SparseMatrixChunked::marginalize(MargsVector& marg, BS::thread_pool*
fs.exceptions(_fs.exceptions());
fs.open(_path, std::ios::in | std::ios::binary);
auto matrix = _matrix;
MargsVector marg_local(marg.size());
for (const auto offset : nonstd::span(_index).subspan(istart, iend - istart)) {
fs.seekg(offset);
matrix.deserialize(fs, *zstd_dctx);
matrix.marginalize(marg_local, nullptr, false);
}

for (std::size_t i = 0; i < marg_local.size(); ++i) {
if (marg_local[i] != 0) {
marg.add(i, marg_local[i]);
}
matrix.marginalize(marg, nullptr, false);
}
};

Expand Down Expand Up @@ -413,17 +406,11 @@ inline void SparseMatrixChunked::marginalize_nnz(MargsVector& marg, BS::thread_p
fs.exceptions(_fs.exceptions());
fs.open(_path, std::ios::in | std::ios::binary);
auto matrix = _matrix;
MargsVector marg_local(marg.size());
for (const auto offset : nonstd::span(_index).subspan(istart, iend - istart)) {
fs.seekg(offset);
matrix.deserialize(fs, *zstd_dctx);
matrix.marginalize_nnz(marg, nullptr, false);
}
for (std::size_t i = 0; i < marg_local.size(); ++i) {
if (marg_local[i] != 0) {
marg.add(i, marg_local[i]);
}
}
};

assert(!marg.empty());
Expand Down Expand Up @@ -457,16 +444,10 @@ inline void SparseMatrixChunked::times_outer_product_marg(MargsVector& marg,
fs.exceptions(_fs.exceptions());
fs.open(_path, std::ios::in | std::ios::binary);
auto matrix = _matrix;
MargsVector marg_local(marg.size());
for (const auto offset : nonstd::span(_index).subspan(istart, iend - istart)) {
fs.seekg(offset);
matrix.deserialize(fs, *zstd_dctx);
matrix.times_outer_product_marg(marg_local, biases, weights, nullptr, false);
}
for (std::size_t i = 0; i < marg.size(); ++i) {
if (marg_local[i] != 0) {
marg.add(i, marg_local[i]);
}
matrix.times_outer_product_marg(marg, biases, weights, nullptr, false);
}
};

Expand Down