39#if defined(XGBOOST_USE_DEBUG_OUTPUT)
40 bool constexpr static kObserve {
true};
42 bool constexpr static kObserve {
false};
46 void Update(int32_t iter)
const {
47 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
48 OBSERVER_PRINT <<
"Iter: " << iter << OBSERVER_ENDL;
51 void Observe(
RegTree const& tree) {
52 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
53 OBSERVER_PRINT <<
"Tree:" << OBSERVER_ENDL;
58 OBSERVER_PRINT << str << OBSERVER_ENDL;
61 void Observe(
RegTree const* p_tree) {
62 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
63 auto const& tree = *p_tree;
68 size_t n = std::numeric_limits<std::size_t>::max()) {
69 std::vector<T> copy(span.size());
70 std::copy(span.cbegin(), span.cend(), copy.begin());
71 this->Observe(copy, name, n);
75 void Observe(std::vector<T>
const& h_vec, std::string name,
76 size_t n = std::numeric_limits<std::size_t>::max())
const {
77 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
78 OBSERVER_PRINT <<
"Procedure: " << name << OBSERVER_ENDL;
80 for (
size_t i = 0; i < h_vec.size(); ++i) {
81 OBSERVER_PRINT << h_vec[i] <<
", ";
82 if (i % 8 == 0 && i != 0) {
83 OBSERVER_PRINT << OBSERVER_NEWLINE;
89 OBSERVER_PRINT << OBSERVER_ENDL;
94 size_t n = std::numeric_limits<std::size_t>::max())
const {
95 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
96 auto const& h_vec = vec.HostVector();
97 this->Observe(h_vec, name, n);
101 size_t n = std::numeric_limits<std::size_t>::max())
const {
102 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
103 this->Observe(*vec, name, n);
107 template <
typename Parameter,
108 typename std::enable_if<
109 std::is_base_of<XGBoostParameter<Parameter>, Parameter>::value>::type* =
nullptr>
110 void Observe(
const Parameter &p, std::string name)
const {
111 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
113 Json obj {toJson(p)};
114 OBSERVER_PRINT <<
"Parameter: " << name <<
":\n" << obj << OBSERVER_ENDL;
117 void Observe(Args
const& args)
const {
118 if (XGBOOST_EXPECT(!kObserve,
true)) {
return; }
120 for (
auto kv : args) {
121 OBSERVER_PRINT << kv.first <<
": " << kv.second << OBSERVER_NEWLINE;
123 OBSERVER_PRINT << OBSERVER_ENDL;