opencv/modules
Daniele Affinita 2a333a6c86
Merge pull request #25644 from DaniAffCH:blockwise-quantization
[GSoC] dnn: Blockwise quantization support #25644

This PR introduces blockwise quantization in DNN allowing the parsing of ONNX models quantized in blockwise style. In particular it modifies the `Quantize` and `Dequantize` operations. The related PR opencv/opencv_extra#1181 contains the test data.

Additional notes:
- The original quantization issue has been fixed. Previously, for 1D scale and zero-point, the operation applied was  $y = int8(x/s - z)$ instead of $y = int8(x/s + z)$. Note that the operation was already correctly implemented when the scale and zero-point were scalars. The previous implementation failed the ONNX test cases, but now all have passed successfully.  [Reference](https://github.com/onnx/onnx/blob/main/docs/Operators.md#QuantizeLinear)
- the function `block_repeat` broadcasts scale and zero-point to the input shape. It repeats all the elements of a given axis n times. This function generalizes the behavior of `repeat` from the core module which is defined just for 2 axis assuming `Mat` has 2 dimensions. If appropriate and useful, you might consider moving `block_repeat` to the core module.
- Now, the scale and zero-point can be taken as layer inputs. This increases the ONNX layers' coverage and enables us to run the ONNX test cases (previously disabled) being fully compliant with ONNX standards. Since they are now supported, I have enabled the test cases for: `test_dequantizelinear`, `test_dequantizelinear_axis`, `test_dequantizelinear_blocked`, `test_quantizelinear`, `test_quantizelinear_axis`, `test_quantizelinear_blocked` just in CPU backend. All of them pass successfully.
   
### 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
- [ ] 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
2024-07-30 14:16:08 +03:00
..
calib3d Merge pull request #25807 from spdfghi:4.x 2024-07-24 15:29:13 +03:00
core core: FileStorage: detect invalid attribute value 2024-07-26 05:55:00 +09:00
dnn Merge pull request #25644 from DaniAffCH:blockwise-quantization 2024-07-30 14:16:08 +03:00
features2d Added Java ORB test 2024-07-25 16:47:41 +03:00
flann Prevent signed integer overflow in LshTable 2024-05-24 23:47:36 +02:00
gapi Merge pull request #25817 from lamiayous:ly/extend_onnxrt_gapi_backend_handle_i32_i64_type 2024-07-12 11:38:43 +03:00
highgui highgui: Make GThread mandatory with GTK 2024-07-15 16:30:39 +02:00
imgcodecs Merge pull request #25814 from sturkmen72:numFrames 2024-07-24 17:13:15 +03:00
imgproc Merge pull request #25898 from Octopus136:issue-25853 2024-07-19 09:08:19 +03:00
java Merge pull request #25856 from alexlyulkov:al/android-optional-kotlin 2024-07-04 13:26:37 +03:00
js fix: js perf tests 2024-07-26 13:24:26 -07:00
ml Partially back-port #25075 to 4.x 2024-03-05 12:15:39 +03:00
objc fix: resolve Swift method name conflicts by adding missing namespace 2024-07-18 00:20:17 +08:00
objdetect Merge pull request #25938 from vrabaud:charuco 2024-07-24 09:27:07 +03:00
photo photo: doc: Fix window range for fastNlMeansDenoisingMulti 2024-06-21 21:04:22 +08:00
python python: prefer cv::Mat over cv::UMat in python binding 2024-07-21 10:00:29 +09:00
stitching Partially back-port #25075 to 4.x 2024-03-05 12:15:39 +03:00
ts Report used HAL to test log and xml 2024-07-23 12:03:39 +03:00
video Merge pull request #25771 from fengyuentau:vittrack_black_input 2024-06-18 12:48:28 +03:00
videoio Merge pull request #25874 from cudawarped:videoio_ffmpeg_fix_encapsulate_ts 2024-07-22 17:41:39 +03:00
world cmake: use /INCREMENTAL:NO with MSVS 2015 2023-12-07 19:46:27 +00:00