CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 04:36:46 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/opencv/opencv.git
etag: W/"2241c433d7f66feae0d222251b4ab4a0"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=DFPvvW%2BHozbTxQ39td%2FNW1VkYy2xIqqMUBhESm8z2tg8rLzmYPSqZeh4cbDVUiqFAxSt78BMW09fZJLBS2eh1A7SLQbcBFiV1QMH5ZMKGdy6EKJBWF2s4lvaGCFbGARN7OeqpvbN3CjnEfug9N00197N00h5woQ32%2FmGWxmAz74kBU7TridilA3xGzcOHV9akDU2px2yB4AYUKAmqj99hA6PfLb%2B2U85Y5G9M%2FDu7IRaH2%2BBYE8mjNOnuWu4cN7QwnWw%2F%2F9eAfiUYDQiy1iKRQ%3D%3D--%2Bg1g9IbgJ5c4huy6--8VF2J35gKpWxguCyO7UmaQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1189338506.1753591005; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 04:36:45 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 04:36:45 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: E59E:0A61:10F141:194861:6885ACDD
Merge pull request #25644 from DaniAffCH:blockwise-quantization · opencv/opencv@2a333a6 · GitHub
Copy file name to clipboardExpand all lines: modules/dnn/src/int8layers/quantization_utils.cpp
Copy file name to clipboardExpand all lines: modules/dnn/src/onnx/onnx_importer.cpp
Copy file name to clipboardExpand all lines: modules/dnn/test/test_onnx_conformance.cpp
Copy file name to clipboardExpand all lines: modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Commit 2a333a6
authored
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 CMake1 parent 89fff35 commit 2a333a6Copy full SHA for 2a333a6
File tree
Expand file treeCollapse file tree
8 files changed
+212
-43
lines changedFilter options
- modules/dnn
- src
- int8layers
- onnx
- test
Expand file treeCollapse file tree
8 files changed
+212
-43
lines changedmodules/dnn/src/int8layers/quantization_utils.cpp
Copy file name to clipboardExpand all lines: modules/dnn/src/int8layers/quantization_utils.cpp+172-29Lines changed: 172 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 |
| - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 |
| |
20 | 23 |
| |
21 | 24 |
| |
| |||
35 | 38 |
| |
36 | 39 |
| |
37 | 40 |
| |
38 |
| - | |
39 |
| - | |
| 41 | + | |
40 | 42 |
| |
41 |
| - | |
42 |
| - | |
43 |
| - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
44 | 46 |
| |
45 |
| - | |
46 |
| - | |
| 47 | + | |
| 48 | + | |
47 | 49 |
| |
48 |
| - | |
49 |
| - | |
| 50 | + | |
| 51 | + | |
50 | 52 |
| |
51 |
| - | |
52 |
| - | |
53 |
| - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
54 | 90 |
| |
55 |
| - | |
56 | 91 |
| |
57 |
| - | |
| 92 | + | |
| 93 | + | |
58 | 94 |
| |
59 |
| - | |
60 |
| - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
61 | 133 |
| |
62 | 134 |
| |
63 | 135 |
| |
64 | 136 |
| |
65 | 137 |
| |
66 | 138 |
| |
67 | 139 |
| |
| 140 | + | |
68 | 141 |
| |
69 |
| - | |
| 142 | + | |
| 143 | + | |
70 | 144 |
| |
71 | 145 |
| |
72 | 146 |
| |
73 | 147 |
| |
74 | 148 |
| |
| 149 | + | |
| 150 | + | |
75 | 151 |
| |
76 | 152 |
| |
77 | 153 |
| |
| |||
82 | 158 |
| |
83 | 159 |
| |
84 | 160 |
| |
85 |
| - | |
| 161 | + | |
86 | 162 |
| |
87 | 163 |
| |
88 | 164 |
| |
| |||
108 | 184 |
| |
109 | 185 |
| |
110 | 186 |
| |
111 |
| - | |
| 187 | + | |
112 | 188 |
| |
113 | 189 |
| |
114 | 190 |
| |
| |||
124 | 200 |
| |
125 | 201 |
| |
126 | 202 |
| |
127 |
| - | |
| 203 | + | |
128 | 204 |
| |
129 | 205 |
| |
130 | 206 |
| |
| |||
146 | 222 |
| |
147 | 223 |
| |
148 | 224 |
| |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
149 | 258 |
| |
150 | 259 |
| |
151 | 260 |
| |
| |||
159 | 268 |
| |
160 | 269 |
| |
161 | 270 |
| |
162 |
| - | |
163 |
| - | |
| 271 | + | |
164 | 272 |
| |
165 | 273 |
| |
166 | 274 |
| |
167 | 275 |
| |
168 | 276 |
| |
169 |
| - | |
| 277 | + | |
170 | 278 |
| |
171 | 279 |
| |
172 | 280 |
| |
| |||
190 | 298 |
| |
191 | 299 |
| |
192 | 300 |
| |
| 301 | + | |
193 | 302 |
| |
194 | 303 |
| |
| 304 | + | |
195 | 305 |
| |
196 | 306 |
| |
197 | 307 |
| |
198 | 308 |
| |
199 | 309 |
| |
| 310 | + | |
200 | 311 |
| |
201 | 312 |
| |
202 | 313 |
| |
| |||
208 | 319 |
| |
209 | 320 |
| |
210 | 321 |
| |
211 |
| - | |
| 322 | + | |
212 | 323 |
| |
213 | 324 |
| |
214 | 325 |
| |
| |||
234 | 345 |
| |
235 | 346 |
| |
236 | 347 |
| |
237 |
| - | |
| 348 | + | |
238 | 349 |
| |
239 | 350 |
| |
240 | 351 |
| |
| |||
250 | 361 |
| |
251 | 362 |
| |
252 | 363 |
| |
253 |
| - | |
| 364 | + | |
254 | 365 |
| |
255 | 366 |
| |
256 | 367 |
| |
| |||
269 | 380 |
| |
270 | 381 |
| |
271 | 382 |
| |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
272 | 416 |
| |
273 | 417 |
| |
274 | 418 |
| |
| |||
281 | 425 |
| |
282 | 426 |
| |
283 | 427 |
| |
284 |
| - | |
285 |
| - | |
| 428 | + | |
286 | 429 |
| |
287 | 430 |
| |
288 | 431 |
| |
|
modules/dnn/src/onnx/onnx_importer.cpp
Copy file name to clipboardExpand all lines: modules/dnn/src/onnx/onnx_importer.cpp+11-5Lines changed: 11 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3239 | 3239 |
| |
3240 | 3240 |
| |
3241 | 3241 |
| |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
3242 | 3253 |
| |
3243 | 3254 |
| |
3244 | 3255 |
| |
| |||
3280 | 3291 |
| |
3281 | 3292 |
| |
3282 | 3293 |
| |
3283 |
| - | |
3284 |
| - | |
3285 |
| - | |
3286 |
| - | |
3287 |
| - | |
3288 | 3294 |
| |
3289 | 3295 |
| |
3290 | 3296 |
| |
|
modules/dnn/test/test_onnx_conformance.cpp
Copy file name to clipboardExpand all lines: modules/dnn/test/test_onnx_conformance.cpp+2Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
224 | 224 |
| |
225 | 225 |
| |
226 | 226 |
| |
| 227 | + | |
227 | 228 |
| |
228 | 229 |
| |
229 | 230 |
| |
| |||
569 | 570 |
| |
570 | 571 |
| |
571 | 572 |
| |
| 573 | + | |
572 | 574 |
| |
573 | 575 |
| |
574 | 576 |
| |
|
modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp
Copy file name to clipboardExpand all lines: modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp+8-4Lines changed: 8 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
565 | 565 |
| |
566 | 566 |
| |
567 | 567 |
| |
568 |
| - | |
| 568 | + | |
569 | 569 |
| |
570 |
| - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
571 | 573 |
| |
572 | 574 |
| |
573 | 575 |
| |
| |||
1348 | 1350 |
| |
1349 | 1351 |
| |
1350 | 1352 |
| |
1351 |
| - | |
| 1353 | + | |
1352 | 1354 |
| |
1353 |
| - | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1354 | 1358 |
| |
1355 | 1359 |
| |
1356 | 1360 |
| |
|
You can’t perform that action at this time.
0 commit comments