mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #18240 from mpashchenkov:mp/ocv-gapi-input-cnn-reshape
[G-API]: Adding reshape for CNN input. * Added CNN input IE reshape * rbs * Added unordered_set instead vector * Alignment
This commit is contained in:
committed by
GitHub
parent
ddd2447192
commit
12fa8d8444
@@ -8,6 +8,7 @@
|
||||
#define OPENCV_GAPI_INFER_IE_HPP
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <tuple> // tuple, tuple_size
|
||||
@@ -68,6 +69,9 @@ namespace detail {
|
||||
bool is_generic;
|
||||
IEConfig config;
|
||||
|
||||
std::map<std::string, std::vector<std::size_t>> reshape_table;
|
||||
std::unordered_set<std::string> layer_names_to_reshape;
|
||||
|
||||
// NB: Number of asyncrhonious infer requests
|
||||
size_t nireq;
|
||||
};
|
||||
@@ -95,6 +99,8 @@ public:
|
||||
, detail::ParamDesc::Kind::Load
|
||||
, false
|
||||
, {}
|
||||
, {}
|
||||
, {}
|
||||
, 1u} {
|
||||
};
|
||||
|
||||
@@ -106,6 +112,8 @@ public:
|
||||
, detail::ParamDesc::Kind::Import
|
||||
, false
|
||||
, {}
|
||||
, {}
|
||||
, {}
|
||||
, 1u} {
|
||||
};
|
||||
|
||||
@@ -148,6 +156,36 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Params<Net>& cfgInputReshape(std::map<std::string, std::vector<std::size_t>>&& reshape_table) {
|
||||
desc.reshape_table = std::move(reshape_table);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Params<Net>& cfgInputReshape(const std::map<std::string, std::vector<std::size_t>>& reshape_table) {
|
||||
desc.reshape_table = reshape_table;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Params<Net>& cfgInputReshape(std::string&& layer_name, std::vector<size_t>&& layer_dims) {
|
||||
desc.reshape_table.emplace(layer_name, layer_dims);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Params<Net>& cfgInputReshape(const std::string& layer_name, const std::vector<size_t>& layer_dims) {
|
||||
desc.reshape_table.emplace(layer_name, layer_dims);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Params<Net>& cfgInputReshape(std::unordered_set<std::string>&& layer_names) {
|
||||
desc.layer_names_to_reshape = std::move(layer_names);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Params<Net>& cfgInputReshape(const std::unordered_set<std::string>& layer_names) {
|
||||
desc.layer_names_to_reshape = layer_names;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::ie::backend(); }
|
||||
std::string tag() const { return Net::tag(); }
|
||||
@@ -165,13 +203,13 @@ public:
|
||||
const std::string &model,
|
||||
const std::string &weights,
|
||||
const std::string &device)
|
||||
: desc{ model, weights, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Load, true, {}, 1u}, m_tag(tag) {
|
||||
: desc{ model, weights, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Load, true, {}, {}, {}, 1u}, m_tag(tag) {
|
||||
};
|
||||
|
||||
Params(const std::string &tag,
|
||||
const std::string &model,
|
||||
const std::string &device)
|
||||
: desc{ model, {}, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Import, true, {}, 1u}, m_tag(tag) {
|
||||
: desc{ model, {}, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Import, true, {}, {}, {}, 1u}, m_tag(tag) {
|
||||
};
|
||||
|
||||
Params& pluginConfig(IEConfig&& cfg) {
|
||||
|
||||
Reference in New Issue
Block a user