mirror of
https://github.com/opencv/opencv.git
synced 2026-11-21 17:03:38 -06:00
Unified DNN graph fusion behind fuseChains - #30088 Requires: https://github.com/opencv/opencv_extra/pull/1417 ### What This PR Does Follow-up to #29656, which added the backend-agnostic chain mechanism. That PR introduced it and made pointwise fusion its first consumer; this one moves the rest of the fusion onto it. - `Net::Impl::fuseBasic()` is gone. Its conv+BatchNorm, conv+activation and conv+residual branches now go through the chain mechanism. - `fuseBN` and the six other passes now run from inside `fuseChains()`, in their existing order. - `graph_fusion_basic.cpp` keeps `fuseBN()` and `fuseInstanceNormAffine()`. - New `FusionOps::foldInputScale` folds a scale sitting before a conv directly into its weights, across the dense, depthwise, grouped and MLAS-prepacked layouts. ### Results Measured on Intel Core i9-11900K | Model | 5.x | this PR | speedup | |-----------------------------|-----------|-----------|---------| | inception_v2 | 15.04 ms | 11.80 ms | 1.27 | | efficientnet-lite4 | 14.83 ms | 12.28 ms | 1.21 | | pose_estimation_mediapipe | 5.66 ms | 5.25 ms | 1.08 | | siglip_base_patch16_224 | 143.04 ms | 135.27 ms | 1.06 | | densenet121 | 25.99 ms | 24.76 ms | 1.05 | ### 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