提交 ac5f4218 编写于 作者: Y yangyaming

Using static_cast to make more robust.

上级 5939a17c
...@@ -32,9 +32,9 @@ struct HuberLossForward { ...@@ -32,9 +32,9 @@ struct HuberLossForward {
HOSTDEVICE T operator()(const T& val) const { HOSTDEVICE T operator()(const T& val) const {
T abs_val = std::abs(val); T abs_val = std::abs(val);
if (abs_val <= delta) { if (abs_val <= delta) {
return 0.5 * val * val; return static_cast<T>(0.5) * val * val;
} else { } else {
return delta * (abs_val - 0.5 * delta); return delta * (abs_val - static_cast<T>(0.5) * delta);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册