xgboost/plugin/sycl/tree/hist_row_adder.h
Dmitry Razdoburdin f588252481
[sycl] add loss guided hist building (#10251)
Co-authored-by: Dmitry Razdoburdin <>
2024-05-10 22:35:13 +08:00

47 lines
1.2 KiB
C++

/*!
* Copyright 2017-2024 by Contributors
* \file hist_row_adder.h
*/
#ifndef PLUGIN_SYCL_TREE_HIST_ROW_ADDER_H_
#define PLUGIN_SYCL_TREE_HIST_ROW_ADDER_H_
#include <vector>
#include <algorithm>
namespace xgboost {
namespace sycl {
namespace tree {
template <typename GradientSumT>
class HistRowsAdder {
public:
virtual void AddHistRows(HistUpdater<GradientSumT>* builder,
std::vector<int>* sync_ids, RegTree *p_tree) = 0;
virtual ~HistRowsAdder() = default;
};
template <typename GradientSumT>
class BatchHistRowsAdder: public HistRowsAdder<GradientSumT> {
public:
void AddHistRows(HistUpdater<GradientSumT>* builder,
std::vector<int>* sync_ids, RegTree *p_tree) override {
builder->builder_monitor_.Start("AddHistRows");
for (auto const& entry : builder->nodes_for_explicit_hist_build_) {
int nid = entry.nid;
auto event = builder->hist_.AddHistRow(nid);
}
for (auto const& node : builder->nodes_for_subtraction_trick_) {
auto event = builder->hist_.AddHistRow(node.nid);
}
builder->builder_monitor_.Stop("AddHistRows");
}
};
} // namespace tree
} // namespace sycl
} // namespace xgboost
#endif // PLUGIN_SYCL_TREE_HIST_ROW_ADDER_H_