1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #19617 from smirnov-alexey:as/extend_kernel_package_api

G-API: Extend GKernelPackage and serialization API

* Extend GKernelPackage API

* Adding tests

* Extend serialization API

* Address review comments
This commit is contained in:
Alexey Smirnov
2021-03-10 18:58:34 +03:00
committed by GitHub
parent 04d907fb97
commit ddd2447192
8 changed files with 100 additions and 7 deletions
+20 -1
View File
@@ -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
#ifndef OPENCV_GAPI_GKERNEL_HPP
@@ -517,6 +517,13 @@ namespace gapi {
*/
const std::vector<GTransform>& get_transformations() const;
/**
* @brief Returns vector of kernel ids included in the package
*
* @return vector of kernel ids included in the package
*/
std::vector<std::string> get_kernel_ids() const;
/**
* @brief Test if a particular kernel _implementation_ KImpl is
* included in this kernel package.
@@ -606,6 +613,18 @@ namespace gapi {
includeHelper<KImpl>();
}
/**
* @brief Adds a new kernel based on it's backend and id into the kernel package
*
* @param backend backend associated with the kernel
* @param kernel_id a name/id of the kernel
*/
void include(const cv::gapi::GBackend& backend, const std::string& kernel_id)
{
removeAPI(kernel_id);
m_id_kernels[kernel_id] = std::make_pair(backend, GKernelImpl{{}, {}});
}
/**
* @brief Lists all backends which are included into package
*
+9 -1
View File
@@ -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) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
#ifndef OPENCV_GAPI_S11N_HPP
#define OPENCV_GAPI_S11N_HPP
@@ -24,6 +24,8 @@ namespace detail {
GAPI_EXPORTS cv::GRunArgs getRunArgs(const std::vector<char> &p);
GAPI_EXPORTS std::vector<std::string> getVectorOfStrings(const std::vector<char> &p);
template<typename... Types>
cv::GCompileArgs getCompileArgs(const std::vector<char> &p);
@@ -42,6 +44,7 @@ T deserialize(const std::vector<char> &p);
GAPI_EXPORTS std::vector<char> serialize(const cv::GCompileArgs&);
GAPI_EXPORTS std::vector<char> serialize(const cv::GMetaArgs&);
GAPI_EXPORTS std::vector<char> serialize(const cv::GRunArgs&);
GAPI_EXPORTS std::vector<char> serialize(const std::vector<std::string>&);
template<> inline
cv::GComputation deserialize(const std::vector<char> &p) {
@@ -58,6 +61,11 @@ cv::GRunArgs deserialize(const std::vector<char> &p) {
return detail::getRunArgs(p);
}
template<> inline
std::vector<std::string> deserialize(const std::vector<char> &p) {
return detail::getVectorOfStrings(p);
}
template<typename T, typename... Types> inline
typename std::enable_if<std::is_same<T, GCompileArgs>::value, GCompileArgs>::
type deserialize(const std::vector<char> &p) {