xgboost/tests/cpp/data/test_gradient_index.cc
Jiaming Yuan 3515931305
Initial support for external memory in gradient index. (#7183)
* Add hessian to batch param in preparation of new approx impl.
* Extract a push method for gradient index matrix.
* Use span instead of vector ref for hessian in sketching.
* Create a binary format for gradient index.
2021-09-13 12:40:56 +08:00

27 lines
716 B
C++

/*!
* Copyright 2021 XGBoost contributors
*/
#include <gtest/gtest.h>
#include <xgboost/data.h>
#include "../helpers.h"
#include "../../../src/data/gradient_index.h"
namespace xgboost {
namespace data {
TEST(GradientIndex, ExternalMemory) {
std::unique_ptr<DMatrix> dmat = CreateSparsePageDMatrix(10000);
std::vector<size_t> base_rowids;
std::vector<float> hessian(dmat->Info().num_row_, 1);
for (auto const& page : dmat->GetBatches<GHistIndexMatrix>({0, 64, hessian})) {
base_rowids.push_back(page.base_rowid);
}
size_t i = 0;
for (auto const& page : dmat->GetBatches<SparsePage>()) {
ASSERT_EQ(base_rowids[i], page.base_rowid);
++i;
}
}
} // namespace data
} // namespace xgboost