Commit faab2e7
authored
[Relax] Fix the squeeze operator to behave consistently with torch (#18478)
This commit fixes the squeeze operator to behave consistently with
PyTorch
by implementing no-op behavior when squeezing dimensions that are not of
size 1.
Previously:
squeeze(x, [1]) on tensor with shape [32, 10, 5] would fail
Now:
squeeze(x, [1]) on tensor with shape [32, 10, 5] returns the original
tensor
without modification, matching PyTorch's behavior
This fixes compatibility issues when converting PyTorch models that use
squeeze with dimensions that may not always be 1 during inference."
This work was done in collaboration with guan404ming's commit d87841d.1 parent 97d78aa commit faab2e7
File tree
5 files changed
+39
-18
lines changed- include/tvm/topi
- python/tvm/relax/frontend/torch
- src/relax/op/tensor
- tests/python/relax
5 files changed
+39
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
432 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
433 | 435 | | |
434 | | - | |
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2003 | 2003 | | |
2004 | 2004 | | |
2005 | 2005 | | |
2006 | | - | |
| 2006 | + | |
2007 | 2007 | | |
2008 | 2008 | | |
2009 | 2009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1234 | 1234 | | |
1235 | 1235 | | |
1236 | 1236 | | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1244 | 1240 | | |
1245 | | - | |
1246 | 1241 | | |
1247 | 1242 | | |
1248 | 1243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5482 | 5482 | | |
5483 | 5483 | | |
5484 | 5484 | | |
5485 | | - | |
| 5485 | + | |
5486 | 5486 | | |
5487 | 5487 | | |
5488 | 5488 | | |
5489 | 5489 | | |
| 5490 | + | |
| 5491 | + | |
| 5492 | + | |
| 5493 | + | |
| 5494 | + | |
| 5495 | + | |
| 5496 | + | |
| 5497 | + | |
| 5498 | + | |
| 5499 | + | |
| 5500 | + | |
| 5501 | + | |
| 5502 | + | |
| 5503 | + | |
| 5504 | + | |
| 5505 | + | |
5490 | 5506 | | |
5491 | 5507 | | |
5492 | 5508 | | |
5493 | 5509 | | |
| 5510 | + | |
5494 | 5511 | | |
5495 | 5512 | | |
5496 | 5513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
994 | 994 | | |
995 | 995 | | |
996 | 996 | | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
1002 | 1010 | | |
1003 | 1011 | | |
1004 | 1012 | | |
| |||
0 commit comments