"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "b2da19b88df1a8d014a9e1b46086e2def20ad4d8"
Unverified Commit 0012fc28 authored by Philip Hyunsu Cho's avatar Philip Hyunsu Cho Committed by GitHub
Browse files

Fix undefined behavior with NaN input in `CategoricalDecision()` (#4468)

* Fix undefined behavior with NaN input in CategoricalDecision()

* Always associate the right child with NaN inputs
parent 5b7a6f3e
......@@ -366,16 +366,14 @@ class Tree {
}
inline int CategoricalDecision(double fval, int node) const {
uint8_t missing_type = GetMissingType(decision_type_[node]);
int int_fval = static_cast<int>(fval);
if (int_fval < 0) {
return right_child_[node];;
} else if (std::isnan(fval)) {
// NaN is always in the right
if (missing_type == MissingType::NaN) {
int int_fval;
if (std::isnan(fval)) {
return right_child_[node];
} else {
int_fval = static_cast<int>(fval);
if (int_fval < 0) {
return right_child_[node];
}
int_fval = 0;
}
int cat_idx = static_cast<int>(threshold_[node]);
if (Common::FindInBitset(cat_threshold_.data() + cat_boundaries_[cat_idx],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment