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.
5 // Copyright (C) 2018-2019 Intel Corporation
8 #ifndef OPENCV_GAPI_GEXECUTOR_HPP
9 #define OPENCV_GAPI_GEXECUTOR_HPP
11 #include <memory> // unique_ptr, shared_ptr
13 #include <utility> // tuple, required by magazine
14 #include <unordered_map> // required by magazine
16 #include <ade/graph.hpp>
18 #include "backends/common/gbackend.hpp"
23 // Graph-level executor interface.
25 // This class specifies API for a "super-executor" which orchestrates
26 // the overall Island graph execution.
28 // Every Island (subgraph) execution is delegated to a particular
29 // backend and is done opaquely to the GExecutor.
31 // Inputs to a GExecutor instance are:
32 // - GIslandModel - a high-level graph model which may be seen as a
33 // "procedure" to execute.
34 // - GModel - a low-level graph of operations (from which a GIslandModel
36 // - GComputation runtime arguments - vectors of input/output objects
38 // Every GExecutor is responsible for
39 // a. Maintaining non-island (intermediate) data objects within graph
40 // b. Providing GIslandExecutables with input/output data according to
42 // c. Triggering execution of GIslandExecutables when task/data dependencies
45 // By default G-API stores all data on host, and cross-Island
46 // exchange happens via host buffers (and CV data objects).
48 // Today's exchange data objects are:
49 // - cv::Mat - for image buffers
50 // - cv::Scalar - for single values (with up to four components inside)
51 // - cv::detail::VectorRef - an untyped wrapper over std::vector<T>
57 std::unique_ptr<ade::Graph> m_orig_graph;
58 std::shared_ptr<ade::Graph> m_island_graph;
60 cv::gimpl::GModel::Graph m_gm; // FIXME: make const?
61 cv::gimpl::GIslandModel::Graph m_gim; // FIXME: make const?
63 // FIXME: Naive executor details are here for now
64 // but then it should be moved to another place
67 std::vector<RcDesc> in_objects;
68 std::vector<RcDesc> out_objects;
69 std::shared_ptr<GIslandExecutable> isl_exec;
71 std::vector<OpDesc> m_ops;
75 ade::NodeHandle slot_nh;
76 ade::NodeHandle data_nh;
78 std::vector<DataDesc> m_slots;
82 void initResource(const ade::NodeHandle &orig_nh); // FIXME: shouldn't it be RcDesc?
85 explicit GExecutor(std::unique_ptr<ade::Graph> &&g_model);
86 void run(cv::gimpl::GRuntimeArgs &&args);
88 bool canReshape() const;
89 void reshape(const GMetaArgs& inMetas, const GCompileArgs& args);
91 const GModel::Graph& model() const; // FIXME: make it ConstGraph?
97 #endif // OPENCV_GAPI_GEXECUTOR_HPP