work around of the test failure of opencv_test_dnn

* let OpenCL kernel run only on Intel GPU
  * brush up the workaround based on 9a2b028 from alalek
This commit is contained in:
Tomoaki Teshima 2018-05-16 19:23:19 +09:00
parent 9dc2005251
commit 3f5347dd7a

View File

@ -62,6 +62,8 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
// this option is useful to run valgrind memory errors detection // this option is useful to run valgrind memory errors detection
static bool DNN_DISABLE_MEMORY_OPTIMIZATIONS = utils::getConfigurationParameterBool("OPENCV_DNN_DISABLE_MEMORY_OPTIMIZATIONS", false); static bool DNN_DISABLE_MEMORY_OPTIMIZATIONS = utils::getConfigurationParameterBool("OPENCV_DNN_DISABLE_MEMORY_OPTIMIZATIONS", false);
static bool DNN_OPENCL_ALLOW_ALL_DEVICES = utils::getConfigurationParameterBool("OPENCV_DNN_OPENCL_ALLOW_ALL_DEVICES", false);
using std::vector; using std::vector;
using std::map; using std::map;
using std::make_pair; using std::make_pair;
@ -847,12 +849,22 @@ struct Net::Impl
if (!netWasAllocated || this->blobsToKeep != blobsToKeep_) if (!netWasAllocated || this->blobsToKeep != blobsToKeep_)
{ {
#ifndef HAVE_OPENCL
if (preferableBackend == DNN_BACKEND_DEFAULT && preferableTarget == DNN_TARGET_OPENCL) if (preferableBackend == DNN_BACKEND_DEFAULT && preferableTarget == DNN_TARGET_OPENCL)
#ifndef HAVE_OPENCL
{ {
CV_LOG_WARNING(NULL, "DNN: OpenCL target is not available in this OpenCV build, switching to CPU.") CV_LOG_WARNING(NULL, "DNN: OpenCL target is not available in this OpenCV build, switching to CPU.");
preferableTarget = DNN_TARGET_CPU; preferableTarget = DNN_TARGET_CPU;
} }
#else
{
if (!DNN_OPENCL_ALLOW_ALL_DEVICES
&& !(ocl::Device::getDefault().isIntel() && ocl::Device::getDefault().type() == ocl::Device::TYPE_GPU) // Current implementation is only valid for Intel GPU (#11494)
)
{
CV_LOG_WARNING(NULL, "DNN: OpenCL target is not supported with current OpenCL device (tested with Intel GPUs only), switching to CPU.");
preferableTarget = DNN_TARGET_CPU;
}
}
#endif #endif
clear(); clear();