Path: blob/master/modules/gapi/src/executor/gexecutor.hpp
16339 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3//4// Copyright (C) 2018 Intel Corporation567#ifndef OPENCV_GAPI_GEXECUTOR_HPP8#define OPENCV_GAPI_GEXECUTOR_HPP910#include <memory> // unique_ptr, shared_ptr1112#include <utility> // tuple, required by magazine13#include <unordered_map> // required by magazine1415#include <ade/graph.hpp>1617#include "backends/common/gbackend.hpp"1819namespace cv {20namespace gimpl {2122// Graph-level executor interface.23//24// This class specifies API for a "super-executor" which orchestrates25// the overall Island graph execution.26//27// Every Island (subgraph) execution is delegated to a particular28// backend and is done opaquely to the GExecutor.29//30// Inputs to a GExecutor instance are:31// - GIslandModel - a high-level graph model which may be seen as a32// "procedure" to execute.33// - GModel - a low-level graph of operations (from which a GIslandModel34// is projected)35// - GComputation runtime arguments - vectors of input/output objects36//37// Every GExecutor is responsible for38// a. Maintaining non-island (intermediate) data objects within graph39// b. Providing GIslandExecutables with input/output data according to40// their protocols41// c. Triggering execution of GIslandExecutables when task/data dependencies42// are met.43//44// By default G-API stores all data on host, and cross-Island45// exchange happens via host buffers (and CV data objects).46//47// Today's exchange data objects are:48// - cv::Mat - for image buffers49// - cv::Scalar - for single values (with up to four components inside)50// - cv::detail::VectorRef - an untyped wrapper over std::vector<T>51//5253class GExecutor54{55protected:56std::unique_ptr<ade::Graph> m_orig_graph;57std::shared_ptr<ade::Graph> m_island_graph;5859cv::gimpl::GModel::Graph m_gm; // FIXME: make const?60cv::gimpl::GIslandModel::Graph m_gim; // FIXME: make const?6162// FIXME: Naive executor details are here for now63// but then it should be moved to another place64struct OpDesc65{66std::vector<RcDesc> in_objects;67std::vector<RcDesc> out_objects;68std::shared_ptr<GIslandExecutable> isl_exec;69};70std::vector<OpDesc> m_ops;7172struct DataDesc73{74ade::NodeHandle slot_nh;75ade::NodeHandle data_nh;76};77std::vector<DataDesc> m_slots;7879Mag m_res;8081void initResource(const ade::NodeHandle &orig_nh); // FIXME: shouldn't it be RcDesc?8283public:84explicit GExecutor(std::unique_ptr<ade::Graph> &&g_model);85void run(cv::gimpl::GRuntimeArgs &&args);8687const GModel::Graph& model() const; // FIXME: make it ConstGraph?88};8990} // namespace gimpl91} // namespace cv9293#endif // OPENCV_GAPI_GEXECUTOR_HPP949596