Skip to content

Commit

Permalink
Merge CPU sketching implementations.
Browse files Browse the repository at this point in the history
* Merge sparse and dense.
  • Loading branch information
trivialfis committed Aug 5, 2020
1 parent 8599f87 commit 4c68464
Show file tree
Hide file tree
Showing 18 changed files with 655 additions and 676 deletions.
1 change: 1 addition & 0 deletions amalgamation/xgboost-all0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 4c68464

Please sign in to comment.