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

Function DoPropertyDistributedQuantile

tests/cpp/common/test_quantile.cc:412–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410
411namespace {
412void DoPropertyDistributedQuantile(ContainerCase const& c) {
413 Context ctx;
414 auto const world = collective::GetWorldSize();
415 auto ft = FeatureTypes(c);
416 auto rank = collective::GetRank();
417 auto full_m = RandomDataGenerator{c.rows * static_cast<std::size_t>(world), c.cols, c.sparsity}
418 .Seed(c.seed)
419 .Lower(.0f)
420 .Upper(1.0f)
421 .Type(ft)
422 .MaxCategory(13)
423 .GenerateDMatrix();
424 if (c.weights == WeightKind::kRow) {
425 full_m->Info().weights_.HostVector() =
426 GenerateWeights(c.rows * static_cast<std::size_t>(world), c.seed + 4096);
427 }
428 std::vector<std::int32_t> ridxs(c.rows);
429 auto row_begin = static_cast<std::size_t>(rank) * c.rows;
430 std::iota(ridxs.begin(), ridxs.end(), static_cast<std::int32_t>(row_begin));
431 std::shared_ptr<DMatrix> m{full_m->Slice(Span<std::int32_t const>{ridxs.data(), ridxs.size()})};
432
433 std::vector<bst_idx_t> column_size(c.cols, c.rows);
434 std::vector<float> hessian(c.rows, 1.0f);
435 auto hess = Span<float const>{hessian};
436 HostSketchContainer row_sketch(&ctx, c.max_bin, m->Info().feature_types.ConstHostSpan(),
437 column_size, false);
438 for (auto const& page : m->GetBatches<SparsePage>(&ctx)) {
439 row_sketch.PushRowPage(page, m->Info(), hess);
440 }
441 auto row_cuts = row_sketch.MakeCuts(&ctx, m->Info());
442
443 HostSketchContainer sorted_sketch(&ctx, c.max_bin, m->Info().feature_types.ConstHostSpan(),
444 column_size, false);
445 for (auto const& page : m->GetBatches<SortedCSCPage>(&ctx)) {
446 sorted_sketch.PushColPage(page, m->Info(), hess);
447 }
448 auto sorted_cuts = sorted_sketch.MakeCuts(&ctx, m->Info());
449
450 collective::Finalize();
451 CHECK_EQ(collective::GetWorldSize(), 1);
452 auto columns = CollectWeightedColumns(full_m.get());
453 ValidateContainerCuts(c, row_cuts, full_m.get(), columns);
454 ValidateContainerCuts(c, sorted_cuts, full_m.get(), columns);
455}
456
457void DoSameOnAllWorkersDistributedQuantile(ContainerCase const& c) {
458 Context ctx;

Callers 1

TEST_PFunction · 0.85

Calls 15

GetWorldSizeFunction · 0.85
FeatureTypesFunction · 0.85
GetRankFunction · 0.85
GenerateWeightsFunction · 0.85
CollectWeightedColumnsFunction · 0.85
ValidateContainerCutsFunction · 0.85
GenerateDMatrixMethod · 0.80
MaxCategoryMethod · 0.80
SeedMethod · 0.80
ConstHostSpanMethod · 0.80
PushRowPageMethod · 0.80
MakeCutsMethod · 0.80

Tested by

no test coverage detected