Limit tree depth for GPU hist. (#6045)

This commit is contained in:
Jiaming Yuan
2020-08-22 19:34:52 +08:00
committed by GitHub
parent b9ebbffc57
commit a144daf034
4 changed files with 19 additions and 3 deletions

View File

@@ -239,6 +239,10 @@ struct TrainParam : public XGBoostParameter<TrainParam> {
if (this->max_leaves > 0) {
n_nodes = this->max_leaves * 2 - 1;
} else {
// bst_node_t will overflow.
CHECK_LE(this->max_depth, 31)
<< "max_depth can not be greater than 31 as that might generate 2 ** "
"32 - 1 nodes.";
n_nodes = (1 << (this->max_depth + 1)) - 1;
}
CHECK_NE(n_nodes, 0);