mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -71,7 +71,7 @@ void GraphMetaExecutable::run(std::vector<InObj> &&input_objs,
|
||||
cv::util::get<cv::detail::OpaqueRef>(out_arg) = it->second;
|
||||
}
|
||||
|
||||
class GraphMetaBackendImpl final: public cv::gapi::GBackend::Priv {
|
||||
class GGraphMetaBackendImpl final: public cv::gapi::GBackend::Priv {
|
||||
virtual void unpackKernel(ade::Graph &,
|
||||
const ade::NodeHandle &,
|
||||
const cv::GKernelImpl &) override {
|
||||
@@ -88,7 +88,7 @@ class GraphMetaBackendImpl final: public cv::gapi::GBackend::Priv {
|
||||
};
|
||||
|
||||
cv::gapi::GBackend graph_meta_backend() {
|
||||
static cv::gapi::GBackend this_backend(std::make_shared<GraphMetaBackendImpl>());
|
||||
static cv::gapi::GBackend this_backend(std::make_shared<GGraphMetaBackendImpl>());
|
||||
return this_backend;
|
||||
}
|
||||
|
||||
|
||||
@@ -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-2020 Intel Corporation
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "api/gbackend_priv.hpp" // FIXME: Make it part of Backend SDK!
|
||||
|
||||
#include "utils/itt.hpp"
|
||||
|
||||
// FIXME: Is there a way to take a typed graph (our GModel),
|
||||
// and create a new typed graph _ATOP_ of that (by extending with a couple of
|
||||
// new types?).
|
||||
@@ -251,8 +253,13 @@ void cv::gimpl::GCPUExecutable::run(std::vector<InObj> &&input_objs,
|
||||
context.m_state = m_nodesToStates.at(op_info.nh);
|
||||
}
|
||||
|
||||
// Now trigger the executable unit
|
||||
k.m_runF(context);
|
||||
{
|
||||
GAPI_ITT_DYNAMIC_LOCAL_HANDLE(op_hndl, op.k.name.c_str());
|
||||
GAPI_ITT_AUTO_TRACE_GUARD(op_hndl);
|
||||
|
||||
// Now trigger the executable unit
|
||||
k.m_runF(context);
|
||||
}
|
||||
|
||||
//As Kernels are forbidden to allocate memory for (Mat) outputs,
|
||||
//this code seems redundant, at least for Mats
|
||||
|
||||
@@ -634,6 +634,15 @@ GAPI_OCV_KERNEL(GCPUKMeans3D, cv::gapi::core::GKMeans3D)
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUTranspose, cv::gapi::core::GTranspose)
|
||||
{
|
||||
static void run(const cv::Mat& in, cv::Mat& out)
|
||||
{
|
||||
cv::transpose(in, out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUParseSSDBL, cv::gapi::nn::parsers::GParseSSDBL)
|
||||
{
|
||||
static void run(const cv::Mat& in_ssd_result,
|
||||
@@ -774,6 +783,7 @@ cv::gapi::GKernelPackage cv::gapi::core::cpu::kernels()
|
||||
, GCPUKMeansNDNoInit
|
||||
, GCPUKMeans2D
|
||||
, GCPUKMeans3D
|
||||
, GCPUTranspose
|
||||
, GCPUParseSSDBL
|
||||
, GOCVParseSSD
|
||||
, GCPUParseYolo
|
||||
|
||||
@@ -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-2020 Intel Corporation
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
@@ -60,6 +60,8 @@ template<typename T> using QueueClass = tbb::concurrent_bounded_queue<T>;
|
||||
template<typename T> using QueueClass = cv::gapi::own::concurrent_bounded_queue<T>;
|
||||
#endif // TBB
|
||||
|
||||
#include "utils/itt.hpp"
|
||||
|
||||
namespace IE = InferenceEngine;
|
||||
|
||||
namespace {
|
||||
@@ -116,6 +118,7 @@ inline int toCV(IE::Precision prec) {
|
||||
case IE::Precision::FP32: return CV_32F;
|
||||
case IE::Precision::I32: return CV_32S;
|
||||
case IE::Precision::I64: return CV_32S;
|
||||
case IE::Precision::FP16: return CV_16F;
|
||||
default: GAPI_Assert(false && "IE. Unsupported data type");
|
||||
}
|
||||
return -1;
|
||||
@@ -194,6 +197,7 @@ inline void copyFromIE(const IE::Blob::Ptr &blob, MatType &mat) {
|
||||
HANDLE(U8, uint8_t);
|
||||
HANDLE(FP32, float);
|
||||
HANDLE(I32, int);
|
||||
HANDLE(FP16, cv::float16_t);
|
||||
#undef HANDLE
|
||||
case IE::Precision::I64: {
|
||||
GAPI_LOG_WARNING(NULL, "INT64 isn't supported for cv::Mat. Conversion to INT32 is used.");
|
||||
@@ -530,10 +534,11 @@ public:
|
||||
explicit RequestPool(std::vector<InferenceEngine::InferRequest>&& requests);
|
||||
|
||||
void execute(Task&& t);
|
||||
void waitAndShutdown();
|
||||
void waitAll();
|
||||
|
||||
private:
|
||||
void callback(Task task, InferenceEngine::InferRequest& request, size_t id);
|
||||
void setup();
|
||||
|
||||
QueueClass<size_t> m_idle_ids;
|
||||
std::vector<InferenceEngine::InferRequest> m_requests;
|
||||
@@ -542,11 +547,15 @@ private:
|
||||
// RequestPool implementation //////////////////////////////////////////////
|
||||
cv::gimpl::ie::RequestPool::RequestPool(std::vector<InferenceEngine::InferRequest>&& requests)
|
||||
: m_requests(std::move(requests)) {
|
||||
for (size_t i = 0; i < m_requests.size(); ++i) {
|
||||
m_idle_ids.push(i);
|
||||
}
|
||||
setup();
|
||||
}
|
||||
|
||||
void cv::gimpl::ie::RequestPool::setup() {
|
||||
for (size_t i = 0; i < m_requests.size(); ++i) {
|
||||
m_idle_ids.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
void cv::gimpl::ie::RequestPool::execute(cv::gimpl::ie::RequestPool::Task&& t) {
|
||||
size_t id = 0u;
|
||||
m_idle_ids.pop(id);
|
||||
@@ -566,12 +575,13 @@ void cv::gimpl::ie::RequestPool::callback(cv::gimpl::ie::RequestPool::Task task,
|
||||
}
|
||||
|
||||
// NB: Not thread-safe.
|
||||
void cv::gimpl::ie::RequestPool::waitAndShutdown() {
|
||||
void cv::gimpl::ie::RequestPool::waitAll() {
|
||||
// NB: It will be blocked if at least one request is busy.
|
||||
for (size_t i = 0; i < m_requests.size(); ++i) {
|
||||
size_t id = 0u;
|
||||
m_idle_ids.pop(id);
|
||||
}
|
||||
setup();
|
||||
}
|
||||
|
||||
// GCPUExcecutable implementation //////////////////////////////////////////////
|
||||
@@ -632,7 +642,7 @@ void cv::gimpl::ie::GIEExecutable::run(cv::gimpl::GIslandExecutable::IInput &in
|
||||
if (cv::util::holds_alternative<cv::gimpl::EndOfStream>(in_msg))
|
||||
{
|
||||
// (3) Wait until all passed task are done.
|
||||
m_reqPool->waitAndShutdown();
|
||||
m_reqPool->waitAll();
|
||||
out.post(cv::gimpl::EndOfStream{});
|
||||
return;
|
||||
}
|
||||
@@ -671,7 +681,7 @@ void cv::gimpl::ie::GIEExecutable::run(cv::gimpl::GIslandExecutable::IInput &in
|
||||
// (5) In non-streaming mode need to wait until the all tasks are done
|
||||
// FIXME: Is there more graceful way to handle this case ?
|
||||
if (!m_gm.metadata().contains<Streaming>()) {
|
||||
m_reqPool->waitAndShutdown();
|
||||
m_reqPool->waitAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,6 +761,9 @@ static void configureInputInfo(const IE::InputInfo::Ptr& ii, const cv::GMetaArg
|
||||
// to post outputs blobs (cv::GMat's).
|
||||
static void PostOutputs(InferenceEngine::InferRequest &request,
|
||||
std::shared_ptr<IECallContext> ctx) {
|
||||
GAPI_ITT_STATIC_LOCAL_HANDLE(ie_cb_post_outputs_hndl, "IE_async_callback_PostOutputs");
|
||||
GAPI_ITT_AUTO_TRACE_GUARD(ie_cb_post_outputs_hndl);
|
||||
|
||||
for (auto i : ade::util::iota(ctx->uu.params.num_out))
|
||||
{
|
||||
auto& out_mat = ctx->outMatR(i);
|
||||
@@ -1279,6 +1292,17 @@ namespace {
|
||||
, cv::gimpl::ie::InferList2
|
||||
>();
|
||||
}
|
||||
|
||||
virtual bool controlsMerge() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool allowsMerge(const cv::gimpl::GIslandModel::Graph &,
|
||||
const ade::NodeHandle &,
|
||||
const ade::NodeHandle &,
|
||||
const ade::NodeHandle &) const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -522,6 +522,15 @@ GAPI_OCL_KERNEL(GOCLConvertTo, cv::gapi::core::GConvertTo)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GAPI_OCL_KERNEL(GOCLTranspose, cv::gapi::core::GTranspose)
|
||||
{
|
||||
static void run(const cv::UMat& in, cv::UMat& out)
|
||||
{
|
||||
cv::transpose(in, out);
|
||||
}
|
||||
};
|
||||
|
||||
cv::gapi::GKernelPackage cv::gapi::core::ocl::kernels()
|
||||
{
|
||||
static auto pkg = cv::gapi::kernels
|
||||
@@ -586,6 +595,7 @@ cv::gapi::GKernelPackage cv::gapi::core::ocl::kernels()
|
||||
, GOCLConcatVert
|
||||
, GOCLLUT
|
||||
, GOCLConvertTo
|
||||
, GOCLTranspose
|
||||
>();
|
||||
return pkg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user