Merge pull request #14827 from YashasSamaga:cuda4dnn-csl-low
[platform/upstream/opencv.git] / modules / dnn / src / cuda4dnn / csl / error.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_CUDA4DNN_CSL_ERROR_HPP
6 #define OPENCV_DNN_SRC_CUDA4DNN_CSL_ERROR_HPP
7
8 #include <opencv2/core.hpp>
9
10 #include <cuda_runtime_api.h>
11
12 #define CUDA4DNN_CHECK_CUDA(call) \
13     ::cv::dnn::cuda4dnn::csl::detail::check((call), CV_Func, __FILE__, __LINE__)
14
15 namespace cv { namespace dnn { namespace cuda4dnn { namespace csl {
16     /** @brief exception class for errors thrown by the CUDA APIs */
17     class CUDAException : public cv::Exception {
18     public:
19         using cv::Exception::Exception;
20     };
21
22     namespace detail {
23         inline void check(cudaError_t err, const char* func, const char* file, int line) {
24             if (err != cudaSuccess)
25                 throw CUDAException(Error::GpuApiCallError, cudaGetErrorString(err), func, file, line);
26         }
27     }
28 }}}} /* namespace cv::dnn::cuda4dnn::csl */
29
30 #endif /* OPENCV_DNN_SRC_CUDA4DNN_CSL_ERROR_HPP */