Commit 6374b99a authored by Dmitry Budnikov's avatar Dmitry Budnikov Committed by Alexander Alekhin

Merge pull request #13240 from dbudniko:dbudniko/gapi_gpu_to_ocl_renaming

G-API rename GPU backend to OCL backend (#13240)

* renaming draft

* inline namespace instead non-safe define

* more back compatibility

* Updates after review from Dmitry
parent 4fb9bce7
...@@ -23,6 +23,7 @@ file(GLOB gapi_ext_hdrs ...@@ -23,6 +23,7 @@ file(GLOB gapi_ext_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/util/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/util/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cpu/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cpu/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/gpu/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/gpu/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/ocl/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/fluid/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/fluid/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/own/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/own/*.hpp"
) )
...@@ -72,11 +73,11 @@ set(gapi_srcs ...@@ -72,11 +73,11 @@ set(gapi_srcs
src/backends/fluid/gfluidimgproc_func.dispatch.cpp src/backends/fluid/gfluidimgproc_func.dispatch.cpp
src/backends/fluid/gfluidcore.cpp src/backends/fluid/gfluidcore.cpp
# GPU Backend (currently built-in) # OCL Backend (currently built-in)
src/backends/gpu/ggpubackend.cpp src/backends/ocl/goclbackend.cpp
src/backends/gpu/ggpukernel.cpp src/backends/ocl/goclkernel.cpp
src/backends/gpu/ggpuimgproc.cpp src/backends/ocl/goclimgproc.cpp
src/backends/gpu/ggpucore.cpp src/backends/ocl/goclcore.cpp
# Compound # Compound
src/backends/common/gcompoundbackend.cpp src/backends/common/gcompoundbackend.cpp
......
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
#ifndef OPENCV_GAPI_GPU_CORE_API_HPP #ifndef OPENCV_GAPI_GPU_CORE_API_HPP
#define OPENCV_GAPI_GPU_CORE_API_HPP #define OPENCV_GAPI_GPU_CORE_API_HPP
/** @file
* @deprecated Use "opencv2/gapi/ocl/core.hpp" instead.
*/
#include <opencv2/core/cvdef.h> // GAPI_EXPORTS #include "opencv2/gapi/ocl/core.hpp"
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
namespace cv { namespace cv {
namespace gapi { namespace gapi {
namespace core { namespace core {
namespace gpu { namespace gpu {
using namespace ocl;
GAPI_EXPORTS GKernelPackage kernels();
} // namespace gpu } // namespace gpu
} // namespace core } // namespace core
} // namespace gapi } // namespace gapi
......
...@@ -7,238 +7,22 @@ ...@@ -7,238 +7,22 @@
#ifndef OPENCV_GAPI_GGPUKERNEL_HPP #ifndef OPENCV_GAPI_GGPUKERNEL_HPP
#define OPENCV_GAPI_GGPUKERNEL_HPP #define OPENCV_GAPI_GGPUKERNEL_HPP
/** @file
* @deprecated Use "opencv2/gapi/ocl/goclkernel.hpp" instead.
*/
#include <vector> #include "opencv2/gapi/ocl/goclkernel.hpp"
#include <functional> #define GAPI_GPU_KERNEL GAPI_OCL_KERNEL
#include <map>
#include <unordered_map>
#include <opencv2/core/mat.hpp>
#include <opencv2/gapi/gcommon.hpp>
#include <opencv2/gapi/gkernel.hpp>
#include <opencv2/gapi/garg.hpp>
// FIXME: namespace scheme for backends?
namespace cv { namespace cv {
namespace gapi {
namespace gimpl namespace core {
{ namespace gpu {
// Forward-declare an internal class using namespace ocl;
class GGPUExecutable;
} // namespace gimpl
namespace gapi
{
namespace gpu
{
/**
* \addtogroup gapi_std_backends G-API Standard backends
* @{
*/
/**
* @brief Get a reference to GPU backend.
*
* At the moment, the GPU backend is built atop of OpenCV
* "Transparent API" (T-API), see cv::UMat for details.
*
* @sa gapi_std_backends
*/
GAPI_EXPORTS cv::gapi::GBackend backend();
/** @} */
} // namespace gpu } // namespace gpu
} // namespace core
} // namespace gapi } // namespace gapi
// Represents arguments which are passed to a wrapped GPU function
// FIXME: put into detail?
class GAPI_EXPORTS GGPUContext
{
public:
// Generic accessor API
template<typename T>
const T& inArg(int input) { return m_args.at(input).get<T>(); }
// Syntax sugar
const cv::UMat& inMat(int input);
cv::UMat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR()
const cv::gapi::own::Scalar& inVal(int input);
cv::gapi::own::Scalar& outValR(int output); // FIXME: Avoid cv::gapi::own::Scalar s = ctx.outValR()
template<typename T> std::vector<T>& outVecR(int output) // FIXME: the same issue
{
return outVecRef(output).wref<T>();
}
protected:
detail::VectorRef& outVecRef(int output);
std::vector<GArg> m_args;
std::unordered_map<std::size_t, GRunArgP> m_results;
friend class gimpl::GGPUExecutable;
};
class GAPI_EXPORTS GGPUKernel
{
public:
// This function is kernel's execution entry point (does the processing work)
using F = std::function<void(GGPUContext &)>;
GGPUKernel();
explicit GGPUKernel(const F& f);
void apply(GGPUContext &ctx);
protected:
F m_f;
};
// FIXME: This is an ugly ad-hoc imlpementation. TODO: refactor
namespace detail
{
template<class T> struct gpu_get_in;
template<> struct gpu_get_in<cv::GMat>
{
static cv::UMat get(GGPUContext &ctx, int idx) { return ctx.inMat(idx); }
};
template<> struct gpu_get_in<cv::GScalar>
{
static cv::Scalar get(GGPUContext &ctx, int idx) { return to_ocv(ctx.inVal(idx)); }
};
template<typename U> struct gpu_get_in<cv::GArray<U> >
{
static const std::vector<U>& get(GGPUContext &ctx, int idx) { return ctx.inArg<VectorRef>(idx).rref<U>(); }
};
template<class T> struct gpu_get_in
{
static T get(GGPUContext &ctx, int idx) { return ctx.inArg<T>(idx); }
};
struct tracked_cv_umat{
//TODO Think if T - API could reallocate UMat to a proper size - how do we handle this ?
//tracked_cv_umat(cv::UMat& m) : r{(m)}, original_data{m.getMat(ACCESS_RW).data} {}
tracked_cv_umat(cv::UMat& m) : r{ (m) }, original_data{ nullptr } {}
cv::UMat r;
uchar* original_data;
operator cv::UMat& (){ return r;}
void validate() const{
//if (r.getMat(ACCESS_RW).data != original_data)
//{
// util::throw_error
// (std::logic_error
// ("OpenCV kernel output parameter was reallocated. \n"
// "Incorrect meta data was provided ?"));
//}
}
};
struct scalar_wrapper_gpu
{
//FIXME reuse CPU (OpenCV) plugin code
scalar_wrapper_gpu(cv::gapi::own::Scalar& s) : m_s{cv::gapi::own::to_ocv(s)}, m_org_s(s) {};
operator cv::Scalar& () { return m_s; }
void writeBack() const { m_org_s = to_own(m_s); }
cv::Scalar m_s;
cv::gapi::own::Scalar& m_org_s;
};
template<typename... Outputs>
void postprocess_gpu(Outputs&... outs)
{
struct
{
void operator()(tracked_cv_umat* bm) { bm->validate(); }
void operator()(scalar_wrapper_gpu* sw) { sw->writeBack(); }
void operator()(...) { }
} validate;
//dummy array to unfold parameter pack
int dummy[] = { 0, (validate(&outs), 0)... };
cv::util::suppress_unused_warning(dummy);
}
template<class T> struct gpu_get_out;
template<> struct gpu_get_out<cv::GMat>
{
static tracked_cv_umat get(GGPUContext &ctx, int idx)
{
auto& r = ctx.outMatR(idx);
return{ r };
}
};
template<> struct gpu_get_out<cv::GScalar>
{
static scalar_wrapper_gpu get(GGPUContext &ctx, int idx)
{
auto& s = ctx.outValR(idx);
return{ s };
}
};
template<typename U> struct gpu_get_out<cv::GArray<U> >
{
static std::vector<U>& get(GGPUContext &ctx, int idx) { return ctx.outVecR<U>(idx); }
};
template<typename, typename, typename>
struct GPUCallHelper;
// FIXME: probably can be simplified with std::apply or analogue.
template<typename Impl, typename... Ins, typename... Outs>
struct GPUCallHelper<Impl, std::tuple<Ins...>, std::tuple<Outs...> >
{
template<typename... Inputs>
struct call_and_postprocess
{
template<typename... Outputs>
static void call(Inputs&&... ins, Outputs&&... outs)
{
//not using a std::forward on outs is deliberate in order to
//cause compilation error, by tring to bind rvalue references to lvalue references
Impl::run(std::forward<Inputs>(ins)..., outs...);
postprocess_gpu(outs...);
}
};
template<int... IIs, int... OIs>
static void call_impl(GGPUContext &ctx, detail::Seq<IIs...>, detail::Seq<OIs...>)
{
//TODO: Make sure that OpenCV kernels do not reallocate memory for output parameters
//by comparing it's state (data ptr) before and after the call.
//Convert own::Scalar to cv::Scalar before call kernel and run kernel
//convert cv::Scalar to own::Scalar after call kernel and write back results
call_and_postprocess<decltype(gpu_get_in<Ins>::get(ctx, IIs))...>::call(gpu_get_in<Ins>::get(ctx, IIs)..., gpu_get_out<Outs>::get(ctx, OIs)...);
}
static void call(GGPUContext &ctx)
{
call_impl(ctx,
typename detail::MkSeq<sizeof...(Ins)>::type(),
typename detail::MkSeq<sizeof...(Outs)>::type());
}
};
} // namespace detail
template<class Impl, class K>
class GGPUKernelImpl: public detail::GPUCallHelper<Impl, typename K::InArgs, typename K::OutArgs>
{
using P = detail::GPUCallHelper<Impl, typename K::InArgs, typename K::OutArgs>;
public:
using API = K;
static cv::gapi::GBackend backend() { return cv::gapi::gpu::backend(); }
static cv::GGPUKernel kernel() { return GGPUKernel(&P::call); }
};
#define GAPI_GPU_KERNEL(Name, API) struct Name: public cv::GGPUKernelImpl<Name, API>
} // namespace cv } // namespace cv
#endif // OPENCV_GAPI_GGPUKERNEL_HPP #endif // OPENCV_GAPI_GGPUKERNEL_HPP
...@@ -7,17 +7,18 @@ ...@@ -7,17 +7,18 @@
#ifndef OPENCV_GAPI_GPU_IMGPROC_API_HPP #ifndef OPENCV_GAPI_GPU_IMGPROC_API_HPP
#define OPENCV_GAPI_GPU_IMGPROC_API_HPP #define OPENCV_GAPI_GPU_IMGPROC_API_HPP
/** @file
* @deprecated Use "opencv2/gapi/ocl/imgproc.hpp" instead.
*/
#include "opencv2/gapi/ocl/imgproc.hpp"
#include <opencv2/core/cvdef.h> // GAPI_EXPORTS
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
namespace cv { namespace cv {
namespace gapi { namespace gapi {
namespace imgproc { namespace imgproc {
namespace gpu { namespace gpu {
using namespace ocl;
GAPI_EXPORTS GKernelPackage kernels();
} // namespace gpu } // namespace gpu
} // namespace imgproc } // namespace imgproc
} // namespace gapi } // namespace gapi
......
// 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_OCL_CORE_API_HPP
#define OPENCV_GAPI_OCL_CORE_API_HPP
#include <opencv2/core/cvdef.h> // GAPI_EXPORTS
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
namespace cv {
namespace gapi {
namespace core {
inline namespace ocl {
GAPI_EXPORTS GKernelPackage kernels();
} // inline namespace ocl
namespace gpu {
using namespace ocl;
} // namespace gpu
} // namespace core
} // namespace gapi
} // namespace cv
#endif // OPENCV_GAPI_OCL_CORE_API_HPP
// 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_GOCLKERNEL_HPP
#define OPENCV_GAPI_GOCLKERNEL_HPP
#include <vector>
#include <functional>
#include <map>
#include <unordered_map>
#include <opencv2/core/mat.hpp>
#include <opencv2/gapi/gcommon.hpp>
#include <opencv2/gapi/gkernel.hpp>
#include <opencv2/gapi/garg.hpp>
// FIXME: namespace scheme for backends?
namespace cv {
namespace gimpl
{
// Forward-declare an internal class
class GOCLExecutable;
} // namespace gimpl
namespace gapi
{
namespace ocl
{
/**
* \addtogroup gapi_std_backends G-API Standard backends
* @{
*/
/**
* @brief Get a reference to OCL backend.
*
* At the moment, the OCL backend is built atop of OpenCV
* "Transparent API" (T-API), see cv::UMat for details.
*
* @sa gapi_std_backends
*/
GAPI_EXPORTS cv::gapi::GBackend backend();
/** @} */
} // namespace ocl
} // namespace gapi
// Represents arguments which are passed to a wrapped OCL function
// FIXME: put into detail?
class GAPI_EXPORTS GOCLContext
{
public:
// Generic accessor API
template<typename T>
const T& inArg(int input) { return m_args.at(input).get<T>(); }
// Syntax sugar
const cv::UMat& inMat(int input);
cv::UMat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR()
const cv::gapi::own::Scalar& inVal(int input);
cv::gapi::own::Scalar& outValR(int output); // FIXME: Avoid cv::gapi::own::Scalar s = ctx.outValR()
template<typename T> std::vector<T>& outVecR(int output) // FIXME: the same issue
{
return outVecRef(output).wref<T>();
}
protected:
detail::VectorRef& outVecRef(int output);
std::vector<GArg> m_args;
std::unordered_map<std::size_t, GRunArgP> m_results;
friend class gimpl::GOCLExecutable;
};
class GAPI_EXPORTS GOCLKernel
{
public:
// This function is kernel's execution entry point (does the processing work)
using F = std::function<void(GOCLContext &)>;
GOCLKernel();
explicit GOCLKernel(const F& f);
void apply(GOCLContext &ctx);
protected:
F m_f;
};
// FIXME: This is an ugly ad-hoc imlpementation. TODO: refactor
namespace detail
{
template<class T> struct ocl_get_in;
template<> struct ocl_get_in<cv::GMat>
{
static cv::UMat get(GOCLContext &ctx, int idx) { return ctx.inMat(idx); }
};
template<> struct ocl_get_in<cv::GScalar>
{
static cv::Scalar get(GOCLContext &ctx, int idx) { return to_ocv(ctx.inVal(idx)); }
};
template<typename U> struct ocl_get_in<cv::GArray<U> >
{
static const std::vector<U>& get(GOCLContext &ctx, int idx) { return ctx.inArg<VectorRef>(idx).rref<U>(); }
};
template<class T> struct ocl_get_in
{
static T get(GOCLContext &ctx, int idx) { return ctx.inArg<T>(idx); }
};
struct tracked_cv_umat{
//TODO Think if T - API could reallocate UMat to a proper size - how do we handle this ?
//tracked_cv_umat(cv::UMat& m) : r{(m)}, original_data{m.getMat(ACCESS_RW).data} {}
tracked_cv_umat(cv::UMat& m) : r{ (m) }, original_data{ nullptr } {}
cv::UMat r;
uchar* original_data;
operator cv::UMat& (){ return r;}
void validate() const{
//if (r.getMat(ACCESS_RW).data != original_data)
//{
// util::throw_error
// (std::logic_error
// ("OpenCV kernel output parameter was reallocated. \n"
// "Incorrect meta data was provided ?"));
//}
}
};
struct scalar_wrapper_ocl
{
//FIXME reuse CPU (OpenCV) plugin code
scalar_wrapper_ocl(cv::gapi::own::Scalar& s) : m_s{cv::gapi::own::to_ocv(s)}, m_org_s(s) {};
operator cv::Scalar& () { return m_s; }
void writeBack() const { m_org_s = to_own(m_s); }
cv::Scalar m_s;
cv::gapi::own::Scalar& m_org_s;
};
template<typename... Outputs>
void postprocess_ocl(Outputs&... outs)
{
struct
{
void operator()(tracked_cv_umat* bm) { bm->validate(); }
void operator()(scalar_wrapper_ocl* sw) { sw->writeBack(); }
void operator()(...) { }
} validate;
//dummy array to unfold parameter pack
int dummy[] = { 0, (validate(&outs), 0)... };
cv::util::suppress_unused_warning(dummy);
}
template<class T> struct ocl_get_out;
template<> struct ocl_get_out<cv::GMat>
{
static tracked_cv_umat get(GOCLContext &ctx, int idx)
{
auto& r = ctx.outMatR(idx);
return{ r };
}
};
template<> struct ocl_get_out<cv::GScalar>
{
static scalar_wrapper_ocl get(GOCLContext &ctx, int idx)
{
auto& s = ctx.outValR(idx);
return{ s };
}
};
template<typename U> struct ocl_get_out<cv::GArray<U> >
{
static std::vector<U>& get(GOCLContext &ctx, int idx) { return ctx.outVecR<U>(idx); }
};
template<typename, typename, typename>
struct OCLCallHelper;
// FIXME: probably can be simplified with std::apply or analogue.
template<typename Impl, typename... Ins, typename... Outs>
struct OCLCallHelper<Impl, std::tuple<Ins...>, std::tuple<Outs...> >
{
template<typename... Inputs>
struct call_and_postprocess
{
template<typename... Outputs>
static void call(Inputs&&... ins, Outputs&&... outs)
{
//not using a std::forward on outs is deliberate in order to
//cause compilation error, by tring to bind rvalue references to lvalue references
Impl::run(std::forward<Inputs>(ins)..., outs...);
postprocess_ocl(outs...);
}
};
template<int... IIs, int... OIs>
static void call_impl(GOCLContext &ctx, detail::Seq<IIs...>, detail::Seq<OIs...>)
{
//TODO: Make sure that OpenCV kernels do not reallocate memory for output parameters
//by comparing it's state (data ptr) before and after the call.
//Convert own::Scalar to cv::Scalar before call kernel and run kernel
//convert cv::Scalar to own::Scalar after call kernel and write back results
call_and_postprocess<decltype(ocl_get_in<Ins>::get(ctx, IIs))...>::call(ocl_get_in<Ins>::get(ctx, IIs)..., ocl_get_out<Outs>::get(ctx, OIs)...);
}
static void call(GOCLContext &ctx)
{
call_impl(ctx,
typename detail::MkSeq<sizeof...(Ins)>::type(),
typename detail::MkSeq<sizeof...(Outs)>::type());
}
};
} // namespace detail
template<class Impl, class K>
class GOCLKernelImpl: public detail::OCLCallHelper<Impl, typename K::InArgs, typename K::OutArgs>
{
using P = detail::OCLCallHelper<Impl, typename K::InArgs, typename K::OutArgs>;
public:
using API = K;
static cv::gapi::GBackend backend() { return cv::gapi::ocl::backend(); }
static cv::GOCLKernel kernel() { return GOCLKernel(&P::call); }
};
#define GAPI_OCL_KERNEL(Name, API) struct Name: public cv::GOCLKernelImpl<Name, API>
} // namespace cv
#endif // OPENCV_GAPI_GOCLKERNEL_HPP
// 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_OCL_IMGPROC_API_HPP
#define OPENCV_GAPI_OCL_IMGPROC_API_HPP
#include <opencv2/core/cvdef.h> // GAPI_EXPORTS
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
namespace cv {
namespace gapi {
namespace imgproc {
inline namespace ocl {
GAPI_EXPORTS GKernelPackage kernels();
} // inline namespace ocl
namespace gpu {
using namespace ocl;
} // namespace gpu
} // namespace imgproc
} // namespace gapi
} // namespace cv
#endif // OPENCV_GAPI_OCL_IMGPROC_API_HPP
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "../perf_precomp.hpp" #include "../perf_precomp.hpp"
#include "../common/gapi_core_perf_tests.hpp" #include "../common/gapi_core_perf_tests.hpp"
#include "opencv2/gapi/gpu/core.hpp"
#define CORE_GPU cv::gapi::core::gpu::kernels() #define CORE_GPU cv::gapi::core::gpu::kernels()
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "../perf_precomp.hpp" #include "../perf_precomp.hpp"
#include "../common/gapi_imgproc_perf_tests.hpp" #include "../common/gapi_imgproc_perf_tests.hpp"
#include "opencv2/gapi/gpu/imgproc.hpp"
#define IMGPROC_GPU cv::gapi::imgproc::gpu::kernels() #define IMGPROC_GPU cv::gapi::imgproc::gpu::kernels()
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "opencv2/gapi/core.hpp" #include "opencv2/gapi/core.hpp"
#include "opencv2/gapi/cpu/gcpukernel.hpp" #include "opencv2/gapi/cpu/gcpukernel.hpp"
#include "opencv2/gapi/gpu/ggpukernel.hpp" #include "opencv2/gapi/gpu/ggpukernel.hpp"
#include "opencv2/gapi/gpu/imgproc.hpp"
#include "opencv2/gapi/gpu/core.hpp"
#include "opencv2/gapi/operators.hpp" #include "opencv2/gapi/operators.hpp"
#include "opencv2/gapi/fluid/core.hpp" #include "opencv2/gapi/fluid/core.hpp"
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "compiler/gobjref.hpp" #include "compiler/gobjref.hpp"
#include "compiler/gmodel.hpp" #include "compiler/gmodel.hpp"
#include "backends/gpu/ggpubackend.hpp" #include "backends/ocl/goclbackend.hpp"
#include "backends/gpu/ggpuimgproc.hpp" #include "backends/ocl/goclimgproc.hpp"
#include "backends/gpu/ggpucore.hpp" #include "backends/ocl/goclcore.hpp"
#include "api/gbackend_priv.hpp" // FIXME: Make it part of Backend SDK! #include "api/gbackend_priv.hpp" // FIXME: Make it part of Backend SDK!
...@@ -37,47 +37,47 @@ ...@@ -37,47 +37,47 @@
// Alternatively, is there a way to compose types graphs? // Alternatively, is there a way to compose types graphs?
// //
// If not, we need to introduce that! // If not, we need to introduce that!
using GGPUModel = ade::TypedGraph using GOCLModel = ade::TypedGraph
< cv::gimpl::Unit < cv::gimpl::Unit
, cv::gimpl::Protocol , cv::gimpl::Protocol
>; >;
// FIXME: Same issue with Typed and ConstTyped // FIXME: Same issue with Typed and ConstTyped
using GConstGGPUModel = ade::ConstTypedGraph using GConstGOCLModel = ade::ConstTypedGraph
< cv::gimpl::Unit < cv::gimpl::Unit
, cv::gimpl::Protocol , cv::gimpl::Protocol
>; >;
namespace namespace
{ {
class GGPUBackendImpl final: public cv::gapi::GBackend::Priv class GOCLBackendImpl final: public cv::gapi::GBackend::Priv
{ {
virtual void unpackKernel(ade::Graph &graph, virtual void unpackKernel(ade::Graph &graph,
const ade::NodeHandle &op_node, const ade::NodeHandle &op_node,
const cv::GKernelImpl &impl) override const cv::GKernelImpl &impl) override
{ {
GGPUModel gm(graph); GOCLModel gm(graph);
auto gpu_impl = cv::util::any_cast<cv::GGPUKernel>(impl.opaque); auto ocl_impl = cv::util::any_cast<cv::GOCLKernel>(impl.opaque);
gm.metadata(op_node).set(cv::gimpl::Unit{gpu_impl}); gm.metadata(op_node).set(cv::gimpl::Unit{ocl_impl});
} }
virtual EPtr compile(const ade::Graph &graph, virtual EPtr compile(const ade::Graph &graph,
const cv::GCompileArgs &, const cv::GCompileArgs &,
const std::vector<ade::NodeHandle> &nodes) const override const std::vector<ade::NodeHandle> &nodes) const override
{ {
return EPtr{new cv::gimpl::GGPUExecutable(graph, nodes)}; return EPtr{new cv::gimpl::GOCLExecutable(graph, nodes)};
} }
}; };
} }
cv::gapi::GBackend cv::gapi::gpu::backend() cv::gapi::GBackend cv::gapi::ocl::backend()
{ {
static cv::gapi::GBackend this_backend(std::make_shared<GGPUBackendImpl>()); static cv::gapi::GBackend this_backend(std::make_shared<GOCLBackendImpl>());
return this_backend; return this_backend;
} }
// GGPUExcecutable implementation ////////////////////////////////////////////// // GOCLExcecutable implementation //////////////////////////////////////////////
cv::gimpl::GGPUExecutable::GGPUExecutable(const ade::Graph &g, cv::gimpl::GOCLExecutable::GOCLExecutable(const ade::Graph &g,
const std::vector<ade::NodeHandle> &nodes) const std::vector<ade::NodeHandle> &nodes)
: m_g(g), m_gm(m_g) : m_g(g), m_gm(m_g)
{ {
...@@ -112,7 +112,7 @@ cv::gimpl::GGPUExecutable::GGPUExecutable(const ade::Graph &g, ...@@ -112,7 +112,7 @@ cv::gimpl::GGPUExecutable::GGPUExecutable(const ade::Graph &g,
} }
// FIXME: Document what it does // FIXME: Document what it does
cv::GArg cv::gimpl::GGPUExecutable::packArg(const GArg &arg) cv::GArg cv::gimpl::GOCLExecutable::packArg(const GArg &arg)
{ {
// No API placeholders allowed at this point // No API placeholders allowed at this point
// FIXME: this check has to be done somewhere in compilation stage. // FIXME: this check has to be done somewhere in compilation stage.
...@@ -143,7 +143,7 @@ cv::GArg cv::gimpl::GGPUExecutable::packArg(const GArg &arg) ...@@ -143,7 +143,7 @@ cv::GArg cv::gimpl::GGPUExecutable::packArg(const GArg &arg)
} }
} }
void cv::gimpl::GGPUExecutable::run(std::vector<InObj> &&input_objs, void cv::gimpl::GOCLExecutable::run(std::vector<InObj> &&input_objs,
std::vector<OutObj> &&output_objs) std::vector<OutObj> &&output_objs)
{ {
// Update resources with run-time information - what this Island // Update resources with run-time information - what this Island
...@@ -172,24 +172,24 @@ void cv::gimpl::GGPUExecutable::run(std::vector<InObj> &&input_objs, ...@@ -172,24 +172,24 @@ void cv::gimpl::GGPUExecutable::run(std::vector<InObj> &&input_objs,
// OpenCV backend execution is not a rocket science at all. // OpenCV backend execution is not a rocket science at all.
// Simply invoke our kernels in the proper order. // Simply invoke our kernels in the proper order.
GConstGGPUModel gcm(m_g); GConstGOCLModel gcm(m_g);
for (auto &op_info : m_script) for (auto &op_info : m_script)
{ {
const auto &op = m_gm.metadata(op_info.nh).get<Op>(); const auto &op = m_gm.metadata(op_info.nh).get<Op>();
// Obtain our real execution unit // Obtain our real execution unit
// TODO: Should kernels be copyable? // TODO: Should kernels be copyable?
GGPUKernel k = gcm.metadata(op_info.nh).get<Unit>().k; GOCLKernel k = gcm.metadata(op_info.nh).get<Unit>().k;
// Initialize kernel's execution context: // Initialize kernel's execution context:
// - Input parameters // - Input parameters
GGPUContext context; GOCLContext context;
context.m_args.reserve(op.args.size()); context.m_args.reserve(op.args.size());
using namespace std::placeholders; using namespace std::placeholders;
ade::util::transform(op.args, ade::util::transform(op.args,
std::back_inserter(context.m_args), std::back_inserter(context.m_args),
std::bind(&GGPUExecutable::packArg, this, _1)); std::bind(&GOCLExecutable::packArg, this, _1));
// - Output parameters. // - Output parameters.
// FIXME: pre-allocate internal Mats, etc, according to the known meta // FIXME: pre-allocate internal Mats, etc, according to the known meta
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
// Copyright (C) 2018 Intel Corporation // Copyright (C) 2018 Intel Corporation
#ifndef OPENCV_GAPI_GGPUBACKEND_HPP #ifndef OPENCV_GAPI_GOCLBACKEND_HPP
#define OPENCV_GAPI_GGPUBACKEND_HPP #define OPENCV_GAPI_GOCLBACKEND_HPP
#include <map> // map #include <map> // map
#include <unordered_map> // unordered_map #include <unordered_map> // unordered_map
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/garg.hpp"
#include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/gproto.hpp"
#include "opencv2/gapi/gpu/ggpukernel.hpp" #include "opencv2/gapi/ocl/goclkernel.hpp"
#include "api/gapi_priv.hpp" #include "api/gapi_priv.hpp"
...@@ -26,11 +26,11 @@ namespace cv { namespace gimpl { ...@@ -26,11 +26,11 @@ namespace cv { namespace gimpl {
struct Unit struct Unit
{ {
static const char *name() { return "GPUKernel"; } static const char *name() { return "OCLKernel"; }
GGPUKernel k; GOCLKernel k;
}; };
class GGPUExecutable final: public GIslandExecutable class GOCLExecutable final: public GIslandExecutable
{ {
const ade::Graph &m_g; const ade::Graph &m_g;
GModel::ConstGraph m_gm; GModel::ConstGraph m_gm;
...@@ -51,16 +51,16 @@ class GGPUExecutable final: public GIslandExecutable ...@@ -51,16 +51,16 @@ class GGPUExecutable final: public GIslandExecutable
GArg packArg(const GArg &arg); GArg packArg(const GArg &arg);
public: public:
GGPUExecutable(const ade::Graph &graph, GOCLExecutable(const ade::Graph &graph,
const std::vector<ade::NodeHandle> &nodes); const std::vector<ade::NodeHandle> &nodes);
virtual inline bool canReshape() const override { return false; } virtual inline bool canReshape() const override { return false; }
virtual inline void reshape(ade::Graph&, const GCompileArgs&) override virtual inline void reshape(ade::Graph&, const GCompileArgs&) override
{ {
// FIXME: GPU plugin is in fact reshapeable (as it was initially, // FIXME: OCL plugin is in fact reshapeable (as it was initially,
// even before outMeta() has been introduced), so this limitation // even before outMeta() has been introduced), so this limitation
// should be dropped. // should be dropped.
util::throw_error(std::logic_error("GGPUExecutable::reshape() should never be called")); util::throw_error(std::logic_error("GOCLExecutable::reshape() should never be called"));
} }
virtual void run(std::vector<InObj> &&input_objs, virtual void run(std::vector<InObj> &&input_objs,
...@@ -69,4 +69,4 @@ public: ...@@ -69,4 +69,4 @@ public:
}} }}
#endif // OPENCV_GAPI_GGPUBACKEND_HPP #endif // OPENCV_GAPI_GOCLBACKEND_HPP
...@@ -5,20 +5,20 @@ ...@@ -5,20 +5,20 @@
// Copyright (C) 2018 Intel Corporation // Copyright (C) 2018 Intel Corporation
#ifndef OPENCV_GAPI_GGPUCORE_HPP #ifndef OPENCV_GAPI_GOCLCORE_HPP
#define OPENCV_GAPI_GGPUCORE_HPP #define OPENCV_GAPI_GOCLCORE_HPP
#include <map> #include <map>
#include <string> #include <string>
#include "opencv2/gapi/gpu/ggpukernel.hpp" #include "opencv2/gapi/ocl/goclkernel.hpp"
namespace cv { namespace gimpl { namespace cv { namespace gimpl {
// NB: This is what a "Kernel Package" from the original Wiki doc should be. // NB: This is what a "Kernel Package" from the original Wiki doc should be.
void loadGPUCore(std::map<std::string, cv::GGPUKernel> &kmap); void loadOCLCore(std::map<std::string, cv::GOCLKernel> &kmap);
} }
} }
#endif // OPENCV_GAPI_GGPUCORE_HPP #endif // OPENCV_GAPI_GOCLCORE_HPP
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencv2/gapi/imgproc.hpp" #include "opencv2/gapi/imgproc.hpp"
#include "opencv2/gapi/gpu/imgproc.hpp" #include "opencv2/gapi/ocl/imgproc.hpp"
#include "backends/gpu/ggpuimgproc.hpp" #include "backends/ocl/goclimgproc.hpp"
GAPI_GPU_KERNEL(GGPUSepFilter, cv::gapi::imgproc::GSepFilter) GAPI_OCL_KERNEL(GOCLSepFilter, cv::gapi::imgproc::GSepFilter)
{ {
static void run(const cv::UMat& in, int ddepth, const cv::Mat& kernX, const cv::Mat& kernY, const cv::Point& anchor, const cv::Scalar& delta, static void run(const cv::UMat& in, int ddepth, const cv::Mat& kernX, const cv::Mat& kernY, const cv::Point& anchor, const cv::Scalar& delta,
int border, const cv::Scalar& bordVal, cv::UMat &out) int border, const cv::Scalar& bordVal, cv::UMat &out)
...@@ -31,7 +31,7 @@ GAPI_GPU_KERNEL(GGPUSepFilter, cv::gapi::imgproc::GSepFilter) ...@@ -31,7 +31,7 @@ GAPI_GPU_KERNEL(GGPUSepFilter, cv::gapi::imgproc::GSepFilter)
} }
}; };
GAPI_GPU_KERNEL(GGPUBoxFilter, cv::gapi::imgproc::GBoxFilter) GAPI_OCL_KERNEL(GOCLBoxFilter, cv::gapi::imgproc::GBoxFilter)
{ {
static void run(const cv::UMat& in, int ddepth, const cv::Size& ksize, const cv::Point& anchor, bool normalize, int borderType, const cv::Scalar& bordVal, cv::UMat &out) static void run(const cv::UMat& in, int ddepth, const cv::Size& ksize, const cv::Point& anchor, bool normalize, int borderType, const cv::Scalar& bordVal, cv::UMat &out)
{ {
...@@ -49,7 +49,7 @@ GAPI_GPU_KERNEL(GGPUBoxFilter, cv::gapi::imgproc::GBoxFilter) ...@@ -49,7 +49,7 @@ GAPI_GPU_KERNEL(GGPUBoxFilter, cv::gapi::imgproc::GBoxFilter)
} }
}; };
GAPI_GPU_KERNEL(GGPUBlur, cv::gapi::imgproc::GBlur) GAPI_OCL_KERNEL(GOCLBlur, cv::gapi::imgproc::GBlur)
{ {
static void run(const cv::UMat& in, const cv::Size& ksize, const cv::Point& anchor, int borderType, const cv::Scalar& bordVal, cv::UMat &out) static void run(const cv::UMat& in, const cv::Size& ksize, const cv::Point& anchor, int borderType, const cv::Scalar& bordVal, cv::UMat &out)
{ {
...@@ -68,7 +68,7 @@ GAPI_GPU_KERNEL(GGPUBlur, cv::gapi::imgproc::GBlur) ...@@ -68,7 +68,7 @@ GAPI_GPU_KERNEL(GGPUBlur, cv::gapi::imgproc::GBlur)
}; };
GAPI_GPU_KERNEL(GGPUFilter2D, cv::gapi::imgproc::GFilter2D) GAPI_OCL_KERNEL(GOCLFilter2D, cv::gapi::imgproc::GFilter2D)
{ {
static void run(const cv::UMat& in, int ddepth, const cv::Mat& k, const cv::Point& anchor, const cv::Scalar& delta, int border, static void run(const cv::UMat& in, int ddepth, const cv::Mat& k, const cv::Point& anchor, const cv::Scalar& delta, int border,
const cv::Scalar& bordVal, cv::UMat &out) const cv::Scalar& bordVal, cv::UMat &out)
...@@ -87,7 +87,7 @@ GAPI_GPU_KERNEL(GGPUFilter2D, cv::gapi::imgproc::GFilter2D) ...@@ -87,7 +87,7 @@ GAPI_GPU_KERNEL(GGPUFilter2D, cv::gapi::imgproc::GFilter2D)
} }
}; };
GAPI_GPU_KERNEL(GGPUGaussBlur, cv::gapi::imgproc::GGaussBlur) GAPI_OCL_KERNEL(GOCLGaussBlur, cv::gapi::imgproc::GGaussBlur)
{ {
static void run(const cv::UMat& in, const cv::Size& ksize, double sigmaX, double sigmaY, int borderType, const cv::Scalar& bordVal, cv::UMat &out) static void run(const cv::UMat& in, const cv::Size& ksize, double sigmaX, double sigmaY, int borderType, const cv::Scalar& bordVal, cv::UMat &out)
{ {
...@@ -105,7 +105,7 @@ GAPI_GPU_KERNEL(GGPUGaussBlur, cv::gapi::imgproc::GGaussBlur) ...@@ -105,7 +105,7 @@ GAPI_GPU_KERNEL(GGPUGaussBlur, cv::gapi::imgproc::GGaussBlur)
} }
}; };
GAPI_GPU_KERNEL(GGPUMedianBlur, cv::gapi::imgproc::GMedianBlur) GAPI_OCL_KERNEL(GOCLMedianBlur, cv::gapi::imgproc::GMedianBlur)
{ {
static void run(const cv::UMat& in, int ksize, cv::UMat &out) static void run(const cv::UMat& in, int ksize, cv::UMat &out)
{ {
...@@ -113,7 +113,7 @@ GAPI_GPU_KERNEL(GGPUMedianBlur, cv::gapi::imgproc::GMedianBlur) ...@@ -113,7 +113,7 @@ GAPI_GPU_KERNEL(GGPUMedianBlur, cv::gapi::imgproc::GMedianBlur)
} }
}; };
GAPI_GPU_KERNEL(GGPUErode, cv::gapi::imgproc::GErode) GAPI_OCL_KERNEL(GOCLErode, cv::gapi::imgproc::GErode)
{ {
static void run(const cv::UMat& in, const cv::Mat& kernel, const cv::Point& anchor, int iterations, int borderType, const cv::Scalar& borderValue, cv::UMat &out) static void run(const cv::UMat& in, const cv::Mat& kernel, const cv::Point& anchor, int iterations, int borderType, const cv::Scalar& borderValue, cv::UMat &out)
{ {
...@@ -121,7 +121,7 @@ GAPI_GPU_KERNEL(GGPUErode, cv::gapi::imgproc::GErode) ...@@ -121,7 +121,7 @@ GAPI_GPU_KERNEL(GGPUErode, cv::gapi::imgproc::GErode)
} }
}; };
GAPI_GPU_KERNEL(GGPUDilate, cv::gapi::imgproc::GDilate) GAPI_OCL_KERNEL(GOCLDilate, cv::gapi::imgproc::GDilate)
{ {
static void run(const cv::UMat& in, const cv::Mat& kernel, const cv::Point& anchor, int iterations, int borderType, const cv::Scalar& borderValue, cv::UMat &out) static void run(const cv::UMat& in, const cv::Mat& kernel, const cv::Point& anchor, int iterations, int borderType, const cv::Scalar& borderValue, cv::UMat &out)
{ {
...@@ -129,7 +129,7 @@ GAPI_GPU_KERNEL(GGPUDilate, cv::gapi::imgproc::GDilate) ...@@ -129,7 +129,7 @@ GAPI_GPU_KERNEL(GGPUDilate, cv::gapi::imgproc::GDilate)
} }
}; };
GAPI_GPU_KERNEL(GGPUSobel, cv::gapi::imgproc::GSobel) GAPI_OCL_KERNEL(GOCLSobel, cv::gapi::imgproc::GSobel)
{ {
static void run(const cv::UMat& in, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType, static void run(const cv::UMat& in, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType,
const cv::Scalar& bordVal, cv::UMat &out) const cv::Scalar& bordVal, cv::UMat &out)
...@@ -147,7 +147,7 @@ GAPI_GPU_KERNEL(GGPUSobel, cv::gapi::imgproc::GSobel) ...@@ -147,7 +147,7 @@ GAPI_GPU_KERNEL(GGPUSobel, cv::gapi::imgproc::GSobel)
} }
}; };
GAPI_GPU_KERNEL(GGPUEqualizeHist, cv::gapi::imgproc::GEqHist) GAPI_OCL_KERNEL(GOCLEqualizeHist, cv::gapi::imgproc::GEqHist)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -155,7 +155,7 @@ GAPI_GPU_KERNEL(GGPUEqualizeHist, cv::gapi::imgproc::GEqHist) ...@@ -155,7 +155,7 @@ GAPI_GPU_KERNEL(GGPUEqualizeHist, cv::gapi::imgproc::GEqHist)
} }
}; };
GAPI_GPU_KERNEL(GGPUCanny, cv::gapi::imgproc::GCanny) GAPI_OCL_KERNEL(GOCLCanny, cv::gapi::imgproc::GCanny)
{ {
static void run(const cv::UMat& in, double thr1, double thr2, int apSize, bool l2gradient, cv::UMat &out) static void run(const cv::UMat& in, double thr1, double thr2, int apSize, bool l2gradient, cv::UMat &out)
{ {
...@@ -163,7 +163,7 @@ GAPI_GPU_KERNEL(GGPUCanny, cv::gapi::imgproc::GCanny) ...@@ -163,7 +163,7 @@ GAPI_GPU_KERNEL(GGPUCanny, cv::gapi::imgproc::GCanny)
} }
}; };
GAPI_GPU_KERNEL(GGPURGB2YUV, cv::gapi::imgproc::GRGB2YUV) GAPI_OCL_KERNEL(GOCLRGB2YUV, cv::gapi::imgproc::GRGB2YUV)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -171,7 +171,7 @@ GAPI_GPU_KERNEL(GGPURGB2YUV, cv::gapi::imgproc::GRGB2YUV) ...@@ -171,7 +171,7 @@ GAPI_GPU_KERNEL(GGPURGB2YUV, cv::gapi::imgproc::GRGB2YUV)
} }
}; };
GAPI_GPU_KERNEL(GGPUYUV2RGB, cv::gapi::imgproc::GYUV2RGB) GAPI_OCL_KERNEL(GOCLYUV2RGB, cv::gapi::imgproc::GYUV2RGB)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -179,7 +179,7 @@ GAPI_GPU_KERNEL(GGPUYUV2RGB, cv::gapi::imgproc::GYUV2RGB) ...@@ -179,7 +179,7 @@ GAPI_GPU_KERNEL(GGPUYUV2RGB, cv::gapi::imgproc::GYUV2RGB)
} }
}; };
GAPI_GPU_KERNEL(GGPURGB2Lab, cv::gapi::imgproc::GRGB2Lab) GAPI_OCL_KERNEL(GOCLRGB2Lab, cv::gapi::imgproc::GRGB2Lab)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -187,7 +187,7 @@ GAPI_GPU_KERNEL(GGPURGB2Lab, cv::gapi::imgproc::GRGB2Lab) ...@@ -187,7 +187,7 @@ GAPI_GPU_KERNEL(GGPURGB2Lab, cv::gapi::imgproc::GRGB2Lab)
} }
}; };
GAPI_GPU_KERNEL(GGPUBGR2LUV, cv::gapi::imgproc::GBGR2LUV) GAPI_OCL_KERNEL(GOCLBGR2LUV, cv::gapi::imgproc::GBGR2LUV)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -195,7 +195,7 @@ GAPI_GPU_KERNEL(GGPUBGR2LUV, cv::gapi::imgproc::GBGR2LUV) ...@@ -195,7 +195,7 @@ GAPI_GPU_KERNEL(GGPUBGR2LUV, cv::gapi::imgproc::GBGR2LUV)
} }
}; };
GAPI_GPU_KERNEL(GGPUBGR2YUV, cv::gapi::imgproc::GBGR2YUV) GAPI_OCL_KERNEL(GOCLBGR2YUV, cv::gapi::imgproc::GBGR2YUV)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -203,7 +203,7 @@ GAPI_GPU_KERNEL(GGPUBGR2YUV, cv::gapi::imgproc::GBGR2YUV) ...@@ -203,7 +203,7 @@ GAPI_GPU_KERNEL(GGPUBGR2YUV, cv::gapi::imgproc::GBGR2YUV)
} }
}; };
GAPI_GPU_KERNEL(GGPULUV2BGR, cv::gapi::imgproc::GLUV2BGR) GAPI_OCL_KERNEL(GOCLLUV2BGR, cv::gapi::imgproc::GLUV2BGR)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -211,7 +211,7 @@ GAPI_GPU_KERNEL(GGPULUV2BGR, cv::gapi::imgproc::GLUV2BGR) ...@@ -211,7 +211,7 @@ GAPI_GPU_KERNEL(GGPULUV2BGR, cv::gapi::imgproc::GLUV2BGR)
} }
}; };
GAPI_GPU_KERNEL(GGPUYUV2BGR, cv::gapi::imgproc::GYUV2BGR) GAPI_OCL_KERNEL(GOCLYUV2BGR, cv::gapi::imgproc::GYUV2BGR)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -219,7 +219,7 @@ GAPI_GPU_KERNEL(GGPUYUV2BGR, cv::gapi::imgproc::GYUV2BGR) ...@@ -219,7 +219,7 @@ GAPI_GPU_KERNEL(GGPUYUV2BGR, cv::gapi::imgproc::GYUV2BGR)
} }
}; };
GAPI_GPU_KERNEL(GGPURGB2Gray, cv::gapi::imgproc::GRGB2Gray) GAPI_OCL_KERNEL(GOCLRGB2Gray, cv::gapi::imgproc::GRGB2Gray)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -227,7 +227,7 @@ GAPI_GPU_KERNEL(GGPURGB2Gray, cv::gapi::imgproc::GRGB2Gray) ...@@ -227,7 +227,7 @@ GAPI_GPU_KERNEL(GGPURGB2Gray, cv::gapi::imgproc::GRGB2Gray)
} }
}; };
GAPI_GPU_KERNEL(GGPUBGR2Gray, cv::gapi::imgproc::GBGR2Gray) GAPI_OCL_KERNEL(GOCLBGR2Gray, cv::gapi::imgproc::GBGR2Gray)
{ {
static void run(const cv::UMat& in, cv::UMat &out) static void run(const cv::UMat& in, cv::UMat &out)
{ {
...@@ -235,7 +235,7 @@ GAPI_GPU_KERNEL(GGPUBGR2Gray, cv::gapi::imgproc::GBGR2Gray) ...@@ -235,7 +235,7 @@ GAPI_GPU_KERNEL(GGPUBGR2Gray, cv::gapi::imgproc::GBGR2Gray)
} }
}; };
GAPI_GPU_KERNEL(GGPURGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom) GAPI_OCL_KERNEL(GOCLRGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom)
{ {
//TODO: avoid copy //TODO: avoid copy
static void run(const cv::UMat& in, float rY, float bY, float gY, cv::UMat &out) static void run(const cv::UMat& in, float rY, float bY, float gY, cv::UMat &out)
...@@ -248,30 +248,30 @@ GAPI_GPU_KERNEL(GGPURGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom) ...@@ -248,30 +248,30 @@ GAPI_GPU_KERNEL(GGPURGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom)
}; };
cv::gapi::GKernelPackage cv::gapi::imgproc::gpu::kernels() cv::gapi::GKernelPackage cv::gapi::imgproc::ocl::kernels()
{ {
static auto pkg = cv::gapi::kernels static auto pkg = cv::gapi::kernels
< GGPUFilter2D < GOCLFilter2D
, GGPUSepFilter , GOCLSepFilter
, GGPUBoxFilter , GOCLBoxFilter
, GGPUBlur , GOCLBlur
, GGPUGaussBlur , GOCLGaussBlur
, GGPUMedianBlur , GOCLMedianBlur
, GGPUErode , GOCLErode
, GGPUDilate , GOCLDilate
, GGPUSobel , GOCLSobel
, GGPUCanny , GOCLCanny
, GGPUEqualizeHist , GOCLEqualizeHist
, GGPURGB2YUV , GOCLRGB2YUV
, GGPUYUV2RGB , GOCLYUV2RGB
, GGPURGB2Lab , GOCLRGB2Lab
, GGPUBGR2LUV , GOCLBGR2LUV
, GGPUBGR2YUV , GOCLBGR2YUV
, GGPUYUV2BGR , GOCLYUV2BGR
, GGPULUV2BGR , GOCLLUV2BGR
, GGPUBGR2Gray , GOCLBGR2Gray
, GGPURGB2Gray , GOCLRGB2Gray
, GGPURGB2GrayCustom , GOCLRGB2GrayCustom
>(); >();
return pkg; return pkg;
} }
...@@ -5,19 +5,19 @@ ...@@ -5,19 +5,19 @@
// Copyright (C) 2018 Intel Corporation // Copyright (C) 2018 Intel Corporation
#ifndef OPENCV_GAPI_GGPUIMGPROC_HPP #ifndef OPENCV_GAPI_GOCLIMGPROC_HPP
#define OPENCV_GAPI_GGPUIMGPROC_HPP #define OPENCV_GAPI_GOCLIMGPROC_HPP
#include <map> #include <map>
#include <string> #include <string>
#include "opencv2/gapi/gpu/ggpukernel.hpp" #include "opencv2/gapi/ocl/goclkernel.hpp"
namespace cv { namespace gimpl { namespace cv { namespace gimpl {
// NB: This is what a "Kernel Package" from the origianl Wiki doc should be. // NB: This is what a "Kernel Package" from the origianl Wiki doc should be.
void loadGPUImgProc(std::map<std::string, cv::GGPUKernel> &kmap); void loadOCLImgProc(std::map<std::string, cv::GOCLKernel> &kmap);
}} }}
#endif // OPENCV_GAPI_GGPUIMGPROC_HPP #endif // OPENCV_GAPI_GOCLIMGPROC_HPP
...@@ -7,43 +7,43 @@ ...@@ -7,43 +7,43 @@
#include <cassert> #include <cassert>
#include "opencv2/gapi/gpu/ggpukernel.hpp" #include "opencv2/gapi/ocl/goclkernel.hpp"
const cv::UMat& cv::GGPUContext::inMat(int input) const cv::UMat& cv::GOCLContext::inMat(int input)
{ {
return (inArg<cv::UMat>(input)); return (inArg<cv::UMat>(input));
} }
cv::UMat& cv::GGPUContext::outMatR(int output) cv::UMat& cv::GOCLContext::outMatR(int output)
{ {
return (*(util::get<cv::UMat*>(m_results.at(output)))); return (*(util::get<cv::UMat*>(m_results.at(output))));
} }
const cv::gapi::own::Scalar& cv::GGPUContext::inVal(int input) const cv::gapi::own::Scalar& cv::GOCLContext::inVal(int input)
{ {
return inArg<cv::gapi::own::Scalar>(input); return inArg<cv::gapi::own::Scalar>(input);
} }
cv::gapi::own::Scalar& cv::GGPUContext::outValR(int output) cv::gapi::own::Scalar& cv::GOCLContext::outValR(int output)
{ {
return *util::get<cv::gapi::own::Scalar*>(m_results.at(output)); return *util::get<cv::gapi::own::Scalar*>(m_results.at(output));
} }
cv::detail::VectorRef& cv::GGPUContext::outVecRef(int output) cv::detail::VectorRef& cv::GOCLContext::outVecRef(int output)
{ {
return util::get<cv::detail::VectorRef>(m_results.at(output)); return util::get<cv::detail::VectorRef>(m_results.at(output));
} }
cv::GGPUKernel::GGPUKernel() cv::GOCLKernel::GOCLKernel()
{ {
} }
cv::GGPUKernel::GGPUKernel(const GGPUKernel::F &f) cv::GOCLKernel::GOCLKernel(const GOCLKernel::F &f)
: m_f(f) : m_f(f)
{ {
} }
void cv::GGPUKernel::apply(GGPUContext &ctx) void cv::GOCLKernel::apply(GOCLContext &ctx)
{ {
CV_Assert(m_f); CV_Assert(m_f);
m_f(ctx); m_f(ctx);
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "../test_precomp.hpp" #include "../test_precomp.hpp"
#include "../common/gapi_core_tests.hpp" #include "../common/gapi_core_tests.hpp"
#include "opencv2/gapi/gpu/core.hpp"
#define CORE_GPU cv::gapi::core::gpu::kernels() #define CORE_GPU cv::gapi::core::gpu::kernels()
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "../test_precomp.hpp" #include "../test_precomp.hpp"
#include "../common/gapi_imgproc_tests.hpp" #include "../common/gapi_imgproc_tests.hpp"
#include "opencv2/gapi/gpu/imgproc.hpp"
#define IMGPROC_GPU cv::gapi::imgproc::gpu::kernels() #define IMGPROC_GPU cv::gapi::imgproc::gpu::kernels()
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "../test_precomp.hpp" #include "../test_precomp.hpp"
#include "../common/gapi_operators_tests.hpp" #include "../common/gapi_operators_tests.hpp"
#include "opencv2/gapi/gpu/core.hpp"
#define CORE_GPU cv::gapi::core::gpu::kernels() #define CORE_GPU cv::gapi::core::gpu::kernels()
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "opencv2/gapi/core.hpp" #include "opencv2/gapi/core.hpp"
#include "opencv2/gapi/cpu/gcpukernel.hpp" #include "opencv2/gapi/cpu/gcpukernel.hpp"
#include "opencv2/gapi/gpu/ggpukernel.hpp" #include "opencv2/gapi/gpu/ggpukernel.hpp"
#include "opencv2/gapi/gpu/imgproc.hpp"
#include "opencv2/gapi/gpu/core.hpp"
#include "opencv2/gapi/gcompoundkernel.hpp" #include "opencv2/gapi/gcompoundkernel.hpp"
#include "opencv2/gapi/operators.hpp" #include "opencv2/gapi/operators.hpp"
#include "opencv2/gapi/fluid/imgproc.hpp" #include "opencv2/gapi/fluid/imgproc.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment