mirror of
https://github.com/opencv/opencv.git
synced 2026-09-12 13:23:03 -05:00
dnn: add HAL hook for general convolution and an RVV kernel - #29689 ### 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 ### Summary Adds cv_hal_dnn_conv32f and a RISC-V RVV implementation. The hook uses the same flat C ABI as the existing DNN hooks and is behaviour-neutral without a backend. The RVV kernel runs e32m2 at vl = K0 = 8 with 10 output positions in flight, and on wide registers packs P = VLMAX/K0 output channel blocks into one vector. It declines to the built-in when an output channel block is only partially filled: K % 8, K/ngroups % 8, or grouped C/ngroups % 8. ### Verification — K3 board, VLEN 256 and 1024, GCC 15.2 + Clang 22 - Standalone harness, 22 configurations (kernel sizes, strides, dilation, asymmetric pads, 1D/2D/3D, groups, residual, all five activations): pass at both VLENs, bit-identical to a scalar reference - opencv_test_dnn under OPENCV_FORCE_DNN_ENGINE=2: 960 passed / 29 failed, failure set identical with the hook on and off and at both VLENs; the 29 are pre-existing - Fault injection flips exactly 19 tests, confirming the hook is on the execution path ### Performance – speedup over the built-in | Network | 8 threads, VLEN 256 | 1 thread, VLEN 256 | 1 thread, VLEN 1024 | | :--- | :--- | :--- | :--- | | **SqueezeNet_v1_1** | 2.91× | 7.8× | 19.4× | | **Inception_v1** | 2.00× | 7.0× | 13.7× | | **Squeezenet** | 2.17× | 6.9× | 14.5× | | **TinyYolov2** | 2.14× | 6.8× | 14.2× | | **ResNet_50** | 2.56× | 5.7× | 9.7× | | **LResNet100E_IR** | 1.94× | 5.5× | 11.2× |