@@ -110,8 +110,7 @@ class PerGroupWeightPolicy {
110
110
};
111
111
} // anonymous namespace
112
112
113
- namespace xgboost {
114
- namespace metric {
113
+ namespace xgboost ::metric {
115
114
// tag the this file, used by force static link later.
116
115
DMLC_REGISTRY_FILE_TAG (rank_metric);
117
116
@@ -440,9 +439,7 @@ class EvalNDCG : public EvalRankWithCache<ltr::NDCGCache> {
440
439
auto p_discount = p_cache->Discount (ctx_).data ();
441
440
442
441
auto h_label = info.labels .HostView ();
443
- auto h_predt =
444
- linalg::MakeTensorView (ctx_->IsCPU () ? preds.ConstHostSpan () : preds.ConstDeviceSpan (),
445
- {preds.Size ()}, ctx_->gpu_id );
442
+ auto h_predt = linalg::MakeTensorView (ctx_, &preds, preds.Size ());
446
443
auto weights = common::MakeOptionalWeights (ctx_, info.weights_ );
447
444
448
445
common::ParallelFor (n_groups, ctx_->Threads (), [&](auto g) {
@@ -493,9 +490,7 @@ class EvalMAPScore : public EvalRankWithCache<ltr::MAPCache> {
493
490
494
491
auto gptr = p_cache->DataGroupPtr (ctx_);
495
492
auto h_label = info.labels .HostView ().Slice (linalg::All (), 0 );
496
- auto h_predt =
497
- linalg::MakeTensorView (ctx_->IsCPU () ? predt.ConstHostSpan () : predt.ConstDeviceSpan (),
498
- {predt.Size ()}, ctx_->gpu_id );
493
+ auto h_predt = linalg::MakeTensorView (ctx_, &predt, predt.Size ());
499
494
500
495
auto map_gloc = p_cache->Map (ctx_);
501
496
std::fill_n (map_gloc.data (), map_gloc.size (), 0.0 );
@@ -548,5 +543,4 @@ XGBOOST_REGISTER_METRIC(EvalNDCG, "ndcg")
548
543
.set_body([](char const * param) {
549
544
return new EvalNDCG{" ndcg" , param};
550
545
});
551
- } // namespace metric
552
- } // namespace xgboost
546
+ } // namespace xgboost::metric
0 commit comments