Skip to content

Commit

Permalink
Unify CPU hist sketching (#5880)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Aug 11, 2020
1 parent bd6b7f4 commit ee70a23
Show file tree
Hide file tree
Showing 18 changed files with 647 additions and 676 deletions.
1 change: 1 addition & 0 deletions amalgamation/xgboost-all0.cc
Expand Up @@ -70,6 +70,7 @@
#include "../src/common/common.cc"
#include "../src/common/charconv.cc"
#include "../src/common/timer.cc"
#include "../src/common/quantile.cc"
#include "../src/common/host_device_vector.cc"
#include "../src/common/hist_util.cc"
#include "../src/common/json.cc"
Expand Down
20 changes: 20 additions & 0 deletions include/xgboost/data.h
Expand Up @@ -239,6 +239,21 @@ struct BatchParam {
}
};

struct HostSparsePageView {
using Inst = common::Span<Entry const>;

common::Span<bst_row_t const> offset;
common::Span<Entry const> data;

Inst operator[](size_t i) const {
auto size = *(offset.data() + i + 1) - *(offset.data() + i);
return {data.data() + *(offset.data() + i),
static_cast<Inst::index_type>(size)};
}

size_t Size() const { return offset.size() == 0 ? 0 : offset.size() - 1; }
};

/*!
* \brief In-memory storage unit of sparse batch, stored in CSR format.
*/
Expand Down Expand Up @@ -270,6 +285,11 @@ class SparsePage {
static_cast<Inst::index_type>(size)};
}

HostSparsePageView GetView() const {
return {offset.ConstHostSpan(), data.ConstHostSpan()};
}


/*! \brief constructor */
SparsePage() {
this->Clear();
Expand Down

0 comments on commit ee70a23

Please sign in to comment.