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

Function DoSameOnAllWorkersDistributedQuantile

tests/cpp/common/test_quantile.cc:457–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457void DoSameOnAllWorkersDistributedQuantile(ContainerCase const& c) {
458 Context ctx;
459 auto const world = collective::GetWorldSize();
460 auto ft = FeatureTypes(c);
461 auto rank = collective::GetRank();
462 auto full_m = RandomDataGenerator{c.rows * static_cast<std::size_t>(world), c.cols, c.sparsity}
463 .Seed(c.seed)
464 .Lower(.0f)
465 .Upper(1.0f)
466 .Type(ft)
467 .MaxCategory(13)
468 .GenerateDMatrix();
469 if (c.weights == WeightKind::kRow) {
470 full_m->Info().weights_.HostVector() =
471 GenerateWeights(c.rows * static_cast<std::size_t>(world), c.seed + 4096);
472 }
473 std::vector<std::int32_t> ridxs(c.rows);
474 auto row_begin = static_cast<std::size_t>(rank) * c.rows;
475 std::iota(ridxs.begin(), ridxs.end(), static_cast<std::int32_t>(row_begin));
476 std::shared_ptr<DMatrix> m{full_m->Slice(Span<std::int32_t const>{ridxs.data(), ridxs.size()})};
477
478 std::vector<bst_idx_t> column_size(c.cols, c.rows);
479 std::vector<float> hessian(c.rows, 1.0f);
480 auto hess = Span<float const>{hessian};
481 HostSketchContainer row_sketch(&ctx, c.max_bin, m->Info().feature_types.ConstHostSpan(),
482 column_size, false);
483 for (auto const& page : m->GetBatches<SparsePage>(&ctx)) {
484 row_sketch.PushRowPage(page, m->Info(), hess);
485 }
486 auto row_cuts = row_sketch.MakeCuts(&ctx, m->Info());
487 AssertSameOnAllWorkers(&ctx, row_cuts);
488
489 HostSketchContainer sorted_sketch(&ctx, c.max_bin, m->Info().feature_types.ConstHostSpan(),
490 column_size, false);
491 for (auto const& page : m->GetBatches<SortedCSCPage>(&ctx)) {
492 sorted_sketch.PushColPage(page, m->Info(), hess);
493 }
494 auto sorted_cuts = sorted_sketch.MakeCuts(&ctx, m->Info());
495 AssertSameOnAllWorkers(&ctx, sorted_cuts);
496
497 collective::Finalize();
498}
499} // namespace
500
501TEST_P(QuantileDistributedContainerTest, Invariants) {

Callers 1

TESTFunction · 0.85

Calls 15

GetWorldSizeFunction · 0.85
FeatureTypesFunction · 0.85
GetRankFunction · 0.85
GenerateWeightsFunction · 0.85
AssertSameOnAllWorkersFunction · 0.85
GenerateDMatrixMethod · 0.80
MaxCategoryMethod · 0.80
SeedMethod · 0.80
ConstHostSpanMethod · 0.80
PushRowPageMethod · 0.80
MakeCutsMethod · 0.80
PushColPageMethod · 0.80

Tested by

no test coverage detected