dnn: add shared fastNorm kernel for mvn, instance norm and layer norm#24409
dnn: add shared fastNorm kernel for mvn, instance norm and layer norm#24409asmorkalov merged 10 commits intoopencv:4.xfrom
Conversation
|
It seems there are a few caffe models using mvn layer. I cannot find one in opencv_extra. There is one layer test though: |
|
@fengyuentau, AlexNet maybe? |
Seems like a no, see below: |
|
@fengyuentau, sorry, it's LRN. There are tests which use MVN: |
|
@dkurt |
|
@fengyuentau, exactly. This is for channel-wise scale/bias. |
Thank you for the clarification. This PR is all set for review. Most of the tests are green on my mac m1 except for something wrong with |
|
Should we just tune the threshold? |
| class CV_EXPORTS LayerNormLayer : public Layer | ||
| { | ||
| public: | ||
| bool hasBias; // Deprecated, preserve for compatibility |
There was a problem hiding this comment.
CV_DEPRECATED_EXTERNAL bool hasBias
dnn: add shared fastNorm kernel for mvn, instance norm and layer norm opencv#24409 Relates opencv#24378 (comment) TODO: - [x] add fastNorm - [x] refactor layer norm with fastNorm - [x] refactor mvn with fastNorm - [ ] add onnx mvn in importer (in a new PR?) - [ ] refactor instance norm with fastNorm (in another PR opencv#24378, need to merge this one first though) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
dnn: add shared fastNorm kernel for mvn, instance norm and layer norm opencv#24409 Relates opencv#24378 (comment) TODO: - [x] add fastNorm - [x] refactor layer norm with fastNorm - [x] refactor mvn with fastNorm - [ ] add onnx mvn in importer (in a new PR?) - [ ] refactor instance norm with fastNorm (in another PR opencv#24378, need to merge this one first though) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
dnn: add shared fastNorm kernel for mvn, instance norm and layer norm opencv#24409 Relates opencv#24378 (comment) TODO: - [x] add fastNorm - [x] refactor layer norm with fastNorm - [x] refactor mvn with fastNorm - [ ] add onnx mvn in importer (in a new PR?) - [ ] refactor instance norm with fastNorm (in another PR opencv#24378, need to merge this one first though) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake

Relates #24378 (comment)
TODO:
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.