Skip to content

Commit

Permalink
Remove pruner.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Mar 16, 2022
1 parent e656853 commit 173ec46
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/tree/updater_approx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class GloablApproxBuilder {
common::ParallelFor2d(space, ctx_->Threads(), [&](size_t nidx, common::Range1d r) {
if (tree[nidx].IsLeaf()) {
const auto rowset = part[nidx];
auto const &stats = snode.at(nidx);
auto const &stats = snode[nidx];
auto leaf_value =
evaluator.CalcWeight(nidx, param_, GradStats{stats.stats}) * param_.learning_rate;
for (const size_t *it = rowset.begin + r.begin(); it < rowset.begin + r.end(); ++it) {
Expand Down
16 changes: 4 additions & 12 deletions src/tree/updater_quantile_hist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,15 @@ DMLC_REGISTRY_FILE_TAG(updater_quantile_hist);

DMLC_REGISTER_PARAMETER(CPUHistMakerTrainParam);

void QuantileHistMaker::Configure(const Args& args) {
// initialize pruner
if (!pruner_) {
pruner_.reset(TreeUpdater::Create("prune", ctx_, task_));
}
pruner_->Configure(args);
void QuantileHistMaker::Configure(const Args &args) {
param_.UpdateAllowUnknown(args);
hist_maker_param_.UpdateAllowUnknown(args);
}

template <typename GradientSumT>
void QuantileHistMaker::SetBuilder(const size_t n_trees,
std::unique_ptr<Builder<GradientSumT>>* builder, DMatrix* dmat) {
builder->reset(
new Builder<GradientSumT>(n_trees, param_, std::move(pruner_), dmat, task_, ctx_));
std::unique_ptr<Builder<GradientSumT>> *builder, DMatrix *dmat) {
builder->reset(new Builder<GradientSumT>(n_trees, param_, dmat, task_, ctx_));
}

template<typename GradientSumT>
Expand Down Expand Up @@ -264,8 +258,6 @@ void QuantileHistMaker::Builder<GradientSumT>::Update(const GHistIndexMatrix &gm

ExpandTree(p_fmat, p_tree, *gpair_ptr);

pruner_->Update(gpair, p_fmat, std::vector<RegTree*>{p_tree});

builder_monitor_.Stop("Update");
}

Expand Down Expand Up @@ -294,7 +286,7 @@ bool QuantileHistMaker::Builder<GradientSumT>::UpdatePredictionCache(
common::ParallelFor2d(space, ctx_->Threads(), [&](size_t nidx, common::Range1d r) {
if (!tree[nidx].IsDeleted() && tree[nidx].IsLeaf()) {
const auto rowset = part[nidx];
auto const &stats = snode.at(nidx);
auto const &stats = snode[nidx];
auto leaf_value =
evaluator.CalcWeight(nidx, param_, GradStats{stats.stats}) * param_.learning_rate;
for (const size_t *it = rowset.begin + r.begin(); it < rowset.begin + r.end(); ++it) {
Expand Down
9 changes: 2 additions & 7 deletions src/tree/updater_quantile_hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,10 @@ class QuantileHistMaker: public TreeUpdater {
public:
using GradientPairT = xgboost::detail::GradientPairInternal<GradientSumT>;
// constructor
explicit Builder(const size_t n_trees, const TrainParam& param,
std::unique_ptr<TreeUpdater> pruner, DMatrix const* fmat, ObjInfo task,
GenericParameter const* ctx)
explicit Builder(const size_t n_trees, const TrainParam& param, DMatrix const* fmat,
ObjInfo task, GenericParameter const* ctx)
: n_trees_(n_trees),
param_(param),
pruner_(std::move(pruner)),
p_last_fmat_(fmat),
histogram_builder_{new HistogramBuilder<GradientSumT, CPUExpandEntry>},
task_{task},
Expand Down Expand Up @@ -342,7 +340,6 @@ class QuantileHistMaker: public TreeUpdater {

std::vector<GradientPair> gpair_local_;

std::unique_ptr<TreeUpdater> pruner_;
std::unique_ptr<HistEvaluator<GradientSumT, CPUExpandEntry>> evaluator_;
// Right now there's only 1 partitioner in this vector, when external memory is fully
// supported we will have number of partitioners equal to number of pages.
Expand Down Expand Up @@ -377,8 +374,6 @@ class QuantileHistMaker: public TreeUpdater {
protected:
std::unique_ptr<Builder<float>> float_builder_;
std::unique_ptr<Builder<double>> double_builder_;

std::unique_ptr<TreeUpdater> pruner_;
ObjInfo task_;
};
} // namespace tree
Expand Down

0 comments on commit 173ec46

Please sign in to comment.