ptrendx commented on a change in pull request #20339:
URL: https://github.com/apache/incubator-mxnet/pull/20339#discussion_r651259834



##########
File path: src/common/cuda/rtc/forward_functions-inl.h
##########
@@ -697,9 +697,11 @@ __device__ inline DType log_sigmoid(const DType val) {
 template <typename DType>
 __device__ inline DType mish(const DType val) {
   if (type_util::has_double_or_integral<DType>::value) {
-    return val * ::tanh(::log(1 + ::exp(val)));
+    const auto softrelu = (val > 20) ? val : ::log(1 + ::exp(val));
+    return val * ::tanh(softrelu);
   } else {
-    return val * ::tanhf(logf(1 + expf(val)));
+    const auto softrelu = (val > 20) ? val : logf(1 + expf(val));
+    return val * ::tanhf(softrelu);

Review comment:
       That is because this function is defined "too early" in this file - e.g. 
softrelu function is defined just after your function (tanh is defined later in 
line 780). You need to move your function after those for the compiler to see 
them.
   
   All of the backward functions are defined after the forward functions so 
that should just work if you use the `op::softrelu` and `op::tanh` there.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to