mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #18419 from TolyaTalamanov:at/generic-inference
[G-API] Introduce generic version for cv::gapi::infer * Introduce generic infer * Move Generic to infer.hpp * Removew num_outs * Fix windows warnings * Fix comments to review * Fix doxygen * Add comment * Fix comments to review * standoalone ifdef in ginfer.cpp * Fix test
This commit is contained in:
committed by
GitHub
parent
6a51e3b39a
commit
76be3529f4
@@ -78,3 +78,13 @@ const cv::GCall::Priv& cv::GCall::priv() const
|
||||
{
|
||||
return *m_priv;
|
||||
}
|
||||
|
||||
cv::GKernel& cv::GCall::kernel()
|
||||
{
|
||||
return m_priv->m_k;
|
||||
}
|
||||
|
||||
cv::util::any& cv::GCall::params()
|
||||
{
|
||||
return m_priv->m_params;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,11 @@ class GCall::Priv
|
||||
{
|
||||
public:
|
||||
std::vector<GArg> m_args;
|
||||
const GKernel m_k;
|
||||
GKernel m_k;
|
||||
|
||||
// TODO: Rename to "constructionNode" or smt to reflect its lifetime
|
||||
GNode m_node;
|
||||
cv::util::any m_params;
|
||||
|
||||
explicit Priv(const GKernel &k);
|
||||
};
|
||||
|
||||
@@ -25,3 +25,33 @@ std::vector<cv::gapi::GBackend> cv::gapi::GNetPackage::backends() const {
|
||||
for (const auto &nn : networks) unique_set.insert(nn.backend);
|
||||
return std::vector<cv::gapi::GBackend>(unique_set.begin(), unique_set.end());
|
||||
}
|
||||
|
||||
// FIXME: Inference API is currently only available in full mode
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
cv::GMat& cv::GInferInputs::operator[](const std::string& name) {
|
||||
return in_blobs[name];
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, cv::GMat>& cv::GInferInputs::getBlobs() const {
|
||||
return in_blobs;
|
||||
}
|
||||
|
||||
cv::GInferOutputs::GInferOutputs(std::shared_ptr<cv::GCall> call)
|
||||
: m_call(std::move(call)), m_info(cv::util::any_cast<InOutInfo>(&m_call->params()))
|
||||
{
|
||||
};
|
||||
|
||||
cv::GMat cv::GInferOutputs::at(const std::string& name)
|
||||
{
|
||||
auto it = out_blobs.find(name);
|
||||
if (it == out_blobs.end()) {
|
||||
// FIXME: Avoid modifying GKernel
|
||||
m_call->kernel().outShapes.push_back(cv::GShape::GMAT);
|
||||
int out_idx = static_cast<int>(out_blobs.size());
|
||||
it = out_blobs.emplace(name, m_call->yield(out_idx)).first;
|
||||
m_info->out_names.push_back(name);
|
||||
}
|
||||
return it->second;
|
||||
};
|
||||
#endif // GAPI_STANDALONE
|
||||
|
||||
Reference in New Issue
Block a user