Skip to content

DNN: fix possible segmentation fault error in winograd on x86#23112

Merged
opencv-pushbot merged 1 commit intoopencv:4.xfrom
zihaomu:fix_x86_winograd
Jan 9, 2023
Merged

DNN: fix possible segmentation fault error in winograd on x86#23112
opencv-pushbot merged 1 commit intoopencv:4.xfrom
zihaomu:fix_x86_winograd

Conversation

@zihaomu
Copy link
Copy Markdown
Member

@zihaomu zihaomu commented Jan 8, 2023

The segmentation fault error only happens in AVX only platform, while the CV_TRY_AVX2 is true and checkHardwareSupport(CPU_AVX2) is false. And this inconsistency will cause Winograd branch code to enter the wrong memory block. And in AVX only platform, the Winograd can not be speeded up by AVX or AVX2 which will be slower than the generic Convolution branch. So, in short term, I think disabling Winograd is a better solution.

And for a long-term solution, we should support Winograd at https://github.com/opencv/opencv/blob/4.x/modules/dnn/src/layers/layers_common.simd.hpp. After that, OpenCV can automatically generate AVX or AVX2 code for Winograd based on CPU instruction set. I will try to implement this.

detailed discussion: cocoa-xu/evision#153 (comment).

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 another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the 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

@asmorkalov asmorkalov added this to the 4.8.0 milestone Jan 9, 2023
@opencv-pushbot opencv-pushbot merged commit 65c2d6a into opencv:4.x Jan 9, 2023
@alalek alalek mentioned this pull request Jan 18, 2023
@zihaomu zihaomu mentioned this pull request Jan 28, 2023
4 tasks
john-forrest pushed a commit to idscan/opencv that referenced this pull request Feb 13, 2023
gnomesysadmins pushed a commit to GNOME/shotwell that referenced this pull request Jun 12, 2023
keighrim added a commit to clamsproject/app-east-textdetection that referenced this pull request Jun 18, 2023
keighrim added a commit to clamsproject/clams-python that referenced this pull request Jun 30, 2023
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.

Segmentation fault for cv::dnn::readNetFromONNX.forward() Segmentation fault for cv2.dnn.readNetFromDarknet.forward() on macOS with 4.7.0.68

4 participants