From 0ae8df9a65cc7a62ff4a9274ad4ae7572d2566c0 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Mon, 16 Jan 2023 22:52:13 +0800 Subject: [PATCH] Define default ctors for gpair. (#8660) * Define default ctors for gpair. Fix clang warning: Definition of implicit copy assignment operator for 'GradientPairInternal' is deprecated because it has a user-declared copy constructor --- include/xgboost/base.h | 14 +++++++++----- src/linear/updater_gpu_coordinate.cu | 7 +++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/xgboost/base.h b/include/xgboost/base.h index a1703d610..ba2ea7886 100644 --- a/include/xgboost/base.h +++ b/include/xgboost/base.h @@ -1,18 +1,19 @@ -/*! - * Copyright (c) 2015 by Contributors +/** + * Copyright 2015-2023 by XGBoost Contributors * \file base.h - * \brief defines configuration macros of xgboost. + * \brief Defines configuration macros and basic types for xgboost. */ #ifndef XGBOOST_BASE_H_ #define XGBOOST_BASE_H_ #include #include + #include #include -#include #include #include +#include /*! * \brief string flag for R library, to leave hooks when needed. @@ -164,7 +165,10 @@ class GradientPairInternal { } // Copy constructor if of same value type, marked as default to be trivially_copyable - GradientPairInternal(const GradientPairInternal &g) = default; + GradientPairInternal(GradientPairInternal const &g) = default; + GradientPairInternal(GradientPairInternal &&g) = default; + GradientPairInternal &operator=(GradientPairInternal const &that) = default; + GradientPairInternal &operator=(GradientPairInternal &&that) = default; // Copy constructor if different value type - use getters and setters to // perform conversion diff --git a/src/linear/updater_gpu_coordinate.cu b/src/linear/updater_gpu_coordinate.cu index ba98f4949..b63c1317e 100644 --- a/src/linear/updater_gpu_coordinate.cu +++ b/src/linear/updater_gpu_coordinate.cu @@ -1,5 +1,5 @@ -/*! - * Copyright 2018-2019 by Contributors +/** + * Copyright 2018-2023 by XGBoost Contributors * \author Rory Mitchell */ @@ -202,8 +202,7 @@ class GPUCoordinateUpdater : public LinearUpdater { // NOLINT auto f = [=] __device__(size_t idx) { auto entry = d_col[idx]; auto g = d_gpair[entry.index * num_group + group_idx]; - return GradientPair(g.GetGrad() * entry.fvalue, - g.GetHess() * entry.fvalue * entry.fvalue); + return GradientPair{g.GetGrad() * entry.fvalue, g.GetHess() * entry.fvalue * entry.fvalue}; }; // NOLINT thrust::transform_iterator multiply_iterator(counting, f);