OpenCV  4.1.0
Open Source Computer Vision
Public Member Functions | Friends | List of all members
cv::gapi::GKernelPackage Class Reference

A container class for heterogeneous kernel implementation collections. More...

#include <opencv2/gapi/gkernel.hpp>

Public Member Functions

std::vector< GBackendbackends () const
 Lists all backends which are included into package.
 
template<typename KImpl >
void include (const cv::unite_policy up=cv::unite_policy::KEEP)
 Put a new kernel implementation KImpl into package.
 
template<typename KImpl >
bool includes () const
 Test if a particular kernel implementation KImpl is included in this kernel package.
 
template<typename KAPI >
bool includesAPI () const
 
template<typename KAPI >
GBackend lookup (const GLookupOrder &order={}) const
 Find a kernel (by its API), given the look-up order.
 
void remove (const GBackend &backend)
 Remove all kernels associated with the given backend from the package.
 
template<typename KAPI >
void remove ()
 Remove all kernels implementing the given API from the package.
 
std::size_t size () const
 Returns total number of kernels in the package (across all backends included)
 

Friends

GKernelPackage combine (const GKernelPackage &lhs, const GKernelPackage &rhs, const cv::unite_policy policy)
 Create a new package based on lhs and rhs, with unity policy defined by policy.
 

Detailed Description

A container class for heterogeneous kernel implementation collections.

GKernelPackage is a special container class which stores kernel implementations. Objects of this class are created and passed to cv::GComputation::compile() to specify which kernels to use in the compiled graph. GKernelPackage may contain kernels of different backends, e.g. be heterogeneous.

The most easy way to create a kernel package is to use function cv::gapi::kernels(). This template functions takes kernel implementations in form of type list (variadic template) and generates a kernel package atop of that.

Kernel packages can be also generated programatically, starting with an empty package (created with the default constructor) and then by populating it with kernels via call to GKernelPackage::include(). Note this method is also a template one since G-API kernel implementations are types, not objects.

Finally, two kernel packages can be combined into a new one with function cv::gapi::combine(). There are different rules apply to this process, see also cv::gapi::unite_policy for details.

Member Function Documentation

std::vector<GBackend> cv::gapi::GKernelPackage::backends ( ) const

Lists all backends which are included into package.

Returns
vector of backends
template<typename KImpl >
void cv::gapi::GKernelPackage::include ( const cv::unite_policy  up = cv::unite_policy::KEEP)
inline

Put a new kernel implementation KImpl into package.

Parameters
upunite policy to use. If the package has already implementation for this kernel (probably from another backend), and cv::unite_policy::KEEP is passed, the existing implementation remains in package; on cv::unite_policy::REPLACE all other existing implementations are first dropped from the package.
template<typename KImpl >
bool cv::gapi::GKernelPackage::includes ( ) const
inline

Test if a particular kernel implementation KImpl is included in this kernel package.

See Also
includesAPI()
Returns
true if there is such kernel, false otherwise.
template<typename KAPI >
bool cv::gapi::GKernelPackage::includesAPI ( ) const
inline

Check if package contains ANY implementation of a kernel API by API type.

template<typename KAPI >
GBackend cv::gapi::GKernelPackage::lookup ( const GLookupOrder order = {}) const
inline

Find a kernel (by its API), given the look-up order.

If order is empty, returns first suitable implementation. Throws if nothing found.

Returns
Backend which hosts matching kernel implementation.
See Also
cv::gapi::lookup_order
void cv::gapi::GKernelPackage::remove ( const GBackend backend)

Remove all kernels associated with the given backend from the package.

Does nothing if there's no kernels of this backend in the package.

Parameters
backendbackend which kernels to remove
template<typename KAPI >
void cv::gapi::GKernelPackage::remove ( )
inline

Remove all kernels implementing the given API from the package.

Does nothing if there's no kernels implementing the given interface.

std::size_t cv::gapi::GKernelPackage::size ( ) const

Returns total number of kernels in the package (across all backends included)

Returns
a number of kernels in the package

Friends And Related Function Documentation

GKernelPackage combine ( const GKernelPackage lhs,
const GKernelPackage rhs,
const cv::unite_policy  policy 
)
friend

Create a new package based on lhs and rhs, with unity policy defined by policy.

Parameters
lhs"Left-hand-side" package in the process
rhs"Right-hand-side" package in the process
policyUnite policy which is used in case of conflicts – when the same kernel API is implemented in both packages by different backends; cv::unite_policy::KEEP keeps both implementation in the resulting package, while cv::unite_policy::REPLACE gives precedence two kernels from "Right-hand-side".
Returns
a new kernel package.

The documentation for this class was generated from the following file: