2#include "../../src/data/ellpack_page.cuh"
10#if defined(__CUDACC__)
12class HistogramCutsWrapper :
public common::HistogramCuts {
14 using SuperT = common::HistogramCuts;
15 void SetValues(std::vector<float> cuts) {
16 SuperT::cut_values_.HostVector() = std::move(cuts);
18 void SetPtrs(std::vector<uint32_t> ptrs) {
19 SuperT::cut_ptrs_.HostVector() = std::move(ptrs);
21 void SetMins(std::vector<float> mins) {
22 SuperT::min_vals_.HostVector() = std::move(mins);
27inline std::unique_ptr<EllpackPageImpl> BuildEllpackPage(
28 int n_rows,
int n_cols,
bst_float sparsity= 0) {
29 auto dmat = RandomDataGenerator(n_rows, n_cols, sparsity).Seed(3).GenerateDMatrix();
32 HistogramCutsWrapper cmat;
33 cmat.SetPtrs({0, 3, 6, 9, 12, 15, 18, 21, 24});
35 cmat.SetValues({0.30f, 0.67f, 1.64f,
42 0.26f, 0.71f, 1.83f});
43 cmat.SetMins({0.1f, 0.2f, 0.3f, 0.1f, 0.2f, 0.3f, 0.2f, 0.2f});
46 const auto &offset_vec = batch.offset.ConstHostVector();
47 for (
size_t i = 1; i < offset_vec.size(); ++i) {
48 row_stride = std::max(row_stride, offset_vec[i] - offset_vec[i-1]);
51 auto page = std::unique_ptr<EllpackPageImpl>(
52 new EllpackPageImpl(0, cmat, batch, dmat->IsDense(), row_stride, {}));
In-memory storage unit of sparse batch, stored in CSR format.
Definition data.h:328
Copyright 2015-2023 by XGBoost Contributors.
namespace of xgboost
Definition base.h:90
std::size_t bst_row_t
Type for data row index.
Definition base.h:110
float bst_float
float type, used for storing statistics
Definition base.h:97