22#ifndef XGBOOST_STRICT_R_MODE
23#define XGBOOST_STRICT_R_MODE 0
32#ifndef XGBOOST_LOG_WITH_TIME
33#define XGBOOST_LOG_WITH_TIME 1
39#ifndef XGBOOST_CUSTOMIZE_GLOBAL_PRNG
40#define XGBOOST_CUSTOMIZE_GLOBAL_PRNG XGBOOST_STRICT_R_MODE
46#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4)
47#define XGBOOST_ALIGNAS(X) alignas(X)
49#define XGBOOST_ALIGNAS(X)
53#define XGBOOST_EXPECT(cond, ret) __builtin_expect((cond), (ret))
55#define XGBOOST_EXPECT(cond, ret) (cond)
61#if defined (__CUDA__) || defined(__NVCC__)
62#define XGBOOST_DEVICE __host__ __device__
67#if defined(__CUDA__) || defined(__CUDACC__)
68#define XGBOOST_HOST_DEV_INLINE XGBOOST_DEVICE __forceinline__
69#define XGBOOST_DEV_INLINE __device__ __forceinline__
71#define XGBOOST_HOST_DEV_INLINE
72#define XGBOOST_DEV_INLINE
76#if !defined(XGBOOST_MM_PREFETCH_PRESENT) && !defined(XGBOOST_BUILTIN_PREFETCH_PRESENT)
78#if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))) || defined(__INTEL_COMPILER)
80 #define XGBOOST_MM_PREFETCH_PRESENT
81 #define XGBOOST_BUILTIN_PREFETCH_PRESENT
82#elif defined(__GNUC__)
84#define XGBOOST_BUILTIN_PREFETCH_PRESENT
149 inline void Add(
const ValueT& grad,
const ValueT& hess) {
173 template <
typename T2>
175 SetGrad(g.GetGrad());
176 SetHess(g.GetHess());
192 g.grad_ = grad_ + rhs.grad_;
193 g.hess_ = hess_ + rhs.hess_;
207 g.grad_ = grad_ - rhs.grad_;
208 g.hess_ = hess_ - rhs.hess_;
220 g.grad_ = grad_ * multiplier;
221 g.hess_ = hess_ * multiplier;
233 g.grad_ = grad_ / divisor;
234 g.hess_ = hess_ / divisor;
239 return grad_ == rhs.grad_ && hess_ == rhs.hess_;
244 static_cast<float>(value));
247 friend std::ostream &operator<<(std::ostream &os,
249 os << g.GetGrad() <<
"/" << g.GetHess();
277 XGBOOST_DEVICE [[nodiscard]] T GetQuantisedGrad()
const {
return grad_; }
278 XGBOOST_DEVICE [[nodiscard]] T GetQuantisedHess()
const {
return hess_; }
288 g.grad_ = grad_ + rhs.grad_;
289 g.hess_ = hess_ + rhs.hess_;
301 g.grad_ = grad_ - rhs.grad_;
302 g.hess_ = hess_ - rhs.hess_;
307 return grad_ == rhs.grad_ && hess_ == rhs.hess_;
309 friend std::ostream &operator<<(std::ostream &os,
311 os << g.GetQuantisedGrad() <<
"/" << g.GetQuantisedHess();
316using Args = std::vector<std::pair<std::string, std::string> >;
Fixed point representation for high precision gradient pair. Has a different interface so we don't ac...
Definition base.h:262
Implementation of gradient statistics pair. Template specialisation may be used to overload different...
Definition base.h:137
defines configuration macros
#define XGBOOST_DEVICE
Tag function as usable by device.
Definition base.h:64
detail namespace with internal helper functions
Definition json.hpp:249
namespace of xgboost
Definition base.h:90
int32_t XGBoostVersionT
Type used for representing version number in binary form.
Definition base.h:326
uint32_t bst_feature_t
Type for data column (feature) index.
Definition base.h:101
std::uint32_t bst_group_t
Type for ranking group index.
Definition base.h:114
std::int32_t bst_node_t
Type for tree node index.
Definition base.h:112
dmlc::omp_ulong omp_ulong
define unsigned long for openmp loop
Definition base.h:322
dmlc::omp_uint bst_omp_uint
define unsigned int for openmp loop
Definition base.h:324
std::int32_t bst_tree_t
Type for indexing trees.
Definition base.h:126
std::uint32_t bst_target_t
Type for indexing into output targets.
Definition base.h:118
std::int16_t bst_d_ordinal_t
Ordinal of a CUDA device.
Definition base.h:130
uint64_t bst_ulong
unsigned long integers
Definition base.h:95
std::size_t bst_row_t
Type for data row index.
Definition base.h:110
uint32_t bst_uint
unsigned integer type used for feature index.
Definition base.h:93
int32_t bst_cat_t
Categorical value type.
Definition base.h:99
std::int32_t bst_layer_t
Type for indexing boosted layers.
Definition base.h:122
int32_t bst_bin_t
Type for histogram bin index.
Definition base.h:103
float bst_float
float type, used for storing statistics
Definition base.h:97
constexpr bst_float kRtEps
small eps gap for minimum split decision.
Definition base.h:319
header to handle OpenMP compatibility issues