Skip to content

Commit c5702ca

Browse files
committed
Add test case
1 parent 1008567 commit c5702ca

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tripy/nvtripy/frontend/ops/slice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def get_max(a, b):
220220
# If `start` is past the end, clamp it - if we're going backwards, we need to clamp it to a valid value;
221221
# otherwise, we can clamp it out of bounds (which will yield an empty tensor):
222222
start = get_min(start, select(step >= 0, dim_size, dim_size - 1))
223-
start = get_max(start, 0) # if the start is negative and greater than the dimension size, clamp it to 0
223+
start = get_max(start, 0) # if the adjusted start is still negative, clamp it to 0
224224
else:
225225
start = default_start
226226

tripy/tests/integration/test_slice.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class TestSliceOp:
6969
((2, 3, 4), lambda t: t[None]),
7070
((2, 3, 4), lambda t: t[None, 1:2, :, None]),
7171
((2, 3, 4), lambda t: t[..., None, 0, None]),
72+
((1, 2), lambda t: t[:, -4:]), # negative start greater than dimension size
7273
],
7374
)
7475
def test_slice(self, use_constant, shape, slice_func, eager_or_compiled):

0 commit comments

Comments
 (0)