Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / src / backends / gpu / ggpubackend.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 #ifndef OPENCV_GAPI_GGPUBACKEND_HPP
9 #define OPENCV_GAPI_GGPUBACKEND_HPP
10
11 #include <map>                // map
12 #include <unordered_map>      // unordered_map
13 #include <tuple>              // tuple
14 #include <ade/util/algorithm.hpp> // type_list_index
15
16 #include "opencv2/gapi/garg.hpp"
17 #include "opencv2/gapi/gproto.hpp"
18 #include "opencv2/gapi/gpu/ggpukernel.hpp"
19
20
21 #include "api/gapi_priv.hpp"
22 #include "backends/common/gbackend.hpp"
23 #include "compiler/gislandmodel.hpp"
24
25 namespace cv { namespace gimpl {
26
27 struct Unit
28 {
29     static const char *name() { return "GPUKernel"; }
30     GGPUKernel k;
31 };
32
33 class GGPUExecutable final: public GIslandExecutable
34 {
35     const ade::Graph &m_g;
36     GModel::ConstGraph m_gm;
37
38     struct OperationInfo
39     {
40         ade::NodeHandle nh;
41         GMetaArgs expected_out_metas;
42     };
43
44     // Execution script, currently absolutely naive
45     std::vector<OperationInfo> m_script;
46     // List of all resources in graph (both internal and external)
47     std::vector<ade::NodeHandle> m_dataNodes;
48
49     // Actual data of all resources in graph (both internal and external)
50     Mag m_res;
51     GArg packArg(const GArg &arg);
52
53 public:
54     GGPUExecutable(const ade::Graph                   &graph,
55                    const std::vector<ade::NodeHandle> &nodes);
56
57     virtual inline bool canReshape() const override { return false; }
58     virtual inline void reshape(ade::Graph&, const GCompileArgs&) override
59     {
60         // FIXME: GPU plugin is in fact reshapeable (as it was initially,
61         // even before outMeta() has been introduced), so this limitation
62         // should be dropped.
63         util::throw_error(std::logic_error("GGPUExecutable::reshape() should never be called"));
64     }
65
66     virtual void run(std::vector<InObj>  &&input_objs,
67                      std::vector<OutObj> &&output_objs) override;
68 };
69
70 }}
71
72 #endif // OPENCV_GAPI_GGPUBACKEND_HPP