diff --git a/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp b/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp index cade72590e..af58cad833 100644 --- a/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp +++ b/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp @@ -379,6 +379,8 @@ bool OCL4DNNConvSpatial::Forward(const UMat& bottom, { num_ = numImages; prepareKernel(bottom, top, weight, bias, numImages); + if (bestKernelConfig.empty()) + return false; return convolve(bottom, top, weight, bias, numImages, bestKernelConfig, cv::ocl::Queue::getDefault()); }