Skip to content

Commit

Permalink
Fix rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Mar 9, 2023
1 parent d884113 commit e461132
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
14 changes: 4 additions & 10 deletions src/metric/rank_metric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ class PerGroupWeightPolicy {
};
} // anonymous namespace

namespace xgboost {
namespace metric {
namespace xgboost::metric {
// tag the this file, used by force static link later.
DMLC_REGISTRY_FILE_TAG(rank_metric);

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

auto h_label = info.labels.HostView();
auto h_predt =
linalg::MakeTensorView(ctx_->IsCPU() ? preds.ConstHostSpan() : preds.ConstDeviceSpan(),
{preds.Size()}, ctx_->gpu_id);
auto h_predt = linalg::MakeTensorView(ctx_, &preds, preds.Size());
auto weights = common::MakeOptionalWeights(ctx_, info.weights_);

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

auto gptr = p_cache->DataGroupPtr(ctx_);
auto h_label = info.labels.HostView().Slice(linalg::All(), 0);
auto h_predt =
linalg::MakeTensorView(ctx_->IsCPU() ? predt.ConstHostSpan() : predt.ConstDeviceSpan(),
{predt.Size()}, ctx_->gpu_id);
auto h_predt = linalg::MakeTensorView(ctx_, &predt, predt.Size());

auto map_gloc = p_cache->Map(ctx_);
std::fill_n(map_gloc.data(), map_gloc.size(), 0.0);
Expand Down Expand Up @@ -548,5 +543,4 @@ XGBOOST_REGISTER_METRIC(EvalNDCG, "ndcg")
.set_body([](char const* param) {
return new EvalNDCG{"ndcg", param};
});
} // namespace metric
} // namespace xgboost
} // namespace xgboost::metric
8 changes: 3 additions & 5 deletions src/metric/rank_metric.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "xgboost/logging.h" // for CHECK
#include "xgboost/metric.h"

namespace xgboost {
namespace metric {
namespace xgboost::metric {
// tag the this file, used by force static link later.
DMLC_REGISTRY_FILE_TAG(rank_metric_gpu);

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

auto d_group_ptr = p_cache->DataGroupPtr(ctx);
auto n_groups = info.group_ptr_.size() - 1;
Expand Down Expand Up @@ -249,5 +248,4 @@ PackedReduceResult MAPScore(Context const *ctx, MetaInfo const &info,
return result;
}
} // namespace cuda_impl
} // namespace metric
} // namespace xgboost
} // namespace xgboost::metric

0 comments on commit e461132

Please sign in to comment.