| 688 | |
| 689 | namespace { |
| 690 | void VerifySparsePredictionColumnSplit(bool use_gpu, Json const &model, std::size_t rows, |
| 691 | std::size_t cols, float sparsity, |
| 692 | std::vector<float> const &expected_predt) { |
| 693 | Context ctx; |
| 694 | if (use_gpu) { |
| 695 | ctx = MakeCUDACtx(curt::AllVisibleGPUs() == 1 ? 0 : collective::GetRank()); |
| 696 | } |
| 697 | auto Xy = RandomDataGenerator(rows, cols, sparsity).GenerateDMatrix(true); |
| 698 | std::shared_ptr<DMatrix> sliced{Xy->SliceCol(collective::GetWorldSize(), collective::GetRank())}; |
| 699 | HostDeviceVector<float> sparse_predt; |
| 700 | |
| 701 | std::unique_ptr<Learner> learner{Learner::Create({sliced})}; |
| 702 | learner->SetParam("device", ctx.DeviceName()); |
| 703 | learner->LoadModel(model); |
| 704 | learner->Predict(sliced, false, &sparse_predt, 0, 0); |
| 705 | |
| 706 | auto const &predt = sparse_predt.HostVector(); |
| 707 | ASSERT_EQ(predt.size(), expected_predt.size()); |
| 708 | for (size_t i = 0; i < predt.size(); ++i) { |
| 709 | ASSERT_FLOAT_EQ(predt[i], expected_predt[i]); |
| 710 | } |
| 711 | } |
| 712 | } // anonymous namespace |
| 713 | |
| 714 | void TestSparsePredictionColumnSplit(int world_size, bool use_gpu, float sparsity) { |
no test coverage detected