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:
Jiaming Yuan
2022-02-23 11:37:21 +08:00
committed by GitHub
parent 49c74a5369
commit 6762c45494
12 changed files with 149 additions and 148 deletions

View File

@@ -306,8 +306,8 @@ TEST(HistUtil, IndexBinBound) {
}
template <typename T>
void CheckIndexData(T* data_ptr, uint32_t* offsets,
const GHistIndexMatrix& hmat, size_t n_cols) {
void CheckIndexData(T const* data_ptr, uint32_t const* offsets, const GHistIndexMatrix& hmat,
size_t n_cols) {
for (size_t i = 0; i < hmat.index.Size(); ++i) {
EXPECT_EQ(data_ptr[i] + offsets[i % n_cols], hmat.index[i]);
}
@@ -323,7 +323,7 @@ TEST(HistUtil, IndexBinData) {
for (auto max_bin : kBinSizes) {
auto p_fmat = RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
GHistIndexMatrix hmat(p_fmat.get(), max_bin, 0.5, false, common::OmpGetNumThreads(0));
uint32_t* offsets = hmat.index.Offset();
uint32_t const* offsets = hmat.index.Offset();
EXPECT_EQ(hmat.index.Size(), kRows*kCols);
switch (max_bin) {
case kBinSizes[0]: