1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #29079 from varun-jaiswal17:feat/dnn-int8-optimization

dnn int8 optimization #29079

all_layers.hpp 
- Add float_input flag to Conv2Int8Params and Conv2Int8Layer to let the first conv accept raw FP32 input and quantize internally.

graph_fusion_qdq.cpp : 
- Fuse DQ → Sigmoid → QL into SigmoidInt8, Similarly for MAxPool.
- Fuse the input QuantizeLinear node into the first Conv2Int8.

conv2_int8_layer.cpp
- Add quantizeInterleaveBlock()


conv2_int8_kernels.simd.hpp
- Add spatial tiling to both convInt8BlockVNNI and convInt8BlockDepthwise: splits output pixels into tiles so total task count is N × ngroups × Kblk × ntiles, fully utilizing all threads even when the channel count is small.

elementwise_layers.cpp
- Widen CV_Assert to accept CV_8U in addition to CV_8S.

eltwise2_int8_layer.cpp
- Add QLinearMul support: new Mul math path for both signed and unsigned int8.
- Add numpy-style broadcast support so QLinearMul / QLinearAdd with scalar

### 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
This commit is contained in:
Varun Jaiswal
2026-05-26 14:04:47 +05:30
committed by GitHub
parent be2c53c2b7
commit bae8cb1915
7 changed files with 1158 additions and 102 deletions
@@ -395,6 +395,7 @@ CV__DNN_INLINE_NS_BEGIN
int output_zp = 0;
bool per_channel = true;
bool input_is_u8 = false;
bool float_input = false; // accept FP32 NCHW and quantize+interleave internally
// blobs[0] = quantized weights, blobs[1] = fused bias, blobs[2] = output multiplier
Mat weights, bias, outputMultiplier;
};
@@ -408,6 +409,7 @@ CV__DNN_INLINE_NS_BEGIN
int input_zp, output_zp;
float input_sc, output_sc;
bool per_channel;
bool float_input = false;
std::vector<int> strides, dilations, pads;
int ngroups;
@@ -1387,6 +1389,7 @@ CV__DNN_INLINE_NS_BEGIN
float output_sc = 1.f;
int output_zp = 0;
bool with_relu = false;
String operation = "add";
};
class CV_EXPORTS Eltwise2Int8Layer : public Layer