-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
dnn(opencl, cuda): wrong weights are used after power fusion, eltwise power fusion is mathematically wrong #17964
Copy link
Copy link
Closed
Milestone
Description
System information (version)
- OpenCV => 4.4.0, 3.4
Detailed description
opencv/modules/dnn/src/layers/convolution_layer.cpp
Lines 409 to 420 in b698d0a
| if (!activ_power.empty()) | |
| { | |
| if (activ_power->scale != 1.f || activ_power->shift != 0.f) | |
| { | |
| const int outCh = blobs[0].size[0]; | |
| fuseWeights(Mat(1, outCh, CV_32F, Scalar(activ_power->scale)), | |
| Mat(1, outCh, CV_32F, Scalar(activ_power->shift))); | |
| } | |
| power = activ_power->power; | |
| activType = OCL4DNN_CONV_FUSED_ACTIV_POWER; | |
| } |
fusedWeights and fusedBias are not updated after fusion. Same with CUDA. Here is tryFuse for reference on how it should have been:
opencv/modules/dnn/src/layers/convolution_layer.cpp
Lines 176 to 182 in b698d0a
| if (!w.empty() || !b.empty()) | |
| { | |
| fuseWeights(w, b); | |
| fusedWeights = fusedWeights || !w.empty(); | |
| fusedBias = fusedBias || (hasBias() && !w.empty()) || !b.empty(); | |
| return true; | |
| } |
Steps to reproduce
Disabled tests from #17976 can reproduce this bug. Relevant tests have // bug: https://github.com/opencv/opencv/issues/17964 comment just before applying the skip test tag.
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
Reactions are currently unavailable