add fallback case for ocl convolution
authorLi Peng <peng.li@intel.com>
Mon, 12 Feb 2018 14:52:37 +0000 (22:52 +0800)
committerLi Peng <peng.li@intel.com>
Tue, 13 Feb 2018 16:04:38 +0000 (00:04 +0800)
The ocl convolution doesn't support tensorflow padMode well.
Add fallback check if we meet this situation, it could fix the
tensorflow MobileNet SSD failure.

Signed-off-by: Li Peng <peng.li@intel.com>
modules/dnn/src/layers/convolution_layer.cpp

index 64c2212..b0ca770 100644 (file)
@@ -759,6 +759,13 @@ public:
         for (int i = 0; i < inputs.size(); ++i)
             CV_Assert(inputs[i].u != outputs[0].u);
 
+        int inpH = inputs[0].size[2];
+        int inpW = inputs[0].size[3];
+        int out_h = (inpH + 2 * pad.height - (dilation.height * (kernel.height - 1) + 1)) / stride.height + 1;
+        int out_w = (inpW + 2 * pad.width - (dilation.width * (kernel.width - 1) + 1)) / stride.width + 1;
+        if (out_h != outputs[0].size[2] || out_w != outputs[0].size[3])
+            return false;
+
         int group = inputs[0].size[1] / umat_blobs[0].size[1];
 
         if (convolutionOp.empty())