Skip to content

Commit

Permalink
Improve test case for slice of an inline output
Browse files Browse the repository at this point in the history
  • Loading branch information
slyubomirsky committed Dec 10, 2024
1 parent 88cc0a8 commit efd985a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tripy/tests/frontend/trace/ops/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ def test_slice_of_inline_output(self):
assert isinstance(s, tp.Tensor)
assert isinstance(s.trace_tensor.producer, Slice)

# input 0 is a + a, so it's not one of the slice params
slice_inputs = s.trace_tensor.producer.inputs[1:]
assert len(slice_inputs) == 3

assert any(frame.function == "clamp_bound" for frame in slice_inputs[0].stack_info)
assert any(frame.function == "clamp_bound" for frame in slice_inputs[1].stack_info)
assert not any(frame.function == "clamp_bound" for frame in slice_inputs[2].stack_info)

# Consequently, the frame corresponding to the caller is at different depths.
def index_of_caller(trace_input):
for i, frame in enumerate(trace_input.stack_info):
if frame.function == TestSlice.test_slice_of_inline_output.__name__:
return i
return -1

caller_idxs = [index_of_caller(inp) for inp in slice_inputs]
assert all(idx != -1 for idx in caller_idxs)
assert caller_idxs[0] == caller_idxs[1]
assert caller_idxs[2] != caller_idxs[1]

def test_incorrect_index_size(self):
with helper.raises(
tp.TripyException,
Expand Down

0 comments on commit efd985a

Please sign in to comment.