mirror of
https://github.com/opencv/opencv.git
synced 2025-01-19 06:53:50 +08:00
Merge pull request #14599 from rgarnov:gapi_aux_kernels
G-API aux kernels (#14599) * Removed gcpuimgproc.hpp and gcpucore.hpp * Changed GModel::orderedInputs and orderedOutputs to get ConstGraph& * Added auxiliaryKernels() method of GBackend::Priv
This commit is contained in:
parent
cbb699efd2
commit
54ff72a1cc
@ -45,6 +45,11 @@ void cv::gapi::GBackend::Priv::addBackendPasses(ade::ExecutionEngineSetupContext
|
||||
// add custom (backend-specific) graph transformations
|
||||
}
|
||||
|
||||
cv::gapi::GKernelPackage cv::gapi::GBackend::Priv::auxiliaryKernels() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
// GBackend public implementation //////////////////////////////////////////////
|
||||
cv::gapi::GBackend::GBackend()
|
||||
{
|
||||
|
@ -47,6 +47,8 @@ public:
|
||||
|
||||
virtual void addBackendPasses(ade::ExecutionEngineSetupContext &);
|
||||
|
||||
virtual cv::gapi::GKernelPackage auxiliaryKernels() const;
|
||||
|
||||
virtual ~Priv() = default;
|
||||
};
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "compiler/gmodel.hpp"
|
||||
|
||||
#include "backends/cpu/gcpubackend.hpp"
|
||||
#include "backends/cpu/gcpuimgproc.hpp"
|
||||
#include "backends/cpu/gcpucore.hpp"
|
||||
#include "opencv2/gapi/cpu/imgproc.hpp"
|
||||
#include "opencv2/gapi/cpu/core.hpp"
|
||||
|
||||
#include "api/gbackend_priv.hpp" // FIXME: Make it part of Backend SDK!
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "opencv2/gapi/core.hpp"
|
||||
#include "opencv2/gapi/cpu/core.hpp"
|
||||
#include "backends/cpu/gcpucore.hpp"
|
||||
#include "opencv2/gapi/cpu/gcpukernel.hpp"
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUAdd, cv::gapi::core::GAdd)
|
||||
{
|
||||
|
@ -1,24 +0,0 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_GCPUCORE_HPP
|
||||
#define OPENCV_GAPI_GCPUCORE_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "opencv2/gapi/cpu/gcpukernel.hpp"
|
||||
|
||||
namespace cv { namespace gimpl {
|
||||
|
||||
// NB: This is what a "Kernel Package" from the original Wiki doc should be.
|
||||
void loadCPUCore(std::map<std::string, cv::GCPUKernel> &kmap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // OPENCV_GAPI_GCPUCORE_HPP
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "opencv2/gapi/imgproc.hpp"
|
||||
#include "opencv2/gapi/cpu/imgproc.hpp"
|
||||
#include "backends/cpu/gcpuimgproc.hpp"
|
||||
#include "opencv2/gapi/cpu/gcpukernel.hpp"
|
||||
|
||||
namespace {
|
||||
cv::Mat add_border(const cv::Mat& in, const int ksize, const int borderType, const cv::Scalar& bordVal){
|
||||
|
@ -1,23 +0,0 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_GCPUIMGPROC_HPP
|
||||
#define OPENCV_GAPI_GCPUIMGPROC_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "opencv2/gapi/cpu/gcpukernel.hpp"
|
||||
|
||||
namespace cv { namespace gimpl {
|
||||
|
||||
// NB: This is what a "Kernel Package" from the origianl Wiki doc should be.
|
||||
void loadCPUImgProc(std::map<std::string, cv::GCPUKernel> &kmap);
|
||||
|
||||
}}
|
||||
|
||||
#endif // OPENCV_GAPI_GCPUIMGPROC_HPP
|
@ -48,9 +48,17 @@ namespace
|
||||
{
|
||||
cv::gapi::GKernelPackage getKernelPackage(cv::GCompileArgs &args)
|
||||
{
|
||||
auto withAuxKernels = [](const cv::gapi::GKernelPackage& pkg) {
|
||||
cv::gapi::GKernelPackage aux_pkg;
|
||||
for (const auto &b : pkg.backends()) {
|
||||
aux_pkg = combine(aux_pkg, b.priv().auxiliaryKernels());
|
||||
}
|
||||
return combine(pkg, aux_pkg);
|
||||
};
|
||||
|
||||
auto has_use_only = cv::gimpl::getCompileArg<cv::gapi::use_only>(args);
|
||||
if (has_use_only)
|
||||
return has_use_only.value().pkg;
|
||||
return withAuxKernels(has_use_only.value().pkg);
|
||||
|
||||
static auto ocv_pkg =
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
@ -60,7 +68,8 @@ namespace
|
||||
cv::gapi::GKernelPackage();
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
auto user_pkg = cv::gimpl::getCompileArg<cv::gapi::GKernelPackage>(args);
|
||||
return combine(ocv_pkg, user_pkg.value_or(cv::gapi::GKernelPackage{}));
|
||||
auto user_pkg_with_aux = withAuxKernels(user_pkg.value_or(cv::gapi::GKernelPackage{}));
|
||||
return combine(ocv_pkg, user_pkg_with_aux);
|
||||
}
|
||||
|
||||
cv::util::optional<std::string> getGraphDumpDirectory(cv::GCompileArgs& args)
|
||||
|
@ -114,7 +114,7 @@ void GModel::linkOut(Graph &g, ade::NodeHandle opH, ade::NodeHandle objH, std::s
|
||||
op.outs[out_port] = RcDesc{gm.rc, gm.shape, {}};
|
||||
}
|
||||
|
||||
std::vector<ade::NodeHandle> GModel::orderedInputs(Graph &g, ade::NodeHandle nh)
|
||||
std::vector<ade::NodeHandle> GModel::orderedInputs(ConstGraph &g, ade::NodeHandle nh)
|
||||
{
|
||||
std::vector<ade::NodeHandle> sorted_in_nhs(nh->inEdges().size());
|
||||
for (const auto& in_eh : nh->inEdges())
|
||||
@ -126,7 +126,7 @@ std::vector<ade::NodeHandle> GModel::orderedInputs(Graph &g, ade::NodeHandle nh)
|
||||
return sorted_in_nhs;
|
||||
}
|
||||
|
||||
std::vector<ade::NodeHandle> GModel::orderedOutputs(Graph &g, ade::NodeHandle nh)
|
||||
std::vector<ade::NodeHandle> GModel::orderedOutputs(ConstGraph &g, ade::NodeHandle nh)
|
||||
{
|
||||
std::vector<ade::NodeHandle> sorted_out_nhs(nh->outEdges().size());
|
||||
for (const auto& out_eh : nh->outEdges())
|
||||
|
@ -201,8 +201,8 @@ namespace GModel
|
||||
GAPI_EXPORTS void redirectReaders(Graph &g, ade::NodeHandle from, ade::NodeHandle to);
|
||||
GAPI_EXPORTS void redirectWriter (Graph &g, ade::NodeHandle from, ade::NodeHandle to);
|
||||
|
||||
GAPI_EXPORTS std::vector<ade::NodeHandle> orderedInputs (Graph &g, ade::NodeHandle nh);
|
||||
GAPI_EXPORTS std::vector<ade::NodeHandle> orderedOutputs(Graph &g, ade::NodeHandle nh);
|
||||
GAPI_EXPORTS std::vector<ade::NodeHandle> orderedInputs (ConstGraph &g, ade::NodeHandle nh);
|
||||
GAPI_EXPORTS std::vector<ade::NodeHandle> orderedOutputs(ConstGraph &g, ade::NodeHandle nh);
|
||||
|
||||
// Returns input meta array for given op node
|
||||
// Array is sparse, as metadata for non-gapi input objects is empty
|
||||
|
Loading…
Reference in New Issue
Block a user