Skip to content

Commit e461132

Browse files
committed
Fix rebase.
1 parent d884113 commit e461132

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/metric/rank_metric.cc

+4-10
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ class PerGroupWeightPolicy {
110110
};
111111
} // anonymous namespace
112112

113-
namespace xgboost {
114-
namespace metric {
113+
namespace xgboost::metric {
115114
// tag the this file, used by force static link later.
116115
DMLC_REGISTRY_FILE_TAG(rank_metric);
117116

@@ -440,9 +439,7 @@ class EvalNDCG : public EvalRankWithCache<ltr::NDCGCache> {
440439
auto p_discount = p_cache->Discount(ctx_).data();
441440

442441
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());
446443
auto weights = common::MakeOptionalWeights(ctx_, info.weights_);
447444

448445
common::ParallelFor(n_groups, ctx_->Threads(), [&](auto g) {
@@ -493,9 +490,7 @@ class EvalMAPScore : public EvalRankWithCache<ltr::MAPCache> {
493490

494491
auto gptr = p_cache->DataGroupPtr(ctx_);
495492
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());
499494

500495
auto map_gloc = p_cache->Map(ctx_);
501496
std::fill_n(map_gloc.data(), map_gloc.size(), 0.0);
@@ -548,5 +543,4 @@ XGBOOST_REGISTER_METRIC(EvalNDCG, "ndcg")
548543
.set_body([](char const* param) {
549544
return new EvalNDCG{"ndcg", param};
550545
});
551-
} // namespace metric
552-
} // namespace xgboost
546+
} // namespace xgboost::metric

src/metric/rank_metric.cu

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
#include "xgboost/logging.h" // for CHECK
2525
#include "xgboost/metric.h"
2626

27-
namespace xgboost {
28-
namespace metric {
27+
namespace xgboost::metric {
2928
// tag the this file, used by force static link later.
3029
DMLC_REGISTRY_FILE_TAG(rank_metric_gpu);
3130

@@ -142,7 +141,7 @@ PackedReduceResult NDCGScore(Context const *ctx, MetaInfo const &info,
142141
}
143142
auto d_label = info.labels.View(ctx->gpu_id).Slice(linalg::All(), 0);
144143
predt.SetDevice(ctx->gpu_id);
145-
auto d_predt = linalg::MakeTensorView(predt.ConstDeviceSpan(), {predt.Size()}, ctx->gpu_id);
144+
auto d_predt = linalg::MakeTensorView(ctx, predt.ConstDeviceSpan(), predt.Size());
146145

147146
auto d_group_ptr = p_cache->DataGroupPtr(ctx);
148147
auto n_groups = info.group_ptr_.size() - 1;
@@ -249,5 +248,4 @@ PackedReduceResult MAPScore(Context const *ctx, MetaInfo const &info,
249248
return result;
250249
}
251250
} // namespace cuda_impl
252-
} // namespace metric
253-
} // namespace xgboost
251+
} // namespace xgboost::metric

0 commit comments

Comments
 (0)