Skip to content

Commit 2ac5944

Browse files
authored
[backport] Workaround compiler issue on Windows. (dmlc#11916)
1 parent 3423869 commit 2ac5944

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tree/param.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ XGBOOST_DEVICE inline T CalcGainGivenWeight(const TrainingParams &p, T sum_grad,
242242

243243
// calculate weight given the statistics
244244
template <typename TrainingParams, typename T>
245-
XGBOOST_DEVICE inline T CalcWeight(const TrainingParams &p, T sum_grad,
246-
T sum_hess) {
245+
XGBOOST_DEVICE std::enable_if_t<std::is_floating_point_v<T>, T> CalcWeight(TrainingParams const &p,
246+
T sum_grad, T sum_hess) {
247247
if (sum_hess < p.min_child_weight || sum_hess <= 0.0) {
248248
return 0.0;
249249
}
250250
T dw = -ThresholdL1(sum_grad, p.reg_alpha) / (sum_hess + p.reg_lambda);
251-
if (p.max_delta_step != 0.0f && std::abs(dw) > p.max_delta_step) {
252-
dw = std::copysign(p.max_delta_step, dw);
251+
if (p.max_delta_step != 0.0f && ::fabs(dw) > p.max_delta_step) {
252+
dw = ::copysign(p.max_delta_step, dw);
253253
}
254254
return dw;
255255
}

0 commit comments

Comments
 (0)