Skip to content

Commit c95f5d9

Browse files
authored
Remove the use of deprecated functions. (dmlc#11244)
1 parent 92f29e1 commit c95f5d9

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/metric/auc.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021-2024, XGBoost Contributors
2+
* Copyright 2021-2025, XGBoost Contributors
33
*/
44
#include <thrust/copy.h> // for copy
55
#include <thrust/logical.h> // for any_of
@@ -30,8 +30,8 @@ namespace {
3030
using Pair = thrust::pair<double, double>;
3131

3232
template <typename T, typename U, typename P = thrust::pair<T, U>>
33-
struct PairPlus : public thrust::binary_function<P, P, P> {
34-
XGBOOST_DEVICE P operator()(P const& l, P const& r) const {
33+
struct PairPlus {
34+
XGBOOST_DEVICE P operator()(P const &l, P const &r) const {
3535
return thrust::make_pair(l.first + r.first, l.second + r.second);
3636
}
3737
};

src/tree/gpu_hist/gradient_based_sampler.cu

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019-2024, XGBoost Contributors
2+
* Copyright 2019-2025, XGBoost Contributors
33
*/
44
#include <thrust/functional.h>
55
#include <thrust/random.h>
@@ -21,7 +21,7 @@
2121

2222
namespace xgboost::tree {
2323
/*! \brief A functor that returns random weights. */
24-
class RandomWeight : public thrust::unary_function<size_t, float> {
24+
class RandomWeight {
2525
public:
2626
explicit RandomWeight(size_t seed) : seed_(seed) {}
2727

@@ -37,7 +37,7 @@ class RandomWeight : public thrust::unary_function<size_t, float> {
3737
};
3838

3939
/*! \brief A functor that performs a Bernoulli trial to discard a gradient pair. */
40-
class BernoulliTrial : public thrust::unary_function<size_t, bool> {
40+
class BernoulliTrial {
4141
public:
4242
BernoulliTrial(size_t seed, float p) : rnd_(seed), p_(p) {}
4343

@@ -51,14 +51,14 @@ class BernoulliTrial : public thrust::unary_function<size_t, bool> {
5151
};
5252

5353
/*! \brief A functor that returns true if the gradient pair is non-zero. */
54-
struct IsNonZero : public thrust::unary_function<GradientPair, bool> {
54+
struct IsNonZero {
5555
XGBOOST_DEVICE bool operator()(const GradientPair& gpair) const {
5656
return gpair.GetGrad() != 0 || gpair.GetHess() != 0;
5757
}
5858
};
5959

6060
/*! \brief A functor that clears the row indexes with empty gradient. */
61-
struct ClearEmptyRows : public thrust::binary_function<GradientPair, bst_idx_t, bst_idx_t> {
61+
struct ClearEmptyRows {
6262
static constexpr bst_idx_t InvalidRow() { return std::numeric_limits<std::size_t>::max(); }
6363

6464
XGBOOST_DEVICE size_t operator()(const GradientPair& gpair, size_t row_index) const {
@@ -77,7 +77,7 @@ struct ClearEmptyRows : public thrust::binary_function<GradientPair, bst_idx_t,
7777
* \see Ibragimov, B., & Gusev, G. (2019). Minimal Variance Sampling in Stochastic Gradient
7878
* Boosting. In Advances in Neural Information Processing Systems (pp. 15061-15071).
7979
*/
80-
class CombineGradientPair : public thrust::unary_function<GradientPair, float> {
80+
class CombineGradientPair {
8181
public:
8282
XGBOOST_DEVICE float operator()(const GradientPair& gpair) const {
8383
return sqrtf(powf(gpair.GetGrad(), 2) + kLambda * powf(gpair.GetHess(), 2));
@@ -90,7 +90,7 @@ class CombineGradientPair : public thrust::unary_function<GradientPair, float> {
9090
/*! \brief A functor that calculates the difference between the sample rate and the desired sample
9191
* rows, given a cumulative gradient sum.
9292
*/
93-
class SampleRateDelta : public thrust::binary_function<float, size_t, float> {
93+
class SampleRateDelta {
9494
public:
9595
SampleRateDelta(common::Span<float> threshold, size_t n_rows, size_t sample_rows)
9696
: threshold_(threshold), n_rows_(n_rows), sample_rows_(sample_rows) {}
@@ -114,7 +114,7 @@ class SampleRateDelta : public thrust::binary_function<float, size_t, float> {
114114
};
115115

116116
/*! \brief A functor that performs Poisson sampling, and scales gradient pairs by 1/p_i. */
117-
class PoissonSampling : public thrust::binary_function<GradientPair, size_t, GradientPair> {
117+
class PoissonSampling {
118118
public:
119119
PoissonSampling(common::Span<float> threshold, size_t threshold_index, RandomWeight rnd)
120120
: threshold_(threshold), threshold_index_(threshold_index), rnd_(rnd) {}

src/tree/gpu_hist/histogram.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2020-2024, XGBoost Contributors
2+
* Copyright 2020-2025, XGBoost Contributors
33
*/
44
#include <thrust/iterator/transform_iterator.h> // for make_transform_iterator
55

@@ -41,7 +41,7 @@ XGBOOST_DEV_INLINE bst_idx_t IterIdx(EllpackDeviceAccessor const& matrix,
4141
}
4242
} // anonymous namespace
4343

44-
struct Clip : public thrust::unary_function<GradientPair, Pair> {
44+
struct Clip {
4545
static XGBOOST_DEV_INLINE float Pclip(float v) { return v > 0 ? v : 0; }
4646
static XGBOOST_DEV_INLINE float Nclip(float v) { return v < 0 ? abs(v) : 0; }
4747

0 commit comments

Comments
 (0)