From 6573b9ace0d3eb3c9792c0d23d0ddb4a9017a840 Mon Sep 17 00:00:00 2001 From: YashasSamaga Date: Mon, 22 Jun 2020 19:09:36 +0530 Subject: [PATCH] use fp32 mish for fp16 mish --- modules/dnn/src/cuda/functors.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/dnn/src/cuda/functors.hpp b/modules/dnn/src/cuda/functors.hpp index b0c59d6684..5206522abf 100644 --- a/modules/dnn/src/cuda/functors.hpp +++ b/modules/dnn/src/cuda/functors.hpp @@ -57,11 +57,19 @@ struct mish_functor { auto n = e * e + 2 * e; if (value <= -0.6f) return value * fast_divide(n, n + 2); - return value - 2 * fast_divide(value, n + 2); } }; +#if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 530) +template <> +struct mish_functor<__half> { + __device__ __half operator()(__half value) { + return mish_functor()(value); + } +}; +#endif + template struct sigmoid_functor { __device__ T operator()(T value) {