Medial Code Documentation
Loading...
Searching...
No Matches
error_msg.h
1
6#ifndef XGBOOST_COMMON_ERROR_MSG_H_
7#define XGBOOST_COMMON_ERROR_MSG_H_
8
9#include <cinttypes> // for uint64_t
10#include <limits> // for numeric_limits
11#include <string> // for string
12
13#include "xgboost/base.h" // for bst_feature_t
14#include "xgboost/context.h" // for Context
15#include "xgboost/logging.h"
16#include "xgboost/string_view.h" // for StringView
17
18namespace xgboost::error {
19constexpr StringView GroupWeight() {
20 return "Size of weight must equal to the number of query groups when ranking group is used.";
21}
22
23constexpr StringView GroupSize() {
24 return "Invalid query group structure. The number of rows obtained from group doesn't equal to ";
25}
26
27constexpr StringView LabelScoreSize() {
28 return "The size of label doesn't match the size of prediction.";
29}
30
31constexpr StringView InfInData() {
32 return "Input data contains `inf` or a value too large, while `missing` is not set to `inf`";
33}
34
35constexpr StringView NoF128() {
36 return "128-bit floating point is not supported on current platform.";
37}
38
39constexpr StringView InconsistentMaxBin() {
40 return "Inconsistent `max_bin`. `max_bin` should be the same across different QuantileDMatrix, "
41 "and consistent with the Booster being trained.";
42}
43
44constexpr StringView UnknownDevice() { return "Unknown device type."; }
45
46inline void MaxFeatureSize(std::uint64_t n_features) {
47 auto max_n_features = std::numeric_limits<bst_feature_t>::max();
48 CHECK_LE(n_features, max_n_features)
49 << "Unfortunately, XGBoost does not support data matrices with "
50 << std::numeric_limits<bst_feature_t>::max() << " features or greater";
51}
52
53constexpr StringView InplacePredictProxy() {
54 return "Inplace predict accepts only DMatrixProxy as input.";
55}
56
57inline void MaxSampleSize(std::size_t n) {
58 LOG(FATAL) << "Sample size too large for the current updater. Maximum number of samples:" << n
59 << ". Consider using a different updater or tree_method.";
60}
61
62constexpr StringView OldSerialization() {
63 return R"doc(If you are loading a serialized model (like pickle in Python, RDS in R) or
64configuration generated by an older version of XGBoost, please export the model by calling
65`Booster.save_model` from that version first, then load it back in current version. See:
66
67 https://xgboost.readthedocs.io/en/stable/tutorials/saving_model.html
68
69for more details about differences between saving model and serializing.
70)doc";
71}
72
73inline void WarnOldSerialization() {
74 // Display it once is enough. Otherwise this can be really verbose in distributed
75 // environments.
76 static thread_local bool logged{false};
77 if (logged) {
78 return;
79 }
80 LOG(WARNING) << OldSerialization();
81 logged = true;
82}
83
84void WarnDeprecatedGPUHist();
85
86void WarnManualUpdater();
87
88void WarnDeprecatedGPUId();
89
90void WarnEmptyDataset();
91
92std::string DeprecatedFunc(StringView old, StringView since, StringView replacement);
93
94constexpr StringView InvalidCUDAOrdinal() {
95 return "Invalid device. `device` is required to be CUDA and there must be at least one GPU "
96 "available for using GPU.";
97}
98
99void MismatchedDevices(Context const* booster, Context const* data);
100} // namespace xgboost::error
101#endif // XGBOOST_COMMON_ERROR_MSG_H_
Copyright 2014-2023, XGBoost Contributors.
Copyright 2015-2023 by XGBoost Contributors.
defines console logging options for xgboost. Use to enforce unified print behavior.
Copyright 2023 by XGBoost contributors.
Definition error_msg.cc:13