mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
dnn/Vulkan: Refine error handle mechanism
Fallback to OPENCV backend and CPU target if catch exception from vkcom backend. Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>
This commit is contained in:
parent
7fff245f87
commit
3914c17b0d
@ -1412,9 +1412,18 @@ struct Net::Impl
|
||||
}
|
||||
|
||||
ld.skip = false;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@ -2317,9 +2326,18 @@ struct Net::Impl
|
||||
forwardInfEngine(node);
|
||||
}
|
||||
else if (preferableBackend == DNN_BACKEND_VKCOM)
|
||||
{
|
||||
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
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "Unknown backend identifier");
|
||||
|
@ -42,7 +42,8 @@ enum ShapeIdx
|
||||
{ \
|
||||
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"); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user