Commit e5c6f33
[WebNN] Reject conv2d/pool2d/convTranspose2d strides, dilations and
filters that exceed the usable extent
conv2d, pooling and convTranspose2d take strides and dilations as
unsigned long and the only validation was a != 0 check on each value.
When the input spatial size and the filter/window are 1x1, the derived
output size collapses to 1 for any stride/dilation, so an arbitrarily
large value survives all output-size math and is serialized
verbatim into the backend graph, even though it is semantically
equivalent to a much smaller value and cannot legitimately arise.
This CL adds an upper bound in the output-size validation:
- Forward conv2d and pool2d: reject a stride or dilation larger than
the padded input spatial size. Padding is included so that valid
padded windows are not rejected. A value larger than the padded
input can place the window at most once, so it is always equivalent
to a smaller value.
- Forward conv2d and pool2d: reject an effective (dilated) filter
window larger than the padded input spatial size. when the
effective filter size exceeds the padded input, the window can
never be fully placed, so the operation has no valid output.
- ConvTranspose2d: a stride or dilation larger than the output size
can only arise when input==1 or filter==1, where its value is a pure
no-op. Reject such values so that unbounded uint32 strides/dilations
can not flow unchecked into backends
This CL also adds WPTs for the new checks.
There is a related discussion about this in the spec issue[1].
[1] webmachinelearning/webnn#928 (comment)
Fixed: 546106051
Change-Id: I37eea4793cbd42d2e80aab23e68c127ff0f5381d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8250961
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Phillis Tang <phillis@chromium.org>
Reviewed-by: Hu, Ningxin <ningxin.hu@intel.com>
Commit-Queue: Wang, Wei4 <wei4.wang@intel.com>
Cr-Commit-Position: refs/heads/main@{#1682769}1 parent 389fb4a commit e5c6f33
3 files changed
Lines changed: 161 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
552 | 613 | | |
553 | 614 | | |
554 | 615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
552 | 592 | | |
553 | 593 | | |
554 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
310 | 370 | | |
311 | 371 | | |
312 | 372 | | |
| |||
0 commit comments