mirror of
https://github.com/ROCm/jax.git
synced 2025-04-19 05:16:06 +00:00
Slice.from_slice now works for slices with a negative start index
The implementation still requires the step to be 1, so any slice with a negative start index has size 0.
This commit is contained in:
parent
f910a0d4f8
commit
3cea57d9d1
@ -53,7 +53,7 @@ class Slice:
|
||||
start, stop, step = slc.indices(size)
|
||||
if step != 1:
|
||||
raise ValueError(f"slice must have a step of 1 (found: {step})")
|
||||
return cls(start, stop - start)
|
||||
return cls(start, max(stop - start, 0))
|
||||
|
||||
|
||||
def dslice(start: int | Array | None, size: int | None = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user