From 3a4c88c33e614e6266963d50a373064029e25cb8 Mon Sep 17 00:00:00 2001 From: Alexander Lyulkov Date: Fri, 25 Oct 2024 13:00:15 +0300 Subject: [PATCH] Added exception when calling forward to specified layer with the new dnn engine --- modules/dnn/include/opencv2/dnn/dnn.hpp | 4 ++-- modules/dnn/src/net_impl.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/dnn/include/opencv2/dnn/dnn.hpp b/modules/dnn/include/opencv2/dnn/dnn.hpp index dd4fb0fe89..b08dd8acb7 100644 --- a/modules/dnn/include/opencv2/dnn/dnn.hpp +++ b/modules/dnn/include/opencv2/dnn/dnn.hpp @@ -1018,8 +1018,8 @@ CV__DNN_INLINE_NS_BEGIN enum EngineType { - ENGINE_CLASSIC=1, //!< Force use the new dnn engine. The engine does not support non CPU back-ends for now. - ENGINE_NEW=2, //!< Force use the old dnn engine similar to 4.x branch + ENGINE_CLASSIC=1, //!< Force use the old dnn engine similar to 4.x branch + ENGINE_NEW=2, //!< Force use the new dnn engine. The engine does not support non CPU back-ends for now. ENGINE_AUTO=3 //!< Try to use the new engine and then fall back to the classic version. }; diff --git a/modules/dnn/src/net_impl.cpp b/modules/dnn/src/net_impl.cpp index 68c8b41cfd..2c2f8ee78c 100644 --- a/modules/dnn/src/net_impl.cpp +++ b/modules/dnn/src/net_impl.cpp @@ -1178,6 +1178,9 @@ void Net::Impl::forward(std::vector>& outputBlobs, CV_Assert(!empty()); FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; + if (mainGraph) + CV_Error(Error::StsNotImplemented, "The new dnn engine doesn't support inference until a specified layer. If you want to run the whole model, please don't set the outputName argument in the forward() call. If you want to run the model until a specified layer, please use the old dnn engine"); + std::vector pins; for (int i = 0; i < outBlobNames.size(); i++) {