| 19 | using namespace xgboost; // NOLINT |
| 20 | template <typename Page> |
| 21 | void 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 | |
| 58 | TEST(SparsePageDMatrix, Load) { |
| 59 | Context ctx; |
nothing calls this directly
no test coverage detected