From 365451dab0a0f697eca0a5ca90ca019866704eda Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Wed, 17 Oct 2018 14:02:37 +0300 Subject: [PATCH] Implement getBatchSize for Intel's Inference Engine networks --- modules/dnn/src/op_inf_engine.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 23794a187d..ae837a7a0b 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -331,8 +331,18 @@ InferenceEngine::StatusCode InfEngineBackendNet::setBatchSize(size_t size, Infer size_t InfEngineBackendNet::getBatchSize() const noexcept { - CV_Error(Error::StsNotImplemented, ""); - return 0; + size_t batchSize = 0; + for (const auto& inp : inputs) + { + CV_Assert(inp.second); + std::vector dims = inp.second->getDims(); + CV_Assert(!dims.empty()); + if (batchSize != 0) + CV_Assert(batchSize == dims.back()); + else + batchSize = dims.back(); + } + return batchSize; } #if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R2)