Commit 3914c17b authored by Wu Zhiwen's avatar Wu Zhiwen

dnn/Vulkan: Refine error handle mechanism

Fallback to OPENCV backend and CPU target if catch exception from
vkcom backend.
Signed-off-by: 's avatarWu Zhiwen <zhiwen.wu@intel.com>
parent 7fff245f
...@@ -1412,8 +1412,17 @@ struct Net::Impl ...@@ -1412,8 +1412,17 @@ struct Net::Impl
} }
ld.skip = false; ld.skip = false;
ld.backendNodes[DNN_BACKEND_VKCOM] =
layer->initVkCom(ld.inputBlobsWrappers); try
{
ld.backendNodes[DNN_BACKEND_VKCOM] =
layer->initVkCom(ld.inputBlobsWrappers);
}
catch (const cv::Exception& e)
{
CV_LOG_ERROR(NULL, "initVkCom failed, fallback to CPU implementation. " << e.what());
ld.backendNodes[DNN_BACKEND_VKCOM] = Ptr<BackendNode>();
}
} }
#endif #endif
} }
...@@ -2318,7 +2327,16 @@ struct Net::Impl ...@@ -2318,7 +2327,16 @@ struct Net::Impl
} }
else if (preferableBackend == DNN_BACKEND_VKCOM) else if (preferableBackend == DNN_BACKEND_VKCOM)
{ {
forwardVkCom(ld.outputBlobsWrappers, node); try
{
forwardVkCom(ld.outputBlobsWrappers, node);
}
catch (const cv::Exception& e)
{
CV_LOG_ERROR(NULL, "forwardVkCom failed, fallback to CPU implementation. " << e.what());
it->second = Ptr<BackendNode>();
forwardLayer(ld);
}
} }
else else
{ {
......
...@@ -42,7 +42,8 @@ enum ShapeIdx ...@@ -42,7 +42,8 @@ enum ShapeIdx
{ \ { \
if (f != VK_SUCCESS) \ if (f != VK_SUCCESS) \
{ \ { \
CV_LOG_WARNING(NULL, "Vulkan check failed"); \ CV_LOG_ERROR(NULL, "Vulkan check failed, result = " << f); \
CV_Error(Error::StsError, "Vulkan check failed"); \
} \ } \
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment