Merge pull request #14827 from YashasSamaga:cuda4dnn-csl-low
[platform/upstream/opencv.git] / modules / dnn / src / cuda / limits.hpp
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4
5 #ifndef OPENCV_DNN_SRC_CUDA_LIMITS_HPP
6 #define OPENCV_DNN_SRC_CUDA_LIMITS_HPP
7
8 #include <cuda_runtime.h>
9 #include <cuda_fp16.h>
10
11 #include <cfloat>
12
13 namespace cv { namespace dnn { namespace cuda4dnn { namespace csl { namespace device {
14
15     template <class T>
16     struct numeric_limits;
17
18     template <>
19     struct numeric_limits<__half> {
20         __device__ static __half min() { return 0.0000610; }
21         __device__ static __half max() { return 65504.0; }
22         __device__ static __half lowest() { return -65504.0; }
23     };
24
25     template <>
26     struct numeric_limits<float> {
27         __device__ static float min() { return FLT_MIN; }
28         __device__ static float max() { return FLT_MAX; }
29         __device__ static float lowest() { return -FLT_MAX; }
30     };
31
32 }}}}} /* namespace cv::dnn::cuda4dnn::csl::device */
33
34 #endif /* OPENCV_DNN_SRC_CUDA_LIMITS_HPP */