Span class. (#3548)

* Add basic Span class based on ISO++20.

* Use Span<Entry const> instead of Inst in SparsePage.

* Add DeviceSpan in HostDeviceVector, use it in regression obj.
This commit is contained in:
trivialfis
2018-08-14 13:58:11 +08:00
committed by Rory Mitchell
parent 2b7a1c5780
commit 2c502784ff
28 changed files with 1927 additions and 138 deletions

View File

@@ -58,8 +58,8 @@ void SimpleDMatrix::MakeOneBatch(SparsePage* pcol, bool sorted) {
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
int tid = omp_get_thread_num();
auto inst = batch[i];
for (bst_uint j = 0; j < inst.length; ++j) {
builder.AddBudget(inst[j].index, tid);
for (auto& ins : inst) {
builder.AddBudget(ins.index, tid);
}
}
}
@@ -72,11 +72,11 @@ void SimpleDMatrix::MakeOneBatch(SparsePage* pcol, bool sorted) {
for (long i = 0; i < static_cast<long>(batch.Size()); ++i) { // NOLINT(*)
int tid = omp_get_thread_num();
auto inst = batch[i];
for (bst_uint j = 0; j < inst.length; ++j) {
builder.Push(
inst[j].index,
Entry(static_cast<bst_uint>(batch.base_rowid + i), inst[j].fvalue),
tid);
for (auto& ins : inst) {
builder.Push(ins.index,
Entry(static_cast<bst_uint>(batch.base_rowid + i),
ins.fvalue),
tid);
}
}
}

View File

@@ -45,7 +45,7 @@ class SimpleDMatrix : public DMatrix {
size_t GetColSize(size_t cidx) const override {
auto& batch = *col_iter_.column_page_;
return batch[cidx].length;
return batch[cidx].size();
}
float GetColDensity(size_t cidx) const override {