Commit b1f27e9
Fix Nx.slice crash on scalar tensor
Slicing a scalar tensor is a valid no-op — return the tensor
unchanged when shape is {} and start_indices/lengths are empty.
The check is done in Nx.slice itself (not in BinaryBackend) so all
backends get the fix without needing separate implementations.
NumPy does the same: np.array(5)[()] returns 5.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c9406de commit b1f27e9
3 files changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13670 | 13670 | | |
13671 | 13671 | | |
13672 | 13672 | | |
| 13673 | + | |
| 13674 | + | |
| 13675 | + | |
| 13676 | + | |
| 13677 | + | |
| 13678 | + | |
| 13679 | + | |
| 13680 | + | |
| 13681 | + | |
13673 | 13682 | | |
13674 | 13683 | | |
13675 | 13684 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1849 | 1849 | | |
1850 | 1850 | | |
1851 | 1851 | | |
1852 | | - | |
1853 | | - | |
1854 | 1852 | | |
1855 | 1853 | | |
1856 | 1854 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3585 | 3585 | | |
3586 | 3586 | | |
3587 | 3587 | | |
3588 | | - | |
| 3588 | + | |
3589 | 3589 | | |
3590 | 3590 | | |
3591 | 3591 | | |
0 commit comments