Skip to content

Commit

Permalink
Using static_cast to make more robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkuyym committed Oct 27, 2017
1 parent 5939a17 commit ac5f421
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions paddle/operators/huber_loss_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ struct HuberLossForward {
HOSTDEVICE T operator()(const T& val) const {
T abs_val = std::abs(val);
if (abs_val <= delta) {
return 0.5 * val * val;
return static_cast<T>(0.5) * val * val;
} else {
return delta * (abs_val - 0.5 * delta);
return delta * (abs_val - static_cast<T>(0.5) * delta);
}
}

Expand Down

0 comments on commit ac5f421

Please sign in to comment.