You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Claude suggested the following to address Dmitry's comment. It also requires <numeric>.
// Grow batches geometrically so early inserts can see each other in the sparse
// graph; otherwise a batch collapses onto one hub whose pruning orphans nodes.
// Holds batch sizes until the prefix sum below turns them into bounds.
std::vector<size_t> batch_bounds;
// Bound: ramp-up batches + full-size batches + leading 0.
batch_bounds.reserve(std::bit_width(batchsize) + num_batches + 1);
batch_bounds.push_back(0);
for (size_t size = 1, inserted = 0; inserted < num_nodes;
size = std::min(2 * size, batchsize)) {
batch_bounds.push_back(std::min(num_nodes - inserted, size));
inserted += batch_bounds.back();
}
// Only the final remainder batch can be smaller than its predecessor. Moving it
// into the ramp keeps sizes non-decreasing.
auto last = std::prev(batch_bounds.end());
std::rotate(
std::upper_bound(batch_bounds.begin(), last, *last), last, batch_bounds.end()
);
std::partial_sum(batch_bounds.begin(), batch_bounds.end(), batch_bounds.begin());
Activity