Unify CPU hist sketching (#5880)
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user