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

Function VerifySparsePredictionColumnSplit

tests/cpp/predictor/test_predictor.cc:690–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688
689namespace {
690void 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
714void TestSparsePredictionColumnSplit(int world_size, bool use_gpu, float sparsity) {

Callers 1

Calls 12

MakeCUDACtxFunction · 0.85
AllVisibleGPUsFunction · 0.85
GetRankFunction · 0.85
RandomDataGeneratorClass · 0.85
GetWorldSizeFunction · 0.85
GenerateDMatrixMethod · 0.80
SetParamMethod · 0.80
DeviceNameMethod · 0.80
PredictMethod · 0.80
SliceColMethod · 0.45
LoadModelMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected