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

Function MakeLabels

tests/cpp/helpers.cc:400–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398
399namespace {
400void MakeLabels(DeviceOrd device, bst_idx_t n_samples, bst_target_t n_classes,
401 bst_target_t n_targets, std::shared_ptr<DMatrix> out) {
402 RandomDataGenerator gen{n_samples, n_targets, 0.0f};
403 if (n_classes != 0) {
404 gen.Lower(0).Upper(n_classes).GenerateDense(out->Info().labels.Data());
405 out->Info().labels.Reshape(n_samples, n_targets);
406 auto& h_labels = out->Info().labels.Data()->HostVector();
407 for (auto& v : h_labels) {
408 v = static_cast<float>(static_cast<uint32_t>(v));
409 }
410 } else {
411 gen.GenerateDense(out->Info().labels.Data());
412 CHECK_EQ(out->Info().labels.Size(), n_samples * n_targets);
413 out->Info().labels.Reshape(n_samples, n_targets);
414 }
415 if (device.IsCUDA()) {
416 out->Info().labels.Data()->SetDevice(device);
417 out->Info().labels.Data()->ConstDevicePointer();
418 out->Info().feature_types.SetDevice(device);
419 out->Info().feature_types.ConstDevicePointer();
420 }
421}
422
423[[nodiscard]] bool DecompAllowFallback() {
424#if defined(XGBOOST_USE_NVCOMP)

Callers 3

GenerateDMatrixMethod · 0.85

Calls 8

GenerateDenseMethod · 0.80
ReshapeMethod · 0.80
DataMethod · 0.45
InfoMethod · 0.45
SizeMethod · 0.45
IsCUDAMethod · 0.45
SetDeviceMethod · 0.45
ConstDevicePointerMethod · 0.45

Tested by

no test coverage detected