Skip to content

OpenCL: fix cast for native_powr when half#18395

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
tomoaki0705:fixNativePow
Sep 23, 2020
Merged

OpenCL: fix cast for native_powr when half#18395
opencv-pushbot merged 1 commit intoopencv:3.4from
tomoaki0705:fixNativePow

Conversation

@tomoaki0705
Copy link
Copy Markdown
Contributor

relates #18283 #18360

Platform: Firefly RK3399 (Arm Mali-T860 OpenCL 1.2)
Compiler: GCC 5.4.0
OpenCV: Recent 3.4 ( 3e3787e )

When running opencv_test_dnn with OPENCV_DNN_OPENCL_ALLOW_ALL_DEVICES=1, one kernel fails building.

[----------] 192 tests from Layer_Test_Halide/LRN
(snip)
[ RUN      ] Layer_Test_Halide/LRN.Accuracy/1, where GetParam() = ([6, 5, 8], 3, [0.9, 1, 1.1], false, "ACROSS_CHANNELS", OCV/OCL_FP16)
OpenCL program build log: dnn/ocl4dnn_lrn
Status -11: CL_BUILD_PROGRAM_FAILURE
-D Dtype=half
<source>:38:79: error: call to 'native_powr' is ambiguous
out_off[(head - post_pad) * step] = in_off[(head - post_pad) * step] * (Dtype)native_powr((Dtype)scale_val, (Dtype)negative_beta);
                                                                              ^~~~~~~~~~~

note: candidate function
note: candidate function
note: candidate function
note: candidate function
note: candidate function
note: candidate function
<source>:47:79: error: call to 'native_powr' is ambiguous
out_off[(head - post_pad) * step] = in_off[(head - post_pad) * step] * (Dtype)native_powr((Dtype)scale_val, (Dtype)negative_beta);
                                                                              ^~~~~~~~~~~

note: candidate function
note: candidate function
note: candidate function
note: candidate function
note: candidate function
note: candidate function
error: Compiler frontend failed (error code 59)

[       OK ] Layer_Test_Halide/LRN.Accuracy/1 (20 ms)

The cast should work properly, but somehow raises an error.
Both scale_val and negative_beta are fixed as float, so casting only after the function call should be sufficient.

#define KERNEL_ARG_DTYPE float

const KERNEL_ARG_DTYPE negative_beta) {

KERNEL_ARG_DTYPE scale_val;

The opencv_test_dnn after this PR

[ RUN      ] Layer_Test_Halide/LRN.Accuracy/1, where GetParam() = ([6, 5, 8], 3, [0.9, 1, 1.1], false, "ACROSS_CHANNELS", OCV/OCL_FP16)
[       OK ] Layer_Test_Halide/LRN.Accuracy/1 (120 ms)

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@opencv-pushbot opencv-pushbot merged commit 220b371 into opencv:3.4 Sep 23, 2020
@tomoaki0705 tomoaki0705 deleted the fixNativePow branch September 23, 2020 20:42
@alalek alalek mentioned this pull request Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants