Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / test / gapi_mock_kernels.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 // Copyright (C) 2018-2019 Intel Corporation
6
7
8 #include "opencv2/gapi/cpu/gcpukernel.hpp"
9
10 #include "api/gbackend_priv.hpp" // directly instantiate GBackend::Priv
11
12 namespace opencv_test
13 {
14 namespace {
15     // FIXME: Currently every Kernel implementation in this test file has
16     // its own backend() method and it is incorrect! API classes should
17     // provide it out of the box.
18
19 namespace I
20 {
21     G_TYPED_KERNEL(Foo, <cv::GMat(cv::GMat)>, "test.kernels.foo")
22     {
23         static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
24     };
25
26     G_TYPED_KERNEL(Bar, <cv::GMat(cv::GMat,cv::GMat)>, "test.kernels.bar")
27     {
28         static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &) { return in; }
29     };
30
31     G_TYPED_KERNEL(Baz, <cv::GScalar(cv::GMat)>, "test.kernels.baz")
32     {
33         static cv::GScalarDesc outMeta(const cv::GMatDesc &) { return cv::empty_scalar_desc(); }
34     };
35
36     G_TYPED_KERNEL(Qux, <cv::GMat(cv::GMat, cv::GScalar)>, "test.kernels.qux")
37     {
38         static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GScalarDesc &) { return in; }
39     };
40
41     G_TYPED_KERNEL(Quux, <cv::GMat(cv::GScalar, cv::GMat)>, "test.kernels.quux")
42     {
43         static cv::GMatDesc outMeta(const cv::GScalarDesc &, const cv::GMatDesc& in) { return in; }
44     };
45 }
46
47 // Kernel implementations for imaginary Jupiter device
48 namespace Jupiter
49 {
50     namespace detail
51     {
52         static cv::gapi::GBackend backend(std::make_shared<cv::gapi::GBackend::Priv>());
53     }
54
55     inline cv::gapi::GBackend backend() { return detail::backend; }
56
57     GAPI_OCV_KERNEL(Foo, I::Foo)
58     {
59         static void run(const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
60         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
61     };
62     GAPI_OCV_KERNEL(Bar, I::Bar)
63     {
64         static void run(const cv::Mat &, const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
65         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
66     };
67     GAPI_OCV_KERNEL(Baz, I::Baz)
68     {
69         static void run(const cv::Mat &, cv::Scalar &) { /*Do nothing*/ }
70         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
71     };
72     GAPI_OCV_KERNEL(Qux, I::Qux)
73     {
74         static void run(const cv::Mat &, const cv::Scalar&, cv::Mat &) { /*Do nothing*/ }
75         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
76     };
77
78     GAPI_OCV_KERNEL(Quux, I::Quux)
79     {
80         static void run(const cv::Scalar&, const cv::Mat&, cv::Mat &) { /*Do nothing*/ }
81         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
82     };
83 } // namespace Jupiter
84
85 // Kernel implementations for imaginary Saturn device
86 namespace Saturn
87 {
88     namespace detail
89     {
90         static cv::gapi::GBackend backend(std::make_shared<cv::gapi::GBackend::Priv>());
91     }
92
93     inline cv::gapi::GBackend backend() { return detail::backend; }
94
95     GAPI_OCV_KERNEL(Foo, I::Foo)
96     {
97         static void run(const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
98         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
99     };
100     GAPI_OCV_KERNEL(Bar, I::Bar)
101     {
102         static void run(const cv::Mat &, const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
103         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
104     };
105     GAPI_OCV_KERNEL(Baz, I::Baz)
106     {
107         static void run(const cv::Mat &, cv::Scalar &) { /*Do nothing*/ }
108         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
109     };
110     GAPI_OCV_KERNEL(Qux, I::Qux)
111     {
112         static void run(const cv::Mat &, const cv::Scalar&, cv::Mat &) { /*Do nothing*/ }
113         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
114     };
115
116     GAPI_OCV_KERNEL(Quux, I::Quux)
117     {
118         static void run(const cv::Scalar&, const cv::Mat&, cv::Mat &) { /*Do nothing*/ }
119         static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
120     };
121 } // namespace Saturn
122 } // anonymous namespace
123 } // namespace opencv_test