Skip to content

Commit c08f29c

Browse files
committed
dnn(opencl): fix convolution kernel w/o bias with activation
1 parent 236ad4a commit c08f29c

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ void OCL4DNNConvSpatial<Dtype>::calculateBenchmark(const UMat &bottom, UMat &ver
607607
{
608608
options_.str(""); options_.clear(); // clear contents and state flags
609609
createBasicKernel(1, 1, 1);
610+
CV_Assert(!kernelQueue.empty()); // basic kernel must be available
610611
kernel_index_ = kernelQueue.size() - 1;
611612
convolve(bottom, verifyTop, weight, bias, numImages, kernelQueue[kernel_index_]);
612613
CV_Assert(phash.find(kernelQueue[kernel_index_]->kernelName) != phash.end());
@@ -1713,6 +1714,7 @@ void OCL4DNNConvSpatial<float>::useFirstAvailable(const UMat &bottom,
17131714
tunerItems[i]->blockHeight,
17141715
tunerItems[i]->blockDepth))
17151716
{
1717+
CV_Assert(!kernelQueue.empty()); // basic kernel must be available
17161718
int kernelIdx = kernelQueue.size() - 1;
17171719
kernelConfig* config = kernelQueue[kernelIdx].get();
17181720
bool failed = false;
@@ -1883,6 +1885,7 @@ void OCL4DNNConvSpatial<float>::setupConvolution(const UMat &bottom,
18831885
CV_LOG_INFO(NULL, "fallback to basic kernel");
18841886
options_.str(""); options_.clear(); // clear contents and state flags
18851887
createBasicKernel(1, 1, 1);
1888+
CV_Assert(!kernelQueue.empty()); // basic kernel must be available
18861889
kernel_index_ = kernelQueue.size() - 1;
18871890
}
18881891
this->bestKernelConfig = kernelQueue[kernel_index_];

modules/dnn/src/opencl/conv_layer_spatial.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ __kernel void ConvolveBasic(
205205
#if APPLY_BIAS
206206
ACTIVATION_FUNCTION(convolved_image, offset, sum[kern] + bias[biasIndex + kern], biasIndex + kern);
207207
#else
208-
ACTIVATION_FUNCTION(convolved_image, offset, sum[kern], biasIndex + kern);
208+
ACTIVATION_FUNCTION(convolved_image, offset, sum[kern], kernelNum + kern);
209209
#endif
210210
}
211211
}

modules/dnn/test/test_layers.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,13 +2223,6 @@ TEST_P(ConvolutionActivationFusion, Accuracy)
22232223
if (actType == "Power" && backendId == DNN_BACKEND_OPENCV && (targetId == DNN_TARGET_OPENCL || targetId == DNN_TARGET_OPENCL_FP16))
22242224
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL);
22252225

2226-
// bug: https://github.com/opencv/opencv/issues/17953
2227-
if (actType == "ChannelsPReLU" && bias_term == false &&
2228-
backendId == DNN_BACKEND_OPENCV && (targetId == DNN_TARGET_OPENCL || targetId == DNN_TARGET_OPENCL_FP16))
2229-
{
2230-
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL);
2231-
}
2232-
22332226
Net net;
22342227
int convId = net.addLayer(convParams.name, convParams.type, convParams);
22352228
int activId = net.addLayerToPrev(activationParams.name, activationParams.type, activationParams);

0 commit comments

Comments
 (0)