mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 09:25:45 +08:00
![]() dnn: try improving performance of Attention layer #25076 Checklist: - [x] Use `Mat` over `Mat::zeros` for temporary buffer in forward - [x] Use layer internal buffer over temporary Mat buffer - [x] Try a single fastGemmBatch on the Q/K/V calculation Performance: Performance test case is `Layer_Attention.VisionTransformer/0`, which has input of shape {1, 197, 768}, weight of shape {768, 2304} and bias {2304}. Data is in millisecond. | | macOS 14.2.1, Apple M1 | Ubuntu 22.04.2, Intel i7 12700K | | - | - | - | | Current | 10.96 | 1.58 | | w/ Mat | 6.27 | 1.41 | | w/ Internals | 5.87 | 1.38 | | w/ fastGemmBatch | 6.12 | 2.14 | ### 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 |
||
---|---|---|
.. | ||
calib3d | ||
core | ||
dnn | ||
features2d | ||
flann | ||
gapi | ||
highgui | ||
imgcodecs | ||
imgproc | ||
java | ||
js | ||
ml | ||
objc | ||
objdetect | ||
photo | ||
python | ||
stitching | ||
ts | ||
video | ||
videoio | ||
world |