Commit 1f517b8a authored by Ruslan Garnov's avatar Ruslan Garnov Committed by Alexander Alekhin

Merge pull request #13943 from rgarnov:export_headers_for_backend_development

G-API external backend development (#13943)

* Moved HostCtor and ConstVal from gapi_priv.hpp to objref.hpp

* Added gmodel_priv.hpp, added export of symbols from gmodel.hpp

* Added export of binInArg and bindOutArg

* Renamed gapi_priv.*pp -> gorigin.*pp

* Added a fixme on collecting exports inside one class
parent 7ad5d219
...@@ -31,7 +31,7 @@ file(GLOB gapi_ext_hdrs ...@@ -31,7 +31,7 @@ file(GLOB gapi_ext_hdrs
set(gapi_srcs set(gapi_srcs
# Front-end part # Front-end part
src/api/gapi_priv.cpp src/api/gorigin.cpp
src/api/gmat.cpp src/api/gmat.cpp
src/api/garray.cpp src/api/garray.cpp
src/api/gscalar.cpp src/api/gscalar.cpp
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencv2/gapi/garray.hpp" #include "opencv2/gapi/garray.hpp"
#include "api/gapi_priv.hpp" // GOrigin #include "api/gorigin.hpp"
// cv::detail::GArrayU public implementation /////////////////////////////////// // cv::detail::GArrayU public implementation ///////////////////////////////////
cv::detail::GArrayU::GArrayU() cv::detail::GArrayU::GArrayU()
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <opencv2/gapi/own/mat.hpp> //gapi::own::Mat #include <opencv2/gapi/own/mat.hpp> //gapi::own::Mat
#include "opencv2/gapi/gmat.hpp" #include "opencv2/gapi/gmat.hpp"
#include "api/gapi_priv.hpp" // GOrigin #include "api/gorigin.hpp"
// cv::GMat public implementation ////////////////////////////////////////////// // cv::GMat public implementation //////////////////////////////////////////////
cv::GMat::GMat() cv::GMat::GMat()
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include <ade/util/assert.hpp> #include <ade/util/assert.hpp>
#include "api/gapi_priv.hpp" #include "api/gorigin.hpp"
#include "api/gnode_priv.hpp" #include "api/gnode_priv.hpp"
cv::GOrigin::GOrigin(GShape s, cv::GOrigin::GOrigin(GShape s,
......
...@@ -5,42 +5,22 @@ ...@@ -5,42 +5,22 @@
// Copyright (C) 2018 Intel Corporation // Copyright (C) 2018 Intel Corporation
#ifndef OPENCV_GAPI_PRIV_HPP #ifndef OPENCV_GAPI_GORIGIN_HPP
#define OPENCV_GAPI_PRIV_HPP #define OPENCV_GAPI_GORIGIN_HPP
#include <set> // set #include <set> // set
#include <map> // map #include <map> // map
#include <limits>
#include "opencv2/gapi/util/variant.hpp" // variant #include "opencv2/gapi/util/variant.hpp" // variant
#include "opencv2/gapi/garray.hpp" // ConstructVec
#include "opencv2/gapi/gscalar.hpp"
#include "opencv2/gapi/gcommon.hpp" #include "opencv2/gapi/gcommon.hpp"
#include "opencv2/gapi/opencv_includes.hpp" #include "opencv2/gapi/opencv_includes.hpp"
#include "compiler/gobjref.hpp"
#include "api/gnode.hpp" #include "api/gnode.hpp"
namespace cv namespace cv
{ {
namespace gimpl
{
// Union type for various user-defined type constructors (GArray<T>, etc)
// FIXME: Replace construct-only API with a more generic one
// (probably with bits of introspection)
// Not required for non-user-defined types (GMat, GScalar, etc)
using HostCtor = util::variant
< util::monostate
, detail::ConstructVec
>;
using ConstVal = util::variant
< util::monostate
, cv::gapi::own::Scalar
>;
}
// TODO namespace gimpl? // TODO namespace gimpl?
struct GOrigin struct GOrigin
...@@ -74,4 +54,4 @@ template<typename T> using GOriginMap = std::map<GOrigin, T, detail::GOriginCmp> ...@@ -74,4 +54,4 @@ template<typename T> using GOriginMap = std::map<GOrigin, T, detail::GOriginCmp>
} // namespace cv } // namespace cv
#endif // OPENCV_GAPI_PRIV_HPP #endif // OPENCV_GAPI_GORIGIN_HPP
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/garg.hpp"
#include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/gproto.hpp"
#include "api/gapi_priv.hpp" #include "api/gorigin.hpp"
#include "api/gproto_priv.hpp" #include "api/gproto_priv.hpp"
// FIXME: it should be a visitor! // FIXME: it should be a visitor!
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/gproto.hpp"
#include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/garg.hpp"
#include "api/gapi_priv.hpp" #include "api/gorigin.hpp"
namespace cv { namespace cv {
namespace gimpl { namespace gimpl {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "opencv2/gapi/gscalar.hpp" #include "opencv2/gapi/gscalar.hpp"
#include "opencv2/gapi/own/convert.hpp" #include "opencv2/gapi/own/convert.hpp"
#include "api/gapi_priv.hpp" // GOrigin #include "api/gorigin.hpp"
// cv::GScalar public implementation /////////////////////////////////////////// // cv::GScalar public implementation ///////////////////////////////////////////
cv::GScalar::GScalar() cv::GScalar::GScalar()
......
...@@ -53,8 +53,8 @@ using Mag = magazine::Class<cv::gapi::own::Mat, cv::gapi::own::Scalar, cv::detai ...@@ -53,8 +53,8 @@ using Mag = magazine::Class<cv::gapi::own::Mat, cv::gapi::own::Scalar, cv::detai
namespace magazine namespace magazine
{ {
void bindInArg (Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat = false); void GAPI_EXPORTS bindInArg (Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat = false);
void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, bool is_umat = false); void GAPI_EXPORTS bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, bool is_umat = false);
void resetInternalData(Mag& mag, const Data &d); void resetInternalData(Mag& mag, const Data &d);
cv::GRunArg getArg (const Mag& mag, const RcDesc &ref); cv::GRunArg getArg (const Mag& mag, const RcDesc &ref);
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
#include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/gproto.hpp"
#include "opencv2/gapi/cpu/gcpukernel.hpp" #include "opencv2/gapi/cpu/gcpukernel.hpp"
#include "api/gorigin.hpp"
#include "api/gapi_priv.hpp"
#include "backends/common/gbackend.hpp" #include "backends/common/gbackend.hpp"
#include "compiler/gislandmodel.hpp" #include "compiler/gislandmodel.hpp"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <iomanip> // std::fixed, std::setprecision #include <iomanip> // std::fixed, std::setprecision
#include <set>
#include <unordered_set> #include <unordered_set>
#include <stack> #include <stack>
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
#include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/gproto.hpp"
#include "opencv2/gapi/ocl/goclkernel.hpp" #include "opencv2/gapi/ocl/goclkernel.hpp"
#include "api/gorigin.hpp"
#include "api/gapi_priv.hpp"
#include "backends/common/gbackend.hpp" #include "backends/common/gbackend.hpp"
#include "compiler/gislandmodel.hpp" #include "compiler/gislandmodel.hpp"
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "api/gnode_priv.hpp" // FIXME: why it is here? #include "api/gnode_priv.hpp" // FIXME: why it is here?
#include "api/gproto_priv.hpp" // FIXME: why it is here? #include "api/gproto_priv.hpp" // FIXME: why it is here?
#include "api/gcall_priv.hpp" // FIXME: why it is here? #include "api/gcall_priv.hpp" // FIXME: why it is here?
#include "api/gapi_priv.hpp" // FIXME: why it is here?
#include "api/gbackend_priv.hpp" // Backend basic API (newInstance, etc) #include "api/gbackend_priv.hpp" // Backend basic API (newInstance, etc)
#include "compiler/gmodel.hpp" #include "compiler/gmodel.hpp"
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "api/gnode_priv.hpp" #include "api/gnode_priv.hpp"
#include "compiler/gobjref.hpp" #include "compiler/gobjref.hpp"
#include "compiler/gmodel.hpp" #include "compiler/gmodel.hpp"
#include "api/gorigin.hpp"
#include "compiler/gmodel_priv.hpp"
namespace cv { namespace gimpl { namespace cv { namespace gimpl {
...@@ -34,9 +36,9 @@ ade::NodeHandle GModel::mkOpNode(GModel::Graph &g, const GKernel &k, const std:: ...@@ -34,9 +36,9 @@ ade::NodeHandle GModel::mkOpNode(GModel::Graph &g, const GKernel &k, const std::
ade::NodeHandle GModel::mkDataNode(GModel::Graph &g, const GOrigin& origin) ade::NodeHandle GModel::mkDataNode(GModel::Graph &g, const GOrigin& origin)
{ {
ade::NodeHandle op_h = g.createNode(); ade::NodeHandle data_h = g.createNode();
const auto id = g.metadata().get<DataObjectCounter>().GetNewId(origin.shape); const auto id = g.metadata().get<DataObjectCounter>().GetNewId(origin.shape);
g.metadata(op_h).set(NodeType{NodeType::DATA}); g.metadata(data_h).set(NodeType{NodeType::DATA});
GMetaArg meta; GMetaArg meta;
Data::Storage storage = Data::Storage::INTERNAL; // By default, all objects are marked INTERNAL Data::Storage storage = Data::Storage::INTERNAL; // By default, all objects are marked INTERNAL
...@@ -46,10 +48,24 @@ ade::NodeHandle GModel::mkDataNode(GModel::Graph &g, const GOrigin& origin) ...@@ -46,10 +48,24 @@ ade::NodeHandle GModel::mkDataNode(GModel::Graph &g, const GOrigin& origin)
auto value = value_of(origin); auto value = value_of(origin);
meta = descr_of(value); meta = descr_of(value);
storage = Data::Storage::CONST; storage = Data::Storage::CONST;
g.metadata(op_h).set(ConstValue{value}); g.metadata(data_h).set(ConstValue{value});
} }
g.metadata(op_h).set(Data{origin.shape, id, meta, origin.ctor, storage}); g.metadata(data_h).set(Data{origin.shape, id, meta, origin.ctor, storage});
return op_h; return data_h;
}
ade::NodeHandle GModel::mkDataNode(GModel::Graph &g, const GShape shape)
{
ade::NodeHandle data_h = g.createNode();
g.metadata(data_h).set(NodeType{NodeType::DATA});
const auto id = g.metadata().get<DataObjectCounter>().GetNewId(shape);
GMetaArg meta;
HostCtor ctor;
Data::Storage storage = Data::Storage::INTERNAL; // By default, all objects are marked INTERNAL
g.metadata(data_h).set(Data{shape, id, meta, ctor, storage});
return data_h;
} }
void GModel::linkIn(Graph &g, ade::NodeHandle opH, ade::NodeHandle objH, std::size_t in_port) void GModel::linkIn(Graph &g, ade::NodeHandle opH, ade::NodeHandle objH, std::size_t in_port)
...@@ -169,7 +185,7 @@ void GModel::log(Graph &g, ade::EdgeHandle eh, std::string &&msg, ade::NodeHandl ...@@ -169,7 +185,7 @@ void GModel::log(Graph &g, ade::EdgeHandle eh, std::string &&msg, ade::NodeHandl
} }
} }
ade::NodeHandle GModel::detail::dataNodeOf(const ConstGraph &g, const GOrigin &origin) ade::NodeHandle GModel::detail::dataNodeOf(const ConstLayoutGraph &g, const GOrigin &origin)
{ {
// FIXME: Does it still work with graph transformations, e.g. redirectWriter()?? // FIXME: Does it still work with graph transformations, e.g. redirectWriter()??
return g.metadata().get<Layout>().object_nodes.at(origin); return g.metadata().get<Layout>().object_nodes.at(origin);
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
#include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/garg.hpp"
#include "opencv2/gapi/gkernel.hpp" #include "opencv2/gapi/gkernel.hpp"
#include "api/gapi_priv.hpp" // GShape
#include "api/gproto_priv.hpp" // origin_of
#include "backends/common/gbackend.hpp"
#include "compiler/gobjref.hpp" #include "compiler/gobjref.hpp"
#include "compiler/gislandmodel.hpp" #include "compiler/gislandmodel.hpp"
...@@ -121,16 +118,6 @@ struct Journal ...@@ -121,16 +118,6 @@ struct Journal
std::vector<std::string> messages; std::vector<std::string> messages;
}; };
// The mapping between user-side GMat/GScalar/... objects
// and its appropriate nodes. Can be stored in graph optionally
// (NOT used by any compiler or backends, introspection purposes
// only)
struct Layout
{
static const char *name() { return "Layout"; }
GOriginMap<ade::NodeHandle> object_nodes;
};
// Unique data object counter (per-type) // Unique data object counter (per-type)
class DataObjectCounter class DataObjectCounter
{ {
...@@ -170,7 +157,6 @@ namespace GModel ...@@ -170,7 +157,6 @@ namespace GModel
, Journal , Journal
, ade::passes::TopologicalSortData , ade::passes::TopologicalSortData
, DataObjectCounter , DataObjectCounter
, Layout
, IslandModel , IslandModel
, ActiveBackends , ActiveBackends
>; >;
...@@ -189,59 +175,46 @@ namespace GModel ...@@ -189,59 +175,46 @@ namespace GModel
, Journal , Journal
, ade::passes::TopologicalSortData , ade::passes::TopologicalSortData
, DataObjectCounter , DataObjectCounter
, Layout
, IslandModel , IslandModel
, ActiveBackends , ActiveBackends
>; >;
// FIXME:
// Export a single class, not a bunch of functions inside a namespace
// User should initialize graph before using it // User should initialize graph before using it
// GAPI_EXPORTS for tests // GAPI_EXPORTS for tests
GAPI_EXPORTS void init (Graph& g); GAPI_EXPORTS void init (Graph& g);
ade::NodeHandle mkOpNode(Graph &g, const GKernel &k, const std::vector<GArg>& args, const std::string &island); GAPI_EXPORTS ade::NodeHandle mkOpNode(Graph &g, const GKernel &k, const std::vector<GArg>& args, const std::string &island);
// FIXME: change it to take GMeta instead of GShape? GAPI_EXPORTS ade::NodeHandle mkDataNode(Graph &g, const GShape shape);
ade::NodeHandle mkDataNode(Graph &g, const GOrigin& origin);
// Adds a string message to a node. Any node can be subject of log, messages then // Adds a string message to a node. Any node can be subject of log, messages then
// appear in the dumped .dot file.x // appear in the dumped .dot file.x
void log(Graph &g, ade::NodeHandle op, std::string &&message, ade::NodeHandle updater = ade::NodeHandle()); GAPI_EXPORTS void log(Graph &g, ade::NodeHandle op, std::string &&message, ade::NodeHandle updater = ade::NodeHandle());
void log(Graph &g, ade::EdgeHandle op, std::string &&message, ade::NodeHandle updater = ade::NodeHandle()); GAPI_EXPORTS void log(Graph &g, ade::EdgeHandle op, std::string &&message, ade::NodeHandle updater = ade::NodeHandle());
void linkIn (Graph &g, ade::NodeHandle op, ade::NodeHandle obj, std::size_t in_port);
void linkOut (Graph &g, ade::NodeHandle op, ade::NodeHandle obj, std::size_t out_port);
// FIXME: Align this GModel API properly, it is a mess now
namespace detail
{
// FIXME: GAPI_EXPORTS only because of tests!!!
GAPI_EXPORTS ade::NodeHandle dataNodeOf(const ConstGraph& g, const GOrigin &origin);
}
template<typename T> inline ade::NodeHandle dataNodeOf(const ConstGraph& g, T &&t)
{
return detail::dataNodeOf(g, cv::gimpl::proto::origin_of(GProtoArg{t}));
}
void linkIn (Graph &g, ade::NodeHandle op, ade::NodeHandle obj, std::size_t in_port); GAPI_EXPORTS void linkIn (Graph &g, ade::NodeHandle op, ade::NodeHandle obj, std::size_t in_port);
void linkOut (Graph &g, ade::NodeHandle op, ade::NodeHandle obj, std::size_t out_port); GAPI_EXPORTS void linkOut (Graph &g, ade::NodeHandle op, ade::NodeHandle obj, std::size_t out_port);
void redirectReaders(Graph &g, ade::NodeHandle from, ade::NodeHandle to); GAPI_EXPORTS void redirectReaders(Graph &g, ade::NodeHandle from, ade::NodeHandle to);
void redirectWriter (Graph &g, ade::NodeHandle from, ade::NodeHandle to); GAPI_EXPORTS void redirectWriter (Graph &g, ade::NodeHandle from, ade::NodeHandle to);
std::vector<ade::NodeHandle> orderedInputs (Graph &g, ade::NodeHandle nh); GAPI_EXPORTS std::vector<ade::NodeHandle> orderedInputs (Graph &g, ade::NodeHandle nh);
std::vector<ade::NodeHandle> orderedOutputs(Graph &g, ade::NodeHandle nh); GAPI_EXPORTS std::vector<ade::NodeHandle> orderedOutputs(Graph &g, ade::NodeHandle nh);
// Returns input meta array for given op node // Returns input meta array for given op node
// Array is sparse, as metadata for non-gapi input objects is empty // Array is sparse, as metadata for non-gapi input objects is empty
// TODO: // TODO:
// Cover with tests!! // Cover with tests!!
GMetaArgs collectInputMeta(GModel::ConstGraph cg, ade::NodeHandle node); GAPI_EXPORTS GMetaArgs collectInputMeta(GModel::ConstGraph cg, ade::NodeHandle node);
GMetaArgs collectOutputMeta(GModel::ConstGraph cg, ade::NodeHandle node); GAPI_EXPORTS GMetaArgs collectOutputMeta(GModel::ConstGraph cg, ade::NodeHandle node);
ade::EdgeHandle getInEdgeByPort(const GModel::ConstGraph& cg, const ade::NodeHandle& nh, std::size_t in_port); GAPI_EXPORTS ade::EdgeHandle getInEdgeByPort(const GModel::ConstGraph& cg, const ade::NodeHandle& nh, std::size_t in_port);
// Returns true if the given backend participates in the execution // Returns true if the given backend participates in the execution
bool isActive(const GModel::Graph &cg, const cv::gapi::GBackend &backend); GAPI_EXPORTS bool isActive(const GModel::Graph &cg, const cv::gapi::GBackend &backend);
} // namespace GModel } // namespace GModel
......
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2019 Intel Corporation
#ifndef OPENCV_GAPI_GMODEL_PRIV_HPP
#define OPENCV_GAPI_GMODEL_PRIV_HPP
#include <ade/graph.hpp>
#include "compiler/gmodel.hpp"
#include "api/gproto_priv.hpp" // origin_of
namespace cv { namespace gimpl {
// The mapping between user-side GMat/GScalar/... objects
// and its appropriate nodes. Can be stored in graph optionally
// (NOT used by any compiler or backends, introspection purposes
// only)
struct Layout
{
static const char *name() { return "Layout"; }
GOriginMap<ade::NodeHandle> object_nodes;
};
namespace GModel {
using LayoutGraph = ade::TypedGraph
< Layout
>;
using ConstLayoutGraph = ade::ConstTypedGraph
< Layout
>;
ade::NodeHandle mkDataNode(Graph &g, const GOrigin& origin);
namespace detail
{
// FIXME: GAPI_EXPORTS only because of tests!!!
GAPI_EXPORTS ade::NodeHandle dataNodeOf(const ConstLayoutGraph& g, const GOrigin &origin);
}
template<typename T> inline ade::NodeHandle dataNodeOf(const ConstLayoutGraph& g, T &&t)
{
return detail::dataNodeOf(g, cv::gimpl::proto::origin_of(GProtoArg{t}));
}
}}}
#endif // OPENCV_GAPI_GMODEL_PRIV_HPP
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
#include <ade/util/zip_range.hpp> // util::indexed #include <ade/util/zip_range.hpp> // util::indexed
#include "api/gapi_priv.hpp" // GOrigin #include "api/gorigin.hpp"
#include "api/gproto_priv.hpp" // descriptor_of and other GProtoArg-related #include "api/gproto_priv.hpp" // descriptor_of and other GProtoArg-related
#include "api/gcall_priv.hpp" #include "api/gcall_priv.hpp"
#include "api/gnode_priv.hpp" #include "api/gnode_priv.hpp"
#include "compiler/gmodelbuilder.hpp" #include "compiler/gmodelbuilder.hpp"
#include "compiler/gmodel_priv.hpp"
namespace { namespace {
...@@ -187,7 +188,7 @@ cv::gimpl::Unrolled cv::gimpl::unrollExpr(const GProtoArgs &ins, ...@@ -187,7 +188,7 @@ cv::gimpl::Unrolled cv::gimpl::unrollExpr(const GProtoArgs &ins,
cv::gimpl::GModelBuilder::GModelBuilder(ade::Graph &g) cv::gimpl::GModelBuilder::GModelBuilder(ade::Graph &g)
: m_g(g) : m_g(g), m_gm(g)
{ {
} }
...@@ -212,7 +213,7 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs) ...@@ -212,7 +213,7 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs)
if (proto::is_dynamic(in_arg)) if (proto::is_dynamic(in_arg))
{ {
ade::NodeHandle data_h = put_DataNode(proto::origin_of(in_arg)); ade::NodeHandle data_h = put_DataNode(proto::origin_of(in_arg));
cv::gimpl::GModel::linkIn(m_g, call_h, data_h, in_port); cv::gimpl::GModel::linkIn(m_gm, call_h, data_h, in_port);
} }
} }
} }
...@@ -228,7 +229,7 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs) ...@@ -228,7 +229,7 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs)
if (prod.shape() == cv::GNode::NodeShape::CALL) if (prod.shape() == cv::GNode::NodeShape::CALL)
{ {
ade::NodeHandle call_h = put_OpNode(prod); ade::NodeHandle call_h = put_OpNode(prod);
cv::gimpl::GModel::linkOut(m_g, call_h, data_h, origin.port); cv::gimpl::GModel::linkOut(m_gm, call_h, data_h, origin.port);
} }
} }
...@@ -236,16 +237,17 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs) ...@@ -236,16 +237,17 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs)
for (const auto &arg : ins) for (const auto &arg : ins)
{ {
ade::NodeHandle nh = put_DataNode(proto::origin_of(arg)); ade::NodeHandle nh = put_DataNode(proto::origin_of(arg));
m_g.metadata(nh).get<Data>().storage = Data::Storage::INPUT; m_gm.metadata(nh).get<Data>().storage = Data::Storage::INPUT;
} }
for (const auto &arg : outs) for (const auto &arg : outs)
{ {
ade::NodeHandle nh = put_DataNode(proto::origin_of(arg)); ade::NodeHandle nh = put_DataNode(proto::origin_of(arg));
m_g.metadata(nh).get<Data>().storage = Data::Storage::OUTPUT; m_gm.metadata(nh).get<Data>().storage = Data::Storage::OUTPUT;
} }
// And, finally, store data object layout in meta // And, finally, store data object layout in meta
m_g.metadata().set(Layout{m_graph_data}); GModel::LayoutGraph lg(m_g);
lg.metadata().set(Layout{m_graph_data});
// After graph is generated, specify which data objects are actually // After graph is generated, specify which data objects are actually
// computation entry/exit points. // computation entry/exit points.
...@@ -262,7 +264,7 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs) ...@@ -262,7 +264,7 @@ cv::gimpl::GModelBuilder::put(const GProtoArgs &ins, const GProtoArgs &outs)
for (const auto &arg : proto) for (const auto &arg : proto)
{ {
ade::NodeHandle nh = put_DataNode(proto::origin_of(arg)); ade::NodeHandle nh = put_DataNode(proto::origin_of(arg));
const auto &desc = m_g.metadata(nh).get<Data>(); const auto &desc = m_gm.metadata(nh).get<Data>();
//These extra empty {} are to please GCC (-Wmissing-field-initializers) //These extra empty {} are to please GCC (-Wmissing-field-initializers)
slots.first.push_back(RcDesc{desc.rc, desc.shape, {}}); slots.first.push_back(RcDesc{desc.rc, desc.shape, {}});
slots.second.push_back(nh); slots.second.push_back(nh);
...@@ -284,7 +286,7 @@ ade::NodeHandle cv::gimpl::GModelBuilder::put_OpNode(const cv::GNode &node) ...@@ -284,7 +286,7 @@ ade::NodeHandle cv::gimpl::GModelBuilder::put_OpNode(const cv::GNode &node)
{ {
GAPI_Assert(node.shape() == GNode::NodeShape::CALL); GAPI_Assert(node.shape() == GNode::NodeShape::CALL);
const auto &call_p = node.call().priv(); const auto &call_p = node.call().priv();
auto nh = cv::gimpl::GModel::mkOpNode(m_g, call_p.m_k, call_p.m_args, node_p.m_island); auto nh = cv::gimpl::GModel::mkOpNode(m_gm, call_p.m_k, call_p.m_args, node_p.m_island);
m_graph_ops[&node_p] = nh; m_graph_ops[&node_p] = nh;
return nh; return nh;
} }
...@@ -297,7 +299,7 @@ ade::NodeHandle cv::gimpl::GModelBuilder::put_DataNode(const GOrigin &origin) ...@@ -297,7 +299,7 @@ ade::NodeHandle cv::gimpl::GModelBuilder::put_DataNode(const GOrigin &origin)
const auto it = m_graph_data.find(origin); const auto it = m_graph_data.find(origin);
if (it == m_graph_data.end()) if (it == m_graph_data.end())
{ {
auto nh = cv::gimpl::GModel::mkDataNode(m_g, origin); auto nh = cv::gimpl::GModel::mkDataNode(m_gm, origin);
m_graph_data[origin] = nh; m_graph_data[origin] = nh;
return nh; return nh;
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/gproto.hpp"
#include "opencv2/gapi/gcall.hpp" #include "opencv2/gapi/gcall.hpp"
#include "api/gapi_priv.hpp" #include "api/gorigin.hpp"
#include "api/gnode.hpp" #include "api/gnode.hpp"
#include "compiler/gmodel.hpp" #include "compiler/gmodel.hpp"
...@@ -44,7 +44,8 @@ GAPI_EXPORTS Unrolled unrollExpr(const GProtoArgs &ins, const GProtoArgs &outs); ...@@ -44,7 +44,8 @@ GAPI_EXPORTS Unrolled unrollExpr(const GProtoArgs &ins, const GProtoArgs &outs);
// FIXME: GAPI_EXPORTS only because of tests!!! // FIXME: GAPI_EXPORTS only because of tests!!!
class GAPI_EXPORTS GModelBuilder class GAPI_EXPORTS GModelBuilder
{ {
GModel::Graph m_g; ade::Graph &m_g;
GModel::Graph m_gm;
// Mappings of G-API user framework entities to ADE node handles // Mappings of G-API user framework entities to ADE node handles
std::unordered_map<const cv::GNode::Priv*, ade::NodeHandle> m_graph_ops; std::unordered_map<const cv::GNode::Priv*, ade::NodeHandle> m_graph_ops;
......
...@@ -5,19 +5,31 @@ ...@@ -5,19 +5,31 @@
// Copyright (C) 2018 Intel Corporation // Copyright (C) 2018 Intel Corporation
#ifndef OPENCV_GAPI_GMATREF_HPP #ifndef OPENCV_GAPI_GOBJREF_HPP
#define OPENCV_GAPI_GMATREF_HPP #define OPENCV_GAPI_GOBJREF_HPP
#include "opencv2/gapi/util/variant.hpp" #include "opencv2/gapi/util/variant.hpp"
#include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/garg.hpp"
#include "api/gapi_priv.hpp" // GShape, HostCtor
namespace cv namespace cv
{ {
namespace gimpl namespace gimpl
{ {
// Union type for various user-defined type constructors (GArray<T>, etc)
// FIXME: Replace construct-only API with a more generic one
// (probably with bits of introspection)
// Not required for non-user-defined types (GMat, GScalar, etc)
using HostCtor = util::variant
< util::monostate
, detail::ConstructVec
>;
using ConstVal = util::variant
< util::monostate
, cv::gapi::own::Scalar
>;
struct RcDesc struct RcDesc
{ {
int id; // id is unique but local to shape int id; // id is unique but local to shape
...@@ -47,4 +59,4 @@ namespace detail ...@@ -47,4 +59,4 @@ namespace detail
} // cv } // cv
#endif // OPENCV_GAPI_GMATREF_HPP #endif // OPENCV_GAPI_GOBJREF_HPP
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <iostream> // cout #include <iostream> // cout
#include <sstream> // stringstream #include <sstream> // stringstream
#include <fstream> // ofstream #include <fstream> // ofstream
#include <map>
#include <ade/passes/check_cycles.hpp> #include <ade/passes/check_cycles.hpp>
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "backends/common/gbackend.hpp" #include "backends/common/gbackend.hpp"
#include "compiler/gmodelbuilder.hpp" #include "compiler/gmodelbuilder.hpp"
#include "logger.hpp" // GAPI_LOG #include "logger.hpp" // GAPI_LOG
#include "api/gproto_priv.hpp" // is_dynamic, rewrap
namespace namespace
{ {
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include "../gapi_mock_kernels.hpp" #include "../gapi_mock_kernels.hpp"
#include "compiler/gmodel.hpp"
#include "compiler/gislandmodel.hpp" #include "compiler/gislandmodel.hpp"
#include "compiler/gcompiler.hpp" #include "compiler/gcompiler.hpp"
#include "compiler/gmodel_priv.hpp"
namespace opencv_test namespace opencv_test
{ {
...@@ -44,10 +44,11 @@ TEST(IslandFusion, TwoOps_OneIsland) ...@@ -44,10 +44,11 @@ TEST(IslandFusion, TwoOps_OneIsland)
// Inspect the graph and verify the islands configuration // Inspect the graph and verify the islands configuration
cv::gimpl::GModel::ConstGraph gm(*graph); cv::gimpl::GModel::ConstGraph gm(*graph);
cv::gimpl::GModel::ConstLayoutGraph glm(*graph);
auto in_nh = cv::gimpl::GModel::dataNodeOf(gm, in); auto in_nh = cv::gimpl::GModel::dataNodeOf(glm, in);
auto tmp_nh = cv::gimpl::GModel::dataNodeOf(gm, tmp0); auto tmp_nh = cv::gimpl::GModel::dataNodeOf(glm, tmp0);
auto out_nh = cv::gimpl::GModel::dataNodeOf(gm, out); auto out_nh = cv::gimpl::GModel::dataNodeOf(glm, out);
// in/out mats shouldn't be assigned to any Island // in/out mats shouldn't be assigned to any Island
EXPECT_FALSE(gm.metadata(in_nh ).contains<cv::gimpl::Island>()); EXPECT_FALSE(gm.metadata(in_nh ).contains<cv::gimpl::Island>());
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "compiler/gmodel.hpp" #include "compiler/gmodel.hpp"
#include "compiler/gcompiled_priv.hpp" #include "compiler/gcompiled_priv.hpp"
#include "compiler/gmodel_priv.hpp"
namespace opencv_test namespace opencv_test
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment