1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #12990 from rgarnov:gapi_fluid_reshape_support

G-API: Introduce new `reshape()` API (#12990)

* Moved initFluidUnits, initLineConsumption, calcLatency, calcSkew to separate functions

* Added Fluid::View::allocate method (moved allocation logic from constructor)

* Changed util::zip to util::indexed, utilized collectInputMeta in GFluidExecutable constructor

* Added makeReshape method to FluidExecutable

* Removed m_outputRoi from GFluidExecutable

* Added reshape feature

* Added switch of resize mapper if agent ratio was changed

* Added more TODOs and renamed a function

* G-API reshape(): add missing `override` specifiers

Fix warnings on all platforms
This commit is contained in:
Ruslan Garnov
2018-10-30 21:12:36 +03:00
committed by Alexander Alekhin
parent 08536943ad
commit 443fed796a
18 changed files with 718 additions and 333 deletions
+19 -1
View File
@@ -13,6 +13,7 @@
#include "opencv2/gapi/opencv_includes.hpp"
#include "executor/gexecutor.hpp"
#include "compiler/passes/passes.hpp"
cv::gimpl::GExecutor::GExecutor(std::unique_ptr<ade::Graph> &&g_model)
: m_orig_graph(std::move(g_model))
@@ -34,7 +35,6 @@ cv::gimpl::GExecutor::GExecutor(std::unique_ptr<ade::Graph> &&g_model)
// 6. Run GIslandExecutable
// 7. writeBack
m_ops.reserve(m_gim.nodes().size());
auto sorted = m_gim.metadata().get<ade::passes::TopologicalSortData>();
for (auto nh : sorted.nodes())
{
@@ -59,6 +59,7 @@ cv::gimpl::GExecutor::GExecutor(std::unique_ptr<ade::Graph> &&g_model)
// (3)
for (auto in_slot_nh : nh->inNodes()) xtract(in_slot_nh, input_rcs);
for (auto out_slot_nh : nh->outNodes()) xtract(out_slot_nh, output_rcs);
m_ops.emplace_back(OpDesc{ std::move(input_rcs)
, std::move(output_rcs)
, m_gim.metadata(nh).get<IslandExec>().object});
@@ -224,3 +225,20 @@ const cv::gimpl::GModel::Graph& cv::gimpl::GExecutor::model() const
{
return m_gm;
}
bool cv::gimpl::GExecutor::canReshape() const
{
// FIXME: Introduce proper reshaping support on GExecutor level
// for all cases!
return (m_ops.size() == 1) && m_ops[0].isl_exec->canReshape();
}
void cv::gimpl::GExecutor::reshape(const GMetaArgs& inMetas, const GCompileArgs& args)
{
GAPI_Assert(canReshape());
auto& g = *m_orig_graph.get();
ade::passes::PassContext ctx{g};
passes::initMeta(ctx, inMetas);
passes::inferMeta(ctx, true);
m_ops[0].isl_exec->reshape(g, args);
}
+3
View File
@@ -85,6 +85,9 @@ public:
explicit GExecutor(std::unique_ptr<ade::Graph> &&g_model);
void run(cv::gimpl::GRuntimeArgs &&args);
bool canReshape() const;
void reshape(const GMetaArgs& inMetas, const GCompileArgs& args);
const GModel::Graph& model() const; // FIXME: make it ConstGraph?
};