Skip to content

Commit 5992c46

Browse files
committed
add fallback case for ocl convolution
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 <[email protected]>
1 parent 00d2f34 commit 5992c46

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

modules/dnn/src/layers/convolution_layer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,13 @@ class ConvolutionLayerImpl : public BaseConvolutionLayerImpl
759759
for (int i = 0; i < inputs.size(); ++i)
760760
CV_Assert(inputs[i].u != outputs[0].u);
761761

762+
int inpH = inputs[0].size[2];
763+
int inpW = inputs[0].size[3];
764+
int out_h = (inpH + 2 * pad.height - (dilation.height * (kernel.height - 1) + 1)) / stride.height + 1;
765+
int out_w = (inpW + 2 * pad.width - (dilation.width * (kernel.width - 1) + 1)) / stride.width + 1;
766+
if (out_h != outputs[0].size[2] || out_w != outputs[0].size[3])
767+
return false;
768+
762769
int group = inputs[0].size[1] / umat_blobs[0].size[1];
763770

764771
if (convolutionOp.empty())

0 commit comments

Comments
 (0)