1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #18127 from smirnov-alexey:as/gapi_serialization

[G-API]: Add GOpaque and GArray serialization support

* Add GOpaque and GArray serialization support

* Address review comments

* Remove holds() method

* Address review comments

* Remove comments

* Align streaming with kind changes

* Fix kind in kernel

* Address review comments
This commit is contained in:
Alexey Smirnov
2020-09-07 20:10:03 +03:00
committed by GitHub
parent 620629593b
commit a3e8c6e866
26 changed files with 648 additions and 228 deletions
+4 -3
View File
@@ -2,7 +2,7 @@
// 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) 2018 Intel Corporation
// Copyright (C) 2018-2020 Intel Corporation
#include "precomp.hpp"
@@ -54,7 +54,7 @@ ade::NodeHandle GModel::mkDataNode(GModel::Graph &g, const GOrigin& origin)
// associated host-type constructor (e.g. when the array is
// somewhere in the middle of the graph).
auto ctor_copy = origin.ctor;
g.metadata(data_h).set(Data{origin.shape, id, meta, ctor_copy, storage});
g.metadata(data_h).set(Data{origin.shape, id, meta, ctor_copy, origin.kind, storage});
return data_h;
}
@@ -67,8 +67,9 @@ ade::NodeHandle GModel::mkDataNode(GModel::Graph &g, const GShape shape)
GMetaArg meta;
HostCtor ctor;
Data::Storage storage = Data::Storage::INTERNAL; // By default, all objects are marked INTERNAL
cv::detail::OpaqueKind kind = cv::detail::OpaqueKind::CV_UNKNOWN;
g.metadata(data_h).set(Data{shape, id, meta, ctor, storage});
g.metadata(data_h).set(Data{shape, id, meta, ctor, kind, storage});
return data_h;
}
+3 -1
View File
@@ -2,7 +2,7 @@
// 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) 2018 Intel Corporation
// Copyright (C) 2018-2020 Intel Corporation
#ifndef OPENCV_GAPI_GMODEL_HPP
@@ -26,6 +26,7 @@
#include <opencv2/gapi/garg.hpp>
#include <opencv2/gapi/gkernel.hpp>
#include <opencv2/gapi/gcommon.hpp>
#include "compiler/gobjref.hpp"
#include "compiler/gislandmodel.hpp"
@@ -71,6 +72,7 @@ struct Data
int rc;
GMetaArg meta;
HostCtor ctor; // T-specific helper to deal with unknown types in our code
cv::detail::OpaqueKind kind; // FIXME: is needed to store GArray/GOpaque type
// FIXME: Why rc+shape+meta is not represented as RcDesc here?
enum class Storage: int
+2 -2
View File
@@ -2,7 +2,7 @@
// 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) 2018 Intel Corporation
// Copyright (C) 2018-2020 Intel Corporation
////////////////////////////////////////////////////////////////////////////////
@@ -139,7 +139,7 @@ cv::gimpl::Unrolled cv::gimpl::unrollExpr(const GProtoArgs &ins,
std::size_t port = ade::util::index(it);
GShape shape = ade::util::value(it);
GOrigin org { shape, node, port};
GOrigin org { shape, node, port, {}, origin.kind };
origins.insert(org);
}
-1
View File
@@ -55,7 +55,6 @@ namespace detail
template<> struct GTypeTraits<cv::gimpl::RcDesc>
{
static constexpr const ArgKind kind = ArgKind::GOBJREF;
static constexpr const ArgSpec spec = ArgSpec::OPAQUE_SPEC;
};
}
+16 -13
View File
@@ -2,7 +2,7 @@
// 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) 2018 Intel Corporation
// Copyright (C) 2018-2020 Intel Corporation
#include "precomp.hpp"
@@ -94,18 +94,21 @@ void cv::gimpl::passes::inferMeta(ade::passes::PassContext &ctx, bool meta_is_in
GAPI_Assert(gr.metadata(output_nh).get<NodeType>().t == NodeType::DATA);
auto &output_meta = gr.metadata(output_nh).get<Data>().meta;
if (!meta_is_initialized && !util::holds_alternative<util::monostate>(output_meta))
{
GAPI_LOG_INFO(NULL,
"!!! Output object has an initialized meta - "
"how it is possible today?" << std::endl; );
if (output_meta != out_metas.at(output_port))
{
util::throw_error(std::logic_error("Fatal: meta mismatch"));
// FIXME: New exception type?
// FIXME: More details!
}
}
cv::util::suppress_unused_warning(meta_is_initialized);
// FIXME: calling compile() with meta the second time when cannot reshape will lead to error below
//if (!meta_is_initialized && !util::holds_alternative<util::monostate>(output_meta))
//{
// GAPI_LOG_INFO(NULL,
// "!!! Output object has an initialized meta - "
// "how it is possible today?" << std::endl; );
// if (output_meta != out_metas.at(output_port))
// {
// util::throw_error(std::logic_error("Fatal: meta mismatch"));
// // FIXME: New exception type?
// // FIXME: More details!
// }
//}
// Store meta in graph
output_meta = out_metas.at(output_port);
}