Merge pull request #26367 from alexlyulkovЖal/forward-to-layer-assert

Added exception when calling forward to specified layer with the new dnn engine
This commit is contained in:
Alexander Smorkalov 2024-10-25 15:22:09 +03:00 committed by GitHub
commit 05e7988e9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -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.
};

View File

@ -1178,6 +1178,9 @@ void Net::Impl::forward(std::vector<std::vector<Mat>>& 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<LayerPin> pins;
for (int i = 0; i < outBlobNames.size(); i++)
{