-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
OpenCL: kernel build failure #18433
Description
System information (version)
- OpenCV => recent 3.4 ( 220b371 ) / master ( f584c6d )
- Operating System / Platform => Firefly RK3399 Ubuntu 16.04 (Aarch64)
- Compiler => GCC 5.4.0
- OpenCL => 1.2
Detailed description
Some FP16 inference is disabled on purpose on non-intel platform
Setting OPENCV_DNN_OPENCL_ALLOW_ALL_DEVICES to true will avoid this bypass and kicks the kernel for FP16.
Also, enabling dnn_skip_ocl_fp16, dnn_skip_ocl, dnn_skip_ie_ocl and dnn_skip_ie_ocl_fp16 shows one issue in the kernel build.
OpenCL program build log: dnn/conv_layer_spatial
Status -11: CL_BUILD_PROGRAM_FAILURE
-D TYPE=1 -D Dtype=float -D Dtype2=float2 -D Dtype4=float4 -D Dtype8=float8 -D Dtype16=float16 -D as_Dtype=as_float -D as_Dtype2=as_float2 -D as_Dtype4=as_float4 -D as_Dtype8=as_float8 -D KERNEL_WIDTH=3 -D KERNEL_HEIGHT=3 -D STRIDE_X=1 -D STRIDE_Y=1 -D DILATION_X=1 -D DILATION_Y=1 -D KERNEL_BASIC -cl-fast-relaxed-math -D ConvolveBasic=BASIC_k3x3_cn16_g1_s1x1_d1x1_b0_in16x16_p1x1_num2_M16_activ2_eltwise0_FP32_4_1_1_1 -D CHANNELS=16 -D APPLY_BIAS=0 -D OUTPUT_Z=16 -D ZPAR=1 -D FUSED_CONV_PRELU=1
<source>:157:57: error: use of undeclared identifier 'biasIndex'
ACTIVATION_FUNCTION(convolved_image, offset, sum[kern], biasIndex + kern);
^
<source>:35:53: note: expanded from here
(_dst_)[(_offset_)] = ACTIVATION_RELU_FUNCTION(_x_, _channel_); \
^
<source>:11:101: note: expanded from here
#define ACTIVATION_RELU_FUNCTION(x, c) ((Dtype)(x) > 0 ? (Dtype)(x) : ((Dtype)(x) * (negative_slope[c])))
^
error: Compiler frontend failed (error code 59)
I understand that the FP16 is not fully supported on non Intel platform, but this kernel build failure is a purely syntax error.
Regardless the value of APPLY_BIAS, the parameter biasIndex will be used
opencv/modules/dnn/src/opencl/conv_layer_spatial.cl
Lines 205 to 209 in eec468f
| #if APPLY_BIAS | |
| ACTIVATION_FUNCTION(convolved_image, offset, sum[kern] + bias[biasIndex + kern], biasIndex + kern); | |
| #else | |
| ACTIVATION_FUNCTION(convolved_image, offset, sum[kern], biasIndex + kern); | |
| #endif |
when biasIndex in only defined with APPLY_BIAS
opencv/modules/dnn/src/opencl/conv_layer_spatial.cl
Lines 170 to 172 in eec468f
| #if APPLY_BIAS | |
| const int biasIndex = bias_offset + kernelNum; | |
| #endif |
Looks like this biasIndex was introduced in to ACTIVATION_FUNCTION in #9847 when ACTIVATION_FUNCTION was now related with ACTIVATION_RELU_FUNCTION and FUSED_CONV_PRELU, but not considering the APPLY_BIAS
I need to undo this APPLY_BIAS but it's bit tricky, so I'll just report the issue here.
Steps to reproduce
On Firefly RK3399
$ mkdir build
$ cd build
$ cmake -DOPENCV_EXTRA_MODULES_PATH=/xxx/opencv_contrib/modules -DBUILD_EXAMPLES=true -DOPENCV_ENABLE_NONFREE=true ..
$ make -j 4 all
$ export OPENCV_DNN_OPENCL_ALLOW_ALL_DEVICES=true
$ export OPENCV_TEST_DATA_PATH=/opencv_extra/testdata
$ ./bin/opencv_test_dnn --test_tag_enable=dnn_skip_ocl --gtest_filter=TestLayerFusion/ConvolutionActivationFusion.Accuracy/6
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
answers.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc