Path: blob/master/modules/gapi/src/compiler/gmodelbuilder.hpp
16337 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_GMODEL_BUILDER_HPP8#define OPENCV_GAPI_GMODEL_BUILDER_HPP910#include <map>11#include <unordered_map>1213#include "opencv2/gapi/gproto.hpp"14#include "opencv2/gapi/gcall.hpp"1516#include "api/gapi_priv.hpp"17#include "api/gnode.hpp"18#include "compiler/gmodel.hpp"1920namespace cv { namespace gimpl {2122struct Unrolled23{24std::vector<cv::GNode> all_ops;25GOriginSet all_data;2627// NB.: Right now, as G-API operates with GMats only and that28// GMats have no type or dimensions (when a computation is built),29// track only origins (data links) with no any additional meta.30};3132// FIXME: GAPI_EXPORTS only because of tests!!!33GAPI_EXPORTS Unrolled unrollExpr(const GProtoArgs &ins, const GProtoArgs &outs);3435// This class generates an ADE graph with G-API specific metadata36// to represent user-specified computation in terms of graph model37//38// Resulting graph is built according to the following rules:39// - Every operation is a node40// - Every dynamic object (GMat) is a node41// - Edges between nodes represent producer/consumer relationships42// between operations and data objects.43// FIXME: GAPI_EXPORTS only because of tests!!!44class GAPI_EXPORTS GModelBuilder45{46GModel::Graph m_g;4748// Mappings of G-API user framework entities to ADE node handles49std::unordered_map<const cv::GNode::Priv*, ade::NodeHandle> m_graph_ops;50GOriginMap<ade::NodeHandle> m_graph_data;5152// Internal methods for mapping APIs into ADE during put()53ade::NodeHandle put_OpNode(const cv::GNode &node);54ade::NodeHandle put_DataNode(const cv::GOrigin &origin);5556public:57explicit GModelBuilder(ade::Graph &g);5859// TODO: replace GMat with a generic type60// TODO: Cover with tests! (as the rest of internal stuff)61// FIXME: Calling this method multiple times is currently UB62// TODO: add a semantic link between "ints" returned and in-model data IDs.63typedef std::tuple<std::vector<RcDesc>,64std::vector<RcDesc>,65std::vector<ade::NodeHandle>,66std::vector<ade::NodeHandle> > ProtoSlots;6768ProtoSlots put(const GProtoArgs &ins, const GProtoArgs &outs);6970protected:71ade::NodeHandle opNode(cv::GMat gmat);72};7374}}7576#endif // OPENCV_GAPI_GMODEL_BUILDER_HPP777879