From 809fdf85894fb432d55a659d94c745c1f13046a1 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Mon, 26 Jan 2026 17:34:27 +0800 Subject: [PATCH 1/2] Move header files from `include` to `src`. We have a semi-working C++ "interface" that's not really an interface. Some files are impossible to be used without hacking inside XGBoost. This PR hides the following files to reduce confusion and to reduce the need for broken forward declarations: - learner.h - gbm.h - cache.h - predictor.h Aside from automated headers sorting, I did not make much change, to make sure git recognize this PR is doing a simple rename. --- plugin/sycl/predictor/predictor.cc | 4 +- src/c_api/c_api.cc | 5 +- src/c_api/c_api.cu | 4 +- src/c_api/c_api_utils.h | 4 +- src/common/api_entry.h | 13 +++-- {include/xgboost => src/common}/cache.h | 7 +-- src/data/data.cc | 4 +- src/gbm/gblinear.cc | 8 +-- src/gbm/gblinear_model.h | 4 +- src/gbm/gbm.cc | 6 +- {include/xgboost => src/gbm}/gbm.h | 2 +- src/gbm/gbtree.cc | 4 +- src/gbm/gbtree.h | 6 +- src/gbm/gbtree_model.cc | 4 +- src/gbm/gbtree_model.h | 4 +- src/learner.cc | 56 +++++++++---------- {include/xgboost => src}/learner.h | 7 +-- src/metric/rank_metric.cc | 4 +- src/predictor/cpu_predictor.cc | 4 +- src/predictor/gpu_predictor.cu | 2 +- src/predictor/predictor.cc | 6 +- .../xgboost => src/predictor}/predictor.h | 15 ++--- src/predictor/utils.h | 4 +- tests/cpp/c_api/test_c_api.cc | 4 +- tests/cpp/common/test_categorical.cc | 4 +- tests/cpp/gbm/test_gblinear.cc | 7 ++- tests/cpp/gbm/test_gblinear.cu | 4 +- tests/cpp/gbm/test_gbtree.cc | 6 +- tests/cpp/gbm/test_gbtree.cu | 4 +- tests/cpp/helpers.cc | 8 +-- tests/cpp/helpers.h | 4 +- tests/cpp/linear/test_linear.cc | 7 +-- tests/cpp/linear/test_linear.cu | 3 +- tests/cpp/plugin/test_sycl_predictor.cc | 4 +- tests/cpp/predictor/test_cpu_predictor.cc | 2 +- tests/cpp/predictor/test_gpu_predictor.cu | 6 +- tests/cpp/predictor/test_predictor.cc | 4 +- tests/cpp/predictor/test_predictor.h | 4 +- tests/cpp/test_cache.cc | 12 ++-- tests/cpp/test_learner.cc | 6 +- tests/cpp/test_learner.cu | 4 +- tests/cpp/test_multi_target.cc | 35 ++++++------ tests/cpp/test_serialization.cc | 6 +- tests/cpp/tree/test_prune.cc | 3 +- 44 files changed, 153 insertions(+), 161 deletions(-) rename {include/xgboost => src/common}/cache.h (98%) rename {include/xgboost => src/gbm}/gbm.h (99%) rename {include/xgboost => src}/learner.h (98%) rename {include/xgboost => src/predictor}/predictor.h (95%) diff --git a/plugin/sycl/predictor/predictor.cc b/plugin/sycl/predictor/predictor.cc index 1b4f8f9ee2d6..fc00d4ae7e2c 100755 --- a/plugin/sycl/predictor/predictor.cc +++ b/plugin/sycl/predictor/predictor.cc @@ -1,5 +1,5 @@ /*! - * Copyright by Contributors 2017-2025 + * Copyright by Contributors 2017-2026 */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wtautological-constant-compare" @@ -17,7 +17,7 @@ #include "dmlc/registry.h" #include "xgboost/tree_model.h" -#include "xgboost/predictor.h" +#include "../../../src/predictor/predictor.h" #include "xgboost/tree_updater.h" #include "../../../src/common/timer.h" diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index 313175a2d584..caaca121b171 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -1,5 +1,5 @@ /** - * Copyright 2014-2025, XGBoost Contributors + * Copyright 2014-2026, XGBoost Contributors */ #include "xgboost/c_api.h" @@ -29,6 +29,7 @@ #include "../data/proxy_dmatrix.h" // for DMatrixProxy #include "../data/simple_dmatrix.h" // for SimpleDMatrix #include "../encoder/types.h" // for Overloaded +#include "../learner.h" // for Learner, PredictionType #include "c_api_error.h" // for xgboost_CHECK_C_ARG_PTR, API_END, API_BEGIN #include "c_api_utils.h" // for RequiredArg, OptionalArg, GetMissing, CastDM... #include "dmlc/base.h" // for BeginPtr @@ -42,9 +43,7 @@ #include "xgboost/global_config.h" // for GlobalConfiguration, GlobalConfigThreadLocal... #include "xgboost/host_device_vector.h" // for HostDeviceVector #include "xgboost/json.h" // for Json, get, Integer, IsA, Boolean, String -#include "xgboost/learner.h" // for Learner, PredictionType #include "xgboost/logging.h" // for LOG_FATAL, LogMessageFatal, CHECK, LogCheck_EQ -#include "xgboost/predictor.h" // for PredictionCacheEntry #include "xgboost/span.h" // for Span #include "xgboost/string_view.h" // for StringView, operator<< #include "xgboost/version_config.h" // for XGBOOST_VER_MAJOR, XGBOOST_VER_MINOR, XGBOOS... diff --git a/src/c_api/c_api.cu b/src/c_api/c_api.cu index 999d3dfb36d5..db76b94ad3fb 100644 --- a/src/c_api/c_api.cu +++ b/src/c_api/c_api.cu @@ -1,5 +1,5 @@ /** - * Copyright 2019-2025, XGBoost Contributors + * Copyright 2019-2026, XGBoost Contributors */ #include // for transform @@ -13,7 +13,7 @@ #include "xgboost/c_api.h" #include "xgboost/data.h" #include "xgboost/json.h" -#include "xgboost/learner.h" +#include "../learner.h" // for Learner #if defined(XGBOOST_USE_NCCL) #include #endif // defined(XGBOOST_USE_NCCL) diff --git a/src/c_api/c_api_utils.h b/src/c_api/c_api_utils.h index 0138ca808c61..64c3d284910d 100644 --- a/src/c_api/c_api_utils.h +++ b/src/c_api/c_api_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2021-2024, XGBoost Contributors + * Copyright 2021-2026, XGBoost Contributors */ #ifndef XGBOOST_C_API_C_API_UTILS_H_ #define XGBOOST_C_API_C_API_UTILS_H_ @@ -19,7 +19,7 @@ #include "xgboost/data.h" // DMatrix #include "xgboost/feature_map.h" // for FeatureMap #include "xgboost/json.h" -#include "xgboost/learner.h" +#include "../learner.h" // for Learner #include "xgboost/linalg.h" // ArrayInterfaceHandler, MakeTensorView, ArrayInterfaceStr #include "xgboost/logging.h" #include "xgboost/string_view.h" // StringView diff --git a/src/common/api_entry.h b/src/common/api_entry.h index df1fcd70467f..d432ec9d3e6e 100644 --- a/src/common/api_entry.h +++ b/src/common/api_entry.h @@ -1,17 +1,18 @@ /** - * Copyright 2016-2023 by XGBoost contributors + * Copyright 2016-2026, XGBoost contributors */ #ifndef XGBOOST_COMMON_API_ENTRY_H_ #define XGBOOST_COMMON_API_ENTRY_H_ -#include // std::string -#include // std::vector -#include "xgboost/base.h" // GradientPair,bst_ulong -#include "xgboost/predictor.h" // PredictionCacheEntry +#include // for string +#include // for vector + +#include "../predictor/predictor.h" // PredictionCacheEntry +#include "xgboost/base.h" // GradientPair,bst_ulong namespace xgboost { /** - * \brief entry to to easily hold returning information + * @brief entry to to easily hold returning information */ struct XGBAPIThreadLocalEntry { /*! \brief result holder for returning string */ diff --git a/include/xgboost/cache.h b/src/common/cache.h similarity index 98% rename from include/xgboost/cache.h rename to src/common/cache.h index 32e1b21ac3f6..b1061c8ad215 100644 --- a/include/xgboost/cache.h +++ b/src/common/cache.h @@ -1,9 +1,7 @@ /** - * Copyright 2023 by XGBoost contributors + * Copyright 2023-2026, XGBoost contributors */ -#ifndef XGBOOST_CACHE_H_ -#define XGBOOST_CACHE_H_ - +#pragma once #include // for CHECK_EQ, CHECK #include // for size_t @@ -201,4 +199,3 @@ class DMatrixCache { } }; } // namespace xgboost -#endif // XGBOOST_CACHE_H_ diff --git a/src/data/data.cc b/src/data/data.cc index fa0545d09b08..e920237606e0 100644 --- a/src/data/data.cc +++ b/src/data/data.cc @@ -1,5 +1,5 @@ /** - * Copyright 2015-2025, XGBoost Contributors + * Copyright 2015-2026, XGBoost Contributors * \file data.cc */ #include "xgboost/data.h" @@ -52,7 +52,7 @@ #include "xgboost/base.h" // for bst_group_t, bst_idx_t, bst_float, bst_ulong #include "xgboost/context.h" // for Context #include "xgboost/host_device_vector.h" // for HostDeviceVector -#include "xgboost/learner.h" // for HostDeviceVector +#include "../learner.h" // for Learner #include "xgboost/linalg.h" // for Tensor, Stack, TensorView, Vector, ArrayInte... #include "xgboost/logging.h" // for Error, LogCheck_EQ, CHECK, CHECK_EQ, LOG #include "xgboost/span.h" // for Span, operator!=, SpanIterator diff --git a/src/gbm/gblinear.cc b/src/gbm/gblinear.cc index 3bd03a3b4a41..125d79968ff0 100644 --- a/src/gbm/gblinear.cc +++ b/src/gbm/gblinear.cc @@ -1,5 +1,5 @@ /** - * Copyright 2014-2025, XGBoost Contributors + * Copyright 2014-2026, XGBoost Contributors * \file gblinear.cc * \brief Implementation of Linear booster, with L1/L2 regularization: Elastic Net * the update rule is parallel coordinate descent (shotgun) @@ -17,13 +17,13 @@ #include "../common/threading_utils.h" #include "../common/timer.h" #include "gblinear_model.h" -#include "xgboost/gbm.h" +#include "gbm.h" // for GradientContainer #include "xgboost/json.h" -#include "xgboost/learner.h" +#include "../learner.h" // for LearnerModelParam #include "xgboost/linalg.h" #include "xgboost/linear_updater.h" #include "xgboost/logging.h" -#include "xgboost/predictor.h" +#include "../predictor/predictor.h" // for Predictor namespace xgboost::gbm { DMLC_REGISTRY_FILE_TAG(gblinear); diff --git a/src/gbm/gblinear_model.h b/src/gbm/gblinear_model.h index 08ae56959461..8be2d6e3c409 100644 --- a/src/gbm/gblinear_model.h +++ b/src/gbm/gblinear_model.h @@ -1,10 +1,10 @@ /** - * Copyright 2018-2025, XGBoost Contributors + * Copyright 2018-2026, XGBoost Contributors */ #pragma once #include #include -#include +#include "../learner.h" // for LearnerModelParam #include #include diff --git a/src/gbm/gbm.cc b/src/gbm/gbm.cc index ecee708ecb8e..1854edb93943 100644 --- a/src/gbm/gbm.cc +++ b/src/gbm/gbm.cc @@ -1,16 +1,16 @@ /** - * Copyright 2015-2025, XGBoost Contributors + * Copyright 2015-2026, XGBoost Contributors * \file gbm.cc * \brief Registry of gradient boosters. */ -#include "xgboost/gbm.h" +#include "gbm.h" #include #include #include "xgboost/context.h" -#include "xgboost/learner.h" +#include "../learner.h" // for LearnerModelParam namespace dmlc { DMLC_REGISTRY_ENABLE(::xgboost::GradientBoosterReg); diff --git a/include/xgboost/gbm.h b/src/gbm/gbm.h similarity index 99% rename from include/xgboost/gbm.h rename to src/gbm/gbm.h index 65940773ffee..742f91abab8b 100644 --- a/include/xgboost/gbm.h +++ b/src/gbm/gbm.h @@ -1,5 +1,5 @@ /** - * Copyright 2014-2025, XGBoost Contributors + * Copyright 2014-2026, XGBoost Contributors * \file gbm.h * \brief Interface of gradient booster, * that learns through gradient statistics. diff --git a/src/gbm/gbtree.cc b/src/gbm/gbtree.cc index 06f89242b1d0..40142c584059 100644 --- a/src/gbm/gbtree.cc +++ b/src/gbm/gbtree.cc @@ -24,16 +24,16 @@ #include "../common/threading_utils.h" #include "../common/timer.h" #include "../data/proxy_dmatrix.h" // for DMatrixProxy, HostAdapterDispatch +#include "gbm.h" #include "gbtree_model.h" #include "xgboost/base.h" #include "xgboost/data.h" -#include "xgboost/gbm.h" #include "xgboost/host_device_vector.h" #include "xgboost/json.h" #include "xgboost/logging.h" #include "xgboost/model.h" #include "xgboost/objective.h" -#include "xgboost/predictor.h" +#include "../predictor/predictor.h" // for Predictor #include "xgboost/string_view.h" // for StringView #include "xgboost/tree_model.h" // for RegTree #include "xgboost/tree_updater.h" diff --git a/src/gbm/gbtree.h b/src/gbm/gbtree.h index ec39e2748799..325592899716 100644 --- a/src/gbm/gbtree.h +++ b/src/gbm/gbtree.h @@ -1,5 +1,5 @@ /** - * Copyright 2014-2025, XGBoost Contributors + * Copyright 2014-2026, XGBoost Contributors * \file gbtree.cc * \brief gradient boosted tree implementation. * \author Tianqi Chen @@ -20,15 +20,15 @@ #include "../common/timer.h" #include "../tree/param.h" // TrainParam #include "../tree/tree_view.h" // for WalkTree +#include "gbm.h" // for GradientBooster #include "gbtree_model.h" #include "xgboost/base.h" #include "xgboost/data.h" -#include "xgboost/gbm.h" #include "xgboost/host_device_vector.h" #include "xgboost/json.h" #include "xgboost/logging.h" #include "xgboost/parameter.h" -#include "xgboost/predictor.h" +#include "../predictor/predictor.h" // for Predictor #include "xgboost/tree_updater.h" namespace xgboost { diff --git a/src/gbm/gbtree_model.cc b/src/gbm/gbtree_model.cc index ecb6a66e9c17..e8183cdbf03f 100644 --- a/src/gbm/gbtree_model.cc +++ b/src/gbm/gbtree_model.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2025, XGBoost Contributors + * Copyright 2019-2026, XGBoost Contributors */ #include "gbtree_model.h" @@ -11,7 +11,7 @@ #include "../common/threading_utils.h" // for ParallelFor #include "xgboost/context.h" // for Context #include "xgboost/json.h" // for Json, get, Integer, Array, FromJson, ToJson, Json... -#include "xgboost/learner.h" // for LearnerModelParam +#include "../learner.h" // for LearnerModelParam #include "xgboost/logging.h" // for LogCheck_EQ, CHECK_EQ, CHECK #include "xgboost/tree_model.h" // for RegTree diff --git a/src/gbm/gbtree_model.h b/src/gbm/gbtree_model.h index 51f0962abf37..fe60a972bfd8 100644 --- a/src/gbm/gbtree_model.h +++ b/src/gbm/gbtree_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2017-2025, XGBoost Contributors + * Copyright 2017-2026, XGBoost Contributors * * @file gbtree_model.h */ @@ -15,7 +15,7 @@ #include "../common/threading_utils.h" #include "../data/cat_container.h" // for CatContainer #include "xgboost/context.h" -#include "xgboost/learner.h" +#include "../learner.h" // for LearnerModelParam #include "xgboost/model.h" #include "xgboost/tree_model.h" diff --git a/src/learner.cc b/src/learner.cc index 26ebc1e6f9c4..dcea717d151c 100644 --- a/src/learner.cc +++ b/src/learner.cc @@ -4,47 +4,47 @@ * \brief Implementation of learning algorithm. * \author Tianqi Chen */ -#include "xgboost/learner.h" - -#include // for Stream -#include // for FieldEntry, DMLC_DECLARE_FIELD, Parameter, DMLC... -#include // for ThreadLocalStore - -#include // for equal, max, transform, sort, find_if, all_of -#include // for atomic -#include // for isalpha, isspace -#include // for isnan, isinf -#include // for int32_t, uint32_t, int64_t, uint64_t -#include // for atoi -#include // for memcpy, size_t, memset -#include // for operator<<, setiosflags -#include // for back_insert_iterator, distance, back_inserter -#include // for numeric_limits -#include // for allocator, unique_ptr, shared_ptr, operator== -#include // for mutex, lock_guard -#include // for operator<<, basic_ostream, basic_ostream::opera... -#include // for stack -#include // for basic_string, char_traits, operator<, string -#include // for errc -#include // for operator!=, unordered_map -#include // for pair, as_const, move, swap -#include // for vector +#include "learner.h" + +#include // for Stream +#include // for FieldEntry, DMLC_DECLARE_FIELD, Parameter, DMLC... +#include // for ThreadLocalStore + +#include // for equal, max, transform, sort, find_if, all_of +#include // for atomic +#include // for isalpha, isspace +#include // for isnan, isinf +#include // for int32_t, uint32_t, int64_t, uint64_t +#include // for atoi +#include // for memcpy, size_t, memset +#include // for operator<<, setiosflags +#include // for back_insert_iterator, distance, back_inserter +#include // for numeric_limits +#include // for allocator, unique_ptr, shared_ptr, operator== +#include // for mutex, lock_guard +#include // for operator<<, basic_ostream, basic_ostream::opera... +#include // for stack +#include // for basic_string, char_traits, operator<, string +#include // for errc +#include // for operator!=, unordered_map +#include // for pair, as_const, move, swap +#include // for vector #include "collective/aggregator.h" // for ApplyWithLabels #include "collective/communicator-inl.h" // for Allreduce, Broadcast, GetRank, IsDistributed #include "common/api_entry.h" // for XGBAPIThreadLocalEntry -#include "common/param_array.h" // for ParamArray #include "common/charconv.h" // for to_chars, to_chars_result, NumericLimits, from_... #include "common/error_msg.h" // for MaxFeatureSize, WarnOldSerialization, ... #include "common/io.h" // for PeekableInStream, ReadAll, FixedSizeStream, Mem... #include "common/observer.h" // for TrainingObserver +#include "common/param_array.h" // for ParamArray #include "common/random.h" // for GlobalRandom #include "common/timer.h" // for Monitor #include "common/version.h" // for Version +#include "gbm/gbm.h" // for GradientBooster #include "xgboost/base.h" // for Args, GradientPair, bst_feature_t #include "xgboost/context.h" // for Context #include "xgboost/data.h" // for DMatrix, MetaInfo -#include "xgboost/gbm.h" // for GradientBooster #include "xgboost/global_config.h" // for GlobalConfiguration, GlobalConfigThreadLocalStore #include "xgboost/host_device_vector.h" // for HostDeviceVector #include "xgboost/json.h" // for Json, get, Object, String, IsA, Array, ToJson @@ -53,7 +53,7 @@ #include "xgboost/metric.h" // for Metric #include "xgboost/objective.h" // for ObjFunction #include "xgboost/parameter.h" // for DECLARE_FIELD_ENUM_CLASS, XGBoostParameter -#include "xgboost/predictor.h" // for PredictionContainer, PredictionCacheEntry +#include "predictor/predictor.h" // for PredictionContainer, PredictionCacheEntry #include "xgboost/string_view.h" // for operator<<, StringView #include "xgboost/task.h" // for ObjInfo diff --git a/include/xgboost/learner.h b/src/learner.h similarity index 98% rename from include/xgboost/learner.h rename to src/learner.h index ffaddfbe6442..57c30b028d2a 100644 --- a/include/xgboost/learner.h +++ b/src/learner.h @@ -1,12 +1,11 @@ /** - * Copyright 2015-2025, XGBoost Contributors + * Copyright 2015-2026, XGBoost Contributors * * \brief Learner interface that integrates objective, gbm and evaluation together. * This is the user facing XGBoost training module. * \author Tianqi Chen */ -#ifndef XGBOOST_LEARNER_H_ -#define XGBOOST_LEARNER_H_ +#pragma once #include // for Serializable #include // for bst_feature_t, bst_target_t, bst_float, Args, GradientPair, .. @@ -352,6 +351,4 @@ struct LearnerModelParam { /* \brief Whether this parameter is initialized with LearnerModelParamLegacy. */ [[nodiscard]] bool Initialized() const { return num_feature != 0 && num_output_group != 0; } }; - } // namespace xgboost -#endif // XGBOOST_LEARNER_H_ diff --git a/src/metric/rank_metric.cc b/src/metric/rank_metric.cc index d8f69513c24b..e2d26baeec83 100644 --- a/src/metric/rank_metric.cc +++ b/src/metric/rank_metric.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020-2025, XGBoost contributors + * Copyright 2020-2026, XGBoost contributors */ #include "rank_metric.h" @@ -25,7 +25,7 @@ #include "dmlc/common.h" // for OMPException #include "metric_common.h" // for MetricNoCache, GPUMetric, PackedReduceResult #include "xgboost/base.h" // for bst_float, bst_omp_uint, bst_group_t, Args -#include "xgboost/cache.h" // for DMatrixCache +#include "../common/cache.h" // for DMatrixCache #include "xgboost/context.h" // for Context #include "xgboost/data.h" // for MetaInfo, DMatrix #include "xgboost/host_device_vector.h" // for HostDeviceVector diff --git a/src/predictor/cpu_predictor.cc b/src/predictor/cpu_predictor.cc index 7dfa03bbbec1..5f9c4cf0a107 100644 --- a/src/predictor/cpu_predictor.cc +++ b/src/predictor/cpu_predictor.cc @@ -30,11 +30,11 @@ #include "xgboost/context.h" // for Context #include "xgboost/data.h" // for Entry, DMatrix, MetaInfo, SparsePage, Batch... #include "xgboost/host_device_vector.h" // for HostDeviceVector -#include "xgboost/learner.h" // for LearnerModelParam +#include "../learner.h" // for LearnerModelParam +#include "predictor.h" // for PredictionCacheEntry, Predictor, PredictorReg #include "xgboost/linalg.h" // for TensorView, All, VectorView, Tensor #include "xgboost/logging.h" // for LogCheck_EQ, CHECK_EQ, CHECK, LogCheck_NE #include "xgboost/multi_target_tree_model.h" // for MultiTargetTree -#include "xgboost/predictor.h" // for PredictionCacheEntry, Predictor, PredictorReg #include "xgboost/span.h" // for Span #include "xgboost/tree_model.h" // for RegTree, MTNotImplemented, RTreeNodeStat diff --git a/src/predictor/gpu_predictor.cu b/src/predictor/gpu_predictor.cu index e6bbc3d0e650..81bed2cf4719 100644 --- a/src/predictor/gpu_predictor.cu +++ b/src/predictor/gpu_predictor.cu @@ -33,7 +33,7 @@ #include "xgboost/data.h" #include "xgboost/host_device_vector.h" #include "xgboost/multi_target_tree_model.h" // for MultiTargetTree, MultiTargetTreeView -#include "xgboost/predictor.h" +#include "predictor.h" #include "xgboost/tree_model.h" #include "xgboost/tree_updater.h" diff --git a/src/predictor/predictor.cc b/src/predictor/predictor.cc index 592fb3e02069..3d59c2bd337e 100644 --- a/src/predictor/predictor.cc +++ b/src/predictor/predictor.cc @@ -1,7 +1,7 @@ /** - * Copyright 2017-2025, XGBoost Contributors + * Copyright 2017-2026, XGBoost Contributors */ -#include "xgboost/predictor.h" +#include "predictor.h" #include // for DMLC_REGISTRY_LINK_TAG @@ -9,11 +9,11 @@ #include // for string, to_string #include "../gbm/gbtree_model.h" // for GBTreeModel +#include "../learner.h" // for LearnerModelParam #include "xgboost/base.h" // for Args, bst_group_t, bst_idx_t #include "xgboost/context.h" // for Context #include "xgboost/data.h" // for MetaInfo #include "xgboost/host_device_vector.h" // for HostDeviceVector -#include "xgboost/learner.h" // for LearnerModelParam #include "xgboost/linalg.h" // for Tensor, TensorView #include "xgboost/logging.h" // for CHECK_EQ, CHECK_NE, LOG diff --git a/include/xgboost/predictor.h b/src/predictor/predictor.h similarity index 95% rename from include/xgboost/predictor.h rename to src/predictor/predictor.h index 020e0a59d1e8..ff76e11bf156 100644 --- a/include/xgboost/predictor.h +++ b/src/predictor/predictor.h @@ -1,18 +1,19 @@ /** - * Copyright 2017-2025, XGBoost Contributors + * Copyright 2017-2026, XGBoost Contributors * \file predictor.h * \brief Interface of predictor, * performs predictions for a gradient booster. */ #pragma once -#include // for FunctionRegEntryBase -#include // for bst_tree_t -#include // for DMatrixCache -#include // for Context -#include -#include +#include // for FunctionRegEntryBase + +#include // for bst_tree_t +#include // for Context +#include // for DMatrix #include +#include "../common/cache.h" // for DMatrixCache + #include // for function #include // for shared_ptr #include diff --git a/src/predictor/utils.h b/src/predictor/utils.h index b16ac49bc3f9..2ee9f0572297 100644 --- a/src/predictor/utils.h +++ b/src/predictor/utils.h @@ -1,12 +1,12 @@ /** - * Copyright 2017-2025, XGBoost Contributors + * Copyright 2017-2026, XGBoost Contributors */ #pragma once #include // for shared_ptr #include "../data/proxy_dmatrix.h" // for DMatrixProxy #include "xgboost/data.h" // for DMatrix -#include "xgboost/learner.h" // LearnerModelParam +#include "../learner.h" // LearnerModelParam namespace xgboost::predictor { template diff --git a/tests/cpp/c_api/test_c_api.cc b/tests/cpp/c_api/test_c_api.cc index 2a3b01432a62..a1d9d8dac08d 100644 --- a/tests/cpp/c_api/test_c_api.cc +++ b/tests/cpp/c_api/test_c_api.cc @@ -1,11 +1,11 @@ /** - * Copyright 2019-2025, XGBoost contributors + * Copyright 2019-2026, XGBoost contributors */ #include #include #include #include // Json -#include +#include "../../../src/learner.h" // for Learner #include #include // for copy_n diff --git a/tests/cpp/common/test_categorical.cc b/tests/cpp/common/test_categorical.cc index 4e6e696ecfdd..a14fe8b793a5 100644 --- a/tests/cpp/common/test_categorical.cc +++ b/tests/cpp/common/test_categorical.cc @@ -1,9 +1,9 @@ /*! - * Copyright 2021-2022 by XGBoost Contributors + * Copyright 2021-2026, XGBoost Contributors */ #include #include -#include +#include "../../../src/learner.h" // for Learner #include diff --git a/tests/cpp/gbm/test_gblinear.cc b/tests/cpp/gbm/test_gblinear.cc index 731c22f172c9..259fcdc10ede 100644 --- a/tests/cpp/gbm/test_gblinear.cc +++ b/tests/cpp/gbm/test_gblinear.cc @@ -1,16 +1,17 @@ /** - * Copyright 2019-2024, XGBoost Contributors + * Copyright 2019-2026, XGBoost Contributors */ #include #include // for FeatureMap #include +#include "../../../src/gbm/gblinear_model.h" +#include "../../../src/gbm/gbm.h" // for GradientBooster #include "../helpers.h" #include "xgboost/context.h" -#include "xgboost/gbm.h" #include "xgboost/json.h" -#include "xgboost/learner.h" +#include "../../../src/learner.h" // for Learner namespace xgboost::gbm { TEST(GBLinear, JsonIO) { diff --git a/tests/cpp/gbm/test_gblinear.cu b/tests/cpp/gbm/test_gblinear.cu index 94abce062584..69f3090c041c 100644 --- a/tests/cpp/gbm/test_gblinear.cu +++ b/tests/cpp/gbm/test_gblinear.cu @@ -1,10 +1,10 @@ /** - * Copyright 2023-2025, XGBoost Contributors + * Copyright 2023-2026, XGBoost Contributors */ #include #include // for GlobalConfigThreadLocalStore #include // for Json, Object -#include // for Learner +#include "../../../src/learner.h" // for Learner #include // for transform #include // for string diff --git a/tests/cpp/gbm/test_gbtree.cc b/tests/cpp/gbm/test_gbtree.cc index fde9bc3d602f..17b5f7dd383e 100644 --- a/tests/cpp/gbm/test_gbtree.cc +++ b/tests/cpp/gbm/test_gbtree.cc @@ -1,11 +1,11 @@ /** - * Copyright 2019-2025, XGBoost contributors + * Copyright 2019-2026, XGBoost contributors */ #include #include #include // for HostDeviceVector #include // for Json, Object -#include // for Learner +#include "../../../src/learner.h" // for Learner #include // for numeric_limits #include // for shared_ptr @@ -17,7 +17,7 @@ #include "../filesystem.h" // TemporaryDirectory #include "../helpers.h" #include "xgboost/base.h" -#include "xgboost/predictor.h" +#include "../../../src/predictor/predictor.h" // for Predictor namespace xgboost { TEST(GBTree, SelectTreeMethod) { diff --git a/tests/cpp/gbm/test_gbtree.cu b/tests/cpp/gbm/test_gbtree.cu index 1ef909a29720..9086ff5988a3 100644 --- a/tests/cpp/gbm/test_gbtree.cu +++ b/tests/cpp/gbm/test_gbtree.cu @@ -1,8 +1,8 @@ /** - * Copyright 2023-2025, XGBoost contributors + * Copyright 2023-2026, XGBoost contributors */ #include // for Context -#include // for Learner +#include "../../../src/learner.h" // for Learner #include // for StringView #include // for numeric_limits diff --git a/tests/cpp/helpers.cc b/tests/cpp/helpers.cc index b7d54855c67f..86eff29ed3d6 100644 --- a/tests/cpp/helpers.cc +++ b/tests/cpp/helpers.cc @@ -1,12 +1,11 @@ /** - * Copyright 2016-2025, XGBoost contributors + * Copyright 2016-2026, XGBoost contributors */ #include "helpers.h" #include -#include #include -#include +#include "../../src/learner.h" // for Learner #include #include #include @@ -22,9 +21,10 @@ #include "../../src/data/iterative_dmatrix.h" #include "../../src/data/simple_dmatrix.h" #include "../../src/data/sparse_page_dmatrix.h" +#include "../../src/gbm/gbm.h" // for GradientBooster #include "../../src/gbm/gbtree_model.h" #include "xgboost/c_api.h" -#include "xgboost/predictor.h" +#include "../../src/predictor/predictor.h" // for Predictor #if defined(XGBOOST_USE_RMM) && XGBOOST_USE_RMM == 1 #include diff --git a/tests/cpp/helpers.h b/tests/cpp/helpers.h index 747d7c450bbf..0e468554961c 100644 --- a/tests/cpp/helpers.h +++ b/tests/cpp/helpers.h @@ -1,5 +1,5 @@ /** - * Copyright 2016-2025, XGBoost contributors + * Copyright 2016-2026, XGBoost contributors */ #pragma once @@ -10,7 +10,7 @@ #include #include #include -#include // for LearnerModelParam +#include "../../src/learner.h" // for LearnerModelParam #include // for Configurable #include // std::int32_t diff --git a/tests/cpp/linear/test_linear.cc b/tests/cpp/linear/test_linear.cc index 8f81428b3b4b..c2fc3d66fa65 100644 --- a/tests/cpp/linear/test_linear.cc +++ b/tests/cpp/linear/test_linear.cc @@ -1,12 +1,11 @@ -/*! - * Copyright 2018-2019 by Contributors +/** + * Copyright 2018-2026, XGBoost Contributors */ #include -#include +#include "../../../src/gbm/gblinear_model.h" #include "../helpers.h" #include "test_json_io.h" -#include "../../../src/gbm/gblinear_model.h" #include "xgboost/base.h" namespace xgboost { diff --git a/tests/cpp/linear/test_linear.cu b/tests/cpp/linear/test_linear.cu index 8475116bc954..d839b6b8c1f3 100644 --- a/tests/cpp/linear/test_linear.cu +++ b/tests/cpp/linear/test_linear.cu @@ -1,8 +1,7 @@ /** - * Copyright 2018-2023, XGBoost Contributors + * Copyright 2018-2026, XGBoost Contributors */ #include -#include #include "../helpers.h" #include "test_json_io.h" diff --git a/tests/cpp/plugin/test_sycl_predictor.cc b/tests/cpp/plugin/test_sycl_predictor.cc index 04df03e29bc4..aba8b674fbe6 100755 --- a/tests/cpp/plugin/test_sycl_predictor.cc +++ b/tests/cpp/plugin/test_sycl_predictor.cc @@ -1,11 +1,11 @@ /*! - * Copyright 2017-2025 XGBoost contributors + * Copyright 2017-2026, XGBoost contributors */ #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wtautological-constant-compare" #pragma GCC diagnostic ignored "-W#pragma-messages" -#include +#include "../../../src/predictor/predictor.h" // for Predictor #pragma GCC diagnostic pop #pragma GCC diagnostic push diff --git a/tests/cpp/predictor/test_cpu_predictor.cc b/tests/cpp/predictor/test_cpu_predictor.cc index f4cbd588afa6..84b421a20d6a 100644 --- a/tests/cpp/predictor/test_cpu_predictor.cc +++ b/tests/cpp/predictor/test_cpu_predictor.cc @@ -2,7 +2,7 @@ * Copyright 2017-2026, XGBoost contributors */ #include -#include +#include "../../../src/predictor/predictor.h" // for Predictor #include "../../../src/collective/communicator-inl.h" #include "../../../src/data/adapter.h" diff --git a/tests/cpp/predictor/test_gpu_predictor.cu b/tests/cpp/predictor/test_gpu_predictor.cu index 01f19dec6a12..dd4d1fd5735b 100644 --- a/tests/cpp/predictor/test_gpu_predictor.cu +++ b/tests/cpp/predictor/test_gpu_predictor.cu @@ -1,11 +1,11 @@ /** - * Copyright 2017-2025, XGBoost contributors + * Copyright 2017-2026, XGBoost contributors */ #include #include -#include +#include "../../../src/learner.h" // for Learner #include -#include +#include "../../../src/predictor/predictor.h" // for Predictor #include diff --git a/tests/cpp/predictor/test_predictor.cc b/tests/cpp/predictor/test_predictor.cc index 946959182737..c65b5bd0b1d6 100644 --- a/tests/cpp/predictor/test_predictor.cc +++ b/tests/cpp/predictor/test_predictor.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020-2025, XGBoost Contributors + * Copyright 2020-2026, XGBoost Contributors */ #include "test_predictor.h" @@ -8,7 +8,7 @@ #include // for DMatrix, BatchIterator, BatchSet, MetaInfo #include // for HostDeviceVector #include // for Json -#include // for PredictionCacheEntry, Predictor, Predic... +#include "../../../src/predictor/predictor.h" // for PredictionCacheEntry, Predictor #include // for StringView #include // for numeric_limits diff --git a/tests/cpp/predictor/test_predictor.h b/tests/cpp/predictor/test_predictor.h index f9e52b86e5a9..dc568da54efe 100644 --- a/tests/cpp/predictor/test_predictor.h +++ b/tests/cpp/predictor/test_predictor.h @@ -1,11 +1,11 @@ /** - * Copyright 2020-2023 by XGBoost Contributors + * Copyright 2020-2026, XGBoost Contributors */ #ifndef XGBOOST_TEST_PREDICTOR_H_ #define XGBOOST_TEST_PREDICTOR_H_ #include // for Context -#include +#include "../../../src/predictor/predictor.h" // for Predictor #include #include diff --git a/tests/cpp/test_cache.cc b/tests/cpp/test_cache.cc index cd4b28b0536b..cc3028a26f0c 100644 --- a/tests/cpp/test_cache.cc +++ b/tests/cpp/test_cache.cc @@ -1,15 +1,15 @@ /** - * Copyright 2023 by XGBoost contributors + * Copyright 2023-2026, XGBoost contributors */ #include -#include #include // for DMatrix -#include // for size_t -#include // for uint32_t -#include // for thread +#include // for size_t +#include // for uint32_t +#include // for thread -#include "helpers.h" // for RandomDataGenerator +#include "../../src/common/cache.h" // for DMatrixCache +#include "helpers.h" // for RandomDataGenerator namespace xgboost { namespace { diff --git a/tests/cpp/test_learner.cc b/tests/cpp/test_learner.cc index 0beeabcc5a74..e8e7c9ef2c91 100644 --- a/tests/cpp/test_learner.cc +++ b/tests/cpp/test_learner.cc @@ -1,9 +1,8 @@ /** - * Copyright 2017-2025, XGBoost contributors + * Copyright 2017-2026, XGBoost contributors */ #include #include -#include // for Learner #include // for LogCheck_NE, CHECK_NE, LogCheck_EQ #include // for ObjFunction #include // for XGBOOST_VER_MAJOR, XGBOOST_VER_MINOR @@ -26,6 +25,8 @@ #include "../../src/common/io.h" // for LoadSequentialFile #include "../../src/common/linalg_op.h" // for ElementWiseTransformHost, begin, end #include "../../src/common/random.h" // for GlobalRandom +#include "../../src/learner.h" // for Learner +#include "../../src/predictor/predictor.h" // for PredictionCacheEntry #include "./collective/test_worker.h" // for TestDistributedGlobal #include "dmlc/omp.h" // for omp_get_max_threads #include "filesystem.h" // for TemporaryDirectory @@ -39,7 +40,6 @@ #include "xgboost/json.h" // for Json, Object, get, String, IsA, opera... #include "xgboost/linalg.h" // for Tensor, TensorView #include "xgboost/logging.h" // for ConsoleLogger -#include "xgboost/predictor.h" // for PredictionCacheEntry #include "xgboost/string_view.h" // for StringView namespace xgboost { diff --git a/tests/cpp/test_learner.cu b/tests/cpp/test_learner.cu index 2fde49ca0fdb..80372abdd70e 100644 --- a/tests/cpp/test_learner.cu +++ b/tests/cpp/test_learner.cu @@ -1,15 +1,15 @@ /** - * Copyright 2024, XGBoost contributors + * Copyright 2024-2026, XGBoost contributors */ #include #include // for DeviceSym #include // for GlobalConfigThreadLocalStore -#include #include // for int32_t #include // for unique_ptr #include "../../src/common/device_vector.cuh" // for GlobalMemoryLogger +#include "../../src/learner.h" // for Learner #include "helpers.h" // for RandomDataGenerator namespace xgboost { diff --git a/tests/cpp/test_multi_target.cc b/tests/cpp/test_multi_target.cc index cf926ae26563..f00e23dfb0d5 100644 --- a/tests/cpp/test_multi_target.cc +++ b/tests/cpp/test_multi_target.cc @@ -1,24 +1,23 @@ /** - * Copyright 2023-2025, XGBoost Contributors + * Copyright 2023-2026, XGBoost Contributors */ #include -#include // for Args, bst_target_t -#include // for DMatrix, MetaInfo -#include // for Json, get, Object, String -#include // for Learner - -#include // for copy -#include // for size_t -#include // for shared_ptr, allocator, __shared_ptr_access -#include // for accumulate -#include // for stod, string -#include // for vector - -#include "../../src/common/linalg_op.h" // for begin, cbegin, cend -#include "../../src/common/stats.h" // for Median -#include "helpers.h" // for RandomDataGenerator -#include "xgboost/host_device_vector.h" // for HostDeviceVector -#include "xgboost/linalg.h" // for Tensor, All, TensorView, Vector +#include // for Args, bst_target_t +#include // for DMatrix, MetaInfo +#include // for Json, get, Object, String + +#include // for copy +#include // for size_t +#include // for shared_ptr, allocator, __shared_ptr_access +#include // for stod, string +#include // for vector + +#include "../../src/common/linalg_op.h" // for begin, cbegin, cend +#include "../../src/common/stats.h" // for Median +#include "../../src/learner.h" // for Learner +#include "helpers.h" // for RandomDataGenerator +#include "xgboost/host_device_vector.h" // for HostDeviceVector +#include "xgboost/linalg.h" // for Tensor, All, TensorView, Vector namespace xgboost { class TestL1MultiTarget : public ::testing::Test { diff --git a/tests/cpp/test_serialization.cc b/tests/cpp/test_serialization.cc index a033ab72d4cf..cb7dbd004d1e 100644 --- a/tests/cpp/test_serialization.cc +++ b/tests/cpp/test_serialization.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2025, XGBoost Contributors + * Copyright 2019-2026, XGBoost Contributors */ #include "test_serialization.h" @@ -8,13 +8,13 @@ #include #include // for FeatureMap #include // for Json -#include #include #include "../../src/common/io.h" #include "../../src/common/random.h" -#include "filesystem.h" // for TemporaryDirectory +#include "../../src/learner.h" // for Learner +#include "filesystem.h" // for TemporaryDirectory #include "helpers.h" namespace xgboost { diff --git a/tests/cpp/tree/test_prune.cc b/tests/cpp/tree/test_prune.cc index 0b8e3258c9cd..19f1a6b4bb24 100644 --- a/tests/cpp/tree/test_prune.cc +++ b/tests/cpp/tree/test_prune.cc @@ -1,11 +1,10 @@ /** - * Copyright 2018-2025, XGBoost Contributors + * Copyright 2018-2026, XGBoost Contributors */ #include #include #include // for GradientContainer #include // for HostDeviceVector -#include #include #include From 97fb64591b23bfdddc1807f3b66008db33f3afdc Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Mon, 26 Jan 2026 18:20:25 +0800 Subject: [PATCH 2/2] weird. --- plugin/sycl/predictor/predictor.cc | 0 src/gbm/gbm.h | 4 +--- tests/cpp/plugin/test_sycl_predictor.cc | 0 3 files changed, 1 insertion(+), 3 deletions(-) mode change 100755 => 100644 plugin/sycl/predictor/predictor.cc mode change 100755 => 100644 tests/cpp/plugin/test_sycl_predictor.cc diff --git a/plugin/sycl/predictor/predictor.cc b/plugin/sycl/predictor/predictor.cc old mode 100755 new mode 100644 diff --git a/src/gbm/gbm.h b/src/gbm/gbm.h index 742f91abab8b..c23f8f2a98c8 100644 --- a/src/gbm/gbm.h +++ b/src/gbm/gbm.h @@ -5,8 +5,7 @@ * that learns through gradient statistics. * \author Tianqi Chen */ -#ifndef XGBOOST_GBM_H_ -#define XGBOOST_GBM_H_ +#pragma once #include #include @@ -196,4 +195,3 @@ struct GradientBoosterReg ::dmlc::Registry< ::xgboost::GradientBoosterReg>::Get()->__REGISTER__(Name) } // namespace xgboost -#endif // XGBOOST_GBM_H_ diff --git a/tests/cpp/plugin/test_sycl_predictor.cc b/tests/cpp/plugin/test_sycl_predictor.cc old mode 100755 new mode 100644