Small cleanup to gradient index and hist. (#7668)
* Code comments. * Const accessor to index. * Remove some weird variables in the `Index` class. * Simplify the `MemStackAllocator`.
This commit is contained in:
@@ -16,14 +16,6 @@ class GHistIndexRawFormat : public SparsePageFormat<GHistIndexMatrix> {
|
||||
}
|
||||
// indptr
|
||||
fi->Read(&page->row_ptr);
|
||||
// offset
|
||||
using OffsetT = std::iterator_traits<decltype(page->index.Offset())>::value_type;
|
||||
std::vector<OffsetT> offset;
|
||||
if (!fi->Read(&offset)) {
|
||||
return false;
|
||||
}
|
||||
page->index.ResizeOffset(offset.size());
|
||||
std::copy(offset.begin(), offset.end(), page->index.Offset());
|
||||
// data
|
||||
std::vector<uint8_t> data;
|
||||
if (!fi->Read(&data)) {
|
||||
@@ -55,6 +47,9 @@ class GHistIndexRawFormat : public SparsePageFormat<GHistIndexMatrix> {
|
||||
return false;
|
||||
}
|
||||
page->SetDense(is_dense);
|
||||
if (is_dense) {
|
||||
page->index.SetBinOffset(page->cut.Ptrs());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -65,13 +60,6 @@ class GHistIndexRawFormat : public SparsePageFormat<GHistIndexMatrix> {
|
||||
fo->Write(page.row_ptr);
|
||||
bytes += page.row_ptr.size() * sizeof(decltype(page.row_ptr)::value_type) +
|
||||
sizeof(uint64_t);
|
||||
// offset
|
||||
using OffsetT = std::iterator_traits<decltype(page.index.Offset())>::value_type;
|
||||
std::vector<OffsetT> offset(page.index.OffsetSize());
|
||||
std::copy(page.index.Offset(),
|
||||
page.index.Offset() + page.index.OffsetSize(), offset.begin());
|
||||
fo->Write(offset);
|
||||
bytes += page.index.OffsetSize() * sizeof(OffsetT) + sizeof(uint64_t);
|
||||
// data
|
||||
std::vector<uint8_t> data(page.index.begin(), page.index.end());
|
||||
fo->Write(data);
|
||||
|
||||
Reference in New Issue
Block a user