MCPcopy Create free account
hub / github.com/dmlc/xgboost / TestSparseDMatrixLoad

Function TestSparseDMatrixLoad

tests/cpp/data/test_sparse_page_dmatrix.cc:21–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using namespace xgboost; // NOLINT
20template <typename Page>
21void TestSparseDMatrixLoad(Context const *ctx) {
22 auto m = RandomDataGenerator{1024, 5, 0.0}.Batches(4).GenerateSparsePageDMatrix("temp", true);
23
24 auto n_threads = 0;
25 auto config = ExtMemConfig{"temp",
26 false,
27 ::xgboost::cuda_impl::AutoHostRatio(),
28 cuda_impl::MatchingPageBytes(),
29 std::numeric_limits<float>::quiet_NaN(),
30 n_threads};
31 ASSERT_EQ(AllThreadsForTest(), m->Ctx()->Threads());
32 ASSERT_EQ(m->Info().num_col_, 5);
33 ASSERT_EQ(m->Info().num_row_, 1024);
34
35 auto simple = RandomDataGenerator{1024, 5, 0.0}.GenerateDMatrix(true);
36 Page out;
37 for (auto const &page : m->GetBatches<Page>(ctx)) {
38 if (std::is_same_v<Page, SparsePage>) {
39 out.Push(page);
40 } else {
41 out.PushCSC(page);
42 }
43 }
44 ASSERT_EQ(m->Info().num_col_, simple->Info().num_col_);
45 ASSERT_EQ(m->Info().num_row_, simple->Info().num_row_);
46 if (std::is_same_v<Page, SortedCSCPage>) {
47 out.SortRows(ctx->Threads());
48 }
49
50 for (auto const &page : simple->GetBatches<Page>(ctx)) {
51 ASSERT_EQ(page.offset.HostVector(), out.offset.HostVector());
52 for (size_t i = 0; i < page.data.Size(); ++i) {
53 ASSERT_EQ(page.data.HostVector()[i].fvalue, out.data.HostVector()[i].fvalue);
54 }
55 }
56}
57
58TEST(SparsePageDMatrix, Load) {
59 Context ctx;

Callers

nothing calls this directly

Calls 13

AutoHostRatioFunction · 0.85
MatchingPageBytesFunction · 0.85
AllThreadsForTestFunction · 0.85
BatchesMethod · 0.80
ThreadsMethod · 0.80
GenerateDMatrixMethod · 0.80
PushCSCMethod · 0.80
SortRowsMethod · 0.80
CtxMethod · 0.45
InfoMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected