Avoid regenerating the gradient index for approx. (#7591)

This commit is contained in:
Jiaming Yuan
2022-01-26 21:41:30 +08:00
committed by GitHub
parent 5d7818e75d
commit e060519d4f
7 changed files with 40 additions and 18 deletions

View File

@@ -108,5 +108,16 @@ class GHistIndexMatrix {
std::vector<size_t> hit_count_tloc_;
bool isDense_;
};
/**
* \brief Should we regenerate the gradient index?
*
* \param old Parameter stored in DMatrix.
* \param p New parameter passed in by caller.
*/
inline bool RegenGHist(BatchParam old, BatchParam p) {
// parameter is renewed or caller requests a regen
return p.regen || (old.gpu_id != p.gpu_id || old.max_bin != p.max_bin);
}
} // namespace xgboost
#endif // XGBOOST_DATA_GRADIENT_INDEX_H_