mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Enable stateful kernels in G-API OCV Backend
This commit is contained in:
@@ -265,3 +265,11 @@ void cv::gimpl::GExecutor::reshape(const GMetaArgs& inMetas, const GCompileArgs&
|
||||
passes::inferMeta(ctx, true);
|
||||
m_ops[0].isl_exec->reshape(g, args);
|
||||
}
|
||||
|
||||
void cv::gimpl::GExecutor::prepareForNewStream()
|
||||
{
|
||||
for (auto &op : m_ops)
|
||||
{
|
||||
op.isl_exec->handleNewStream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ public:
|
||||
bool canReshape() const;
|
||||
void reshape(const GMetaArgs& inMetas, const GCompileArgs& args);
|
||||
|
||||
void prepareForNewStream();
|
||||
|
||||
const GModel::Graph& model() const; // FIXME: make it ConstGraph?
|
||||
};
|
||||
|
||||
|
||||
@@ -800,6 +800,7 @@ void cv::gimpl::GStreamingExecutor::setSource(GRunArgs &&ins)
|
||||
}
|
||||
}
|
||||
};
|
||||
bool islandsRecompiled = false;
|
||||
const auto new_meta = cv::descr_of(ins); // 0
|
||||
if (gm.metadata().contains<OriginalInputMeta>()) // (1)
|
||||
{
|
||||
@@ -821,6 +822,8 @@ void cv::gimpl::GStreamingExecutor::setSource(GRunArgs &&ins)
|
||||
}
|
||||
update_int_metas(); // (7)
|
||||
m_reshapable = util::make_optional(is_reshapable);
|
||||
|
||||
islandsRecompiled = true;
|
||||
}
|
||||
else // (8)
|
||||
{
|
||||
@@ -929,7 +932,15 @@ void cv::gimpl::GStreamingExecutor::setSource(GRunArgs &&ins)
|
||||
for (auto &&out_eh : op.nh->outNodes()) {
|
||||
out_queues.push_back(reader_queues(*m_island_graph, out_eh));
|
||||
}
|
||||
op.isl_exec->handleNewStream();
|
||||
|
||||
// If Island Executable is recompiled, all its stuff including internal kernel states
|
||||
// are recreated and re-initialized automatically.
|
||||
// But if not, we should notify Island Executable about new started stream to let it update
|
||||
// its internal variables.
|
||||
if (!islandsRecompiled)
|
||||
{
|
||||
op.isl_exec->handleNewStream();
|
||||
}
|
||||
|
||||
m_threads.emplace_back(islandActorThread,
|
||||
op.in_objects,
|
||||
|
||||
Reference in New Issue
Block a user