| 140 | } |
| 141 | |
| 142 | void SerialTreeLearner2::ResetConfig(const Config* config) { |
| 143 | if (config_->num_leaves != config->num_leaves) { |
| 144 | config_ = config; |
| 145 | int max_cache_size = 0; |
| 146 | // Get the max size of pool |
| 147 | if (config->histogram_pool_size <= 0) { |
| 148 | max_cache_size = config_->num_leaves; |
| 149 | } else { |
| 150 | size_t total_histogram_size = 0; |
| 151 | for (int i = 0; i < train_data_->num_features(); ++i) { |
| 152 | total_histogram_size += sizeof(HistogramBinEntry) * train_data_->FeatureNumBin(i); |
| 153 | } |
| 154 | max_cache_size = static_cast<int>(config_->histogram_pool_size * 1024 * 1024 / total_histogram_size); |
| 155 | } |
| 156 | // at least need 2 leaves |
| 157 | max_cache_size = std::max(2, max_cache_size); |
| 158 | max_cache_size = std::min(max_cache_size, config_->num_leaves); |
| 159 | histogram_pool_.DynamicChangeSize(train_data_, config_, max_cache_size, config_->num_leaves); |
| 160 | |
| 161 | // push split information for all leaves |
| 162 | best_split_per_leaf_.resize(config_->num_leaves); |
| 163 | data_partition_->ResetLeaves(config_->num_leaves); |
| 164 | } else { |
| 165 | config_ = config; |
| 166 | } |
| 167 | histogram_pool_.ResetConfig(config_); |
| 168 | if (CostEfficientGradientBoosting2::IsEnable(config_)) { |
| 169 | cegb_.reset(new CostEfficientGradientBoosting2(this)); |
| 170 | cegb_->Init(); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | Tree* SerialTreeLearner2::Train(const score_t* gradients, const score_t *hessians, bool is_constant_hessian, const Json& forced_split_json) { |
| 175 | gradients_ = gradients; |
nothing calls this directly
no test coverage detected