Commit beaa5c5
[MPS] View fixes (#95323)
* [MPS] Fix the uint8 type issue with View ops kernels (#95145)
This should fix the problem in Resnet model with image artifacts due to saturation on int8 type and also the incorrect class recognition reported in #86954.
Fixes #86954
Pull Request resolved: #95145
Approved by: https://github.com/kulinseth, https://github.com/DenisVieriu97
* [MPS] Fix tensor with non-zero storage offset graph gathering (#91071)
Previously, the "can slice" flag in Placeholder constructor in `OperationUtils.mm` is conditioned on whether the numbers of dimensions of base shape and view shape are the same. This doesn't consider the situation that a view tensor could be the base tensor's sliced and then unsqueezed version, resulting in different num of dims.
For example, if we want to stack `y_mps` and `x_mps` on the last dim:
```
t_mps = torch.tensor([1, 2, 3, 4], device="mps")
x_mps = t_mps[2:] # [3, 4]
y_mps = t_mps[:2] # [1, 2]
res_mps = torch.stack((y_mps, x_mps), dim=-1)
```
the kernel will unsqueeze both of them on the last dim and then concatenate them, which is equivalent to:
```
res_mps = torch.cat((y_mps.unsqueeze(-1), x_mps.unsqueeze(-1)), dim=-1)
```
`x_mps.unsqueeze(-1)` is an unsqueezed and contiguous tensor with a storage offset, this kind of tensors should be sliceable without cloning its storage.
Fixes #87856
Fixes #91065
Pull Request resolved: #91071
Approved by: https://github.com/kulinseth
* [MPS] Fix fill_ where input tensor has a storage offset (#95113)
Fixes #94390
Apart from fixing the issue above, this PR also fixes a bug that when an input tensor can be sliced, a sliced array view is created. This array view seems to be not writable or have a different storage from the original tensor, causing incorrect results with the in-place `fill`.
Pull Request resolved: #95113
Approved by: https://github.com/kulinseth
* [MPS] Fix view op slicing for 2nd dim in case of 0 offset (#95381)
* Fix view op slicing for 2nd dim in case of 0 offset
Pull Request resolved: #95381
Approved by: https://github.com/razarmehr
---------
Co-authored-by: Ramin Azarmehr <razarmehr@apple.com>
Co-authored-by: Li-Huai (Allan) Lin <qqaatw@gmail.com>
Co-authored-by: Denis Vieriu <104024078+DenisVieriu97@users.noreply.github.com>1 parent 4bd5c1e commit beaa5c5
File tree
4 files changed
+173
-31
lines changed- aten/src/ATen/native/mps
- operations
- test
4 files changed
+173
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | | - | |
434 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
435 | 443 | | |
| 444 | + | |
436 | 445 | | |
437 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
438 | 457 | | |
439 | 458 | | |
440 | 459 | | |
441 | 460 | | |
442 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
443 | 475 | | |
444 | 476 | | |
445 | 477 | | |
446 | 478 | | |
447 | 479 | | |
448 | 480 | | |
| 481 | + | |
449 | 482 | | |
450 | | - | |
451 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
452 | 488 | | |
453 | 489 | | |
454 | 490 | | |
455 | 491 | | |
456 | | - | |
457 | | - | |
458 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
459 | 497 | | |
460 | 498 | | |
461 | 499 | | |
| |||
464 | 502 | | |
465 | 503 | | |
466 | 504 | | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
472 | 508 | | |
473 | 509 | | |
474 | 510 | | |
475 | 511 | | |
476 | 512 | | |
477 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
478 | 533 | | |
479 | 534 | | |
480 | 535 | | |
481 | | - | |
| 536 | + | |
482 | 537 | | |
483 | 538 | | |
484 | 539 | | |
485 | 540 | | |
486 | | - | |
| 541 | + | |
487 | 542 | | |
488 | 543 | | |
489 | 544 | | |
490 | 545 | | |
491 | | - | |
| 546 | + | |
492 | 547 | | |
493 | 548 | | |
494 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
495 | 552 | | |
496 | 553 | | |
497 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
498 | 560 | | |
499 | 561 | | |
500 | | - | |
501 | 562 | | |
502 | 563 | | |
503 | 564 | | |
| |||
696 | 757 | | |
697 | 758 | | |
698 | 759 | | |
699 | | - | |
| 760 | + | |
700 | 761 | | |
701 | 762 | | |
702 | 763 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
438 | 459 | | |
439 | 460 | | |
440 | 461 | | |
| |||
1806 | 1827 | | |
1807 | 1828 | | |
1808 | 1829 | | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
1809 | 1887 | | |
1810 | 1888 | | |
1811 | 1889 | | |
| |||
1899 | 1977 | | |
1900 | 1978 | | |
1901 | 1979 | | |
1902 | | - | |
| 1980 | + | |
1903 | 1981 | | |
1904 | 1982 | | |
1905 | | - | |
| 1983 | + | |
1906 | 1984 | | |
1907 | 1985 | | |
1908 | | - | |
| 1986 | + | |
1909 | 1987 | | |
1910 | 1988 | | |
1911 | | - | |
| 1989 | + | |
1912 | 1990 | | |
1913 | 1991 | | |
1914 | | - | |
| 1992 | + | |
1915 | 1993 | | |
1916 | 1994 | | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
1917 | 1998 | | |
1918 | 1999 | | |
1919 | 2000 | | |
1920 | | - | |
| 2001 | + | |
1921 | 2002 | | |
1922 | 2003 | | |
1923 | 2004 | | |
| |||
0 commit comments