diff --git a/paddle/operators/huber_loss_op.h b/paddle/operators/huber_loss_op.h index d8a2da52f508c..4e7bc5543226e 100644 --- a/paddle/operators/huber_loss_op.h +++ b/paddle/operators/huber_loss_op.h @@ -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(0.5) * val * val; } else { - return delta * (abs_val - 0.5 * delta); + return delta * (abs_val - static_cast(0.5) * delta); } }