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,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"); \
} \
}
......
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