Skip to content

Commit 96c00f7

Browse files
assert Deepcopy input while canonicalising subtensor slices
1 parent dd0aed7 commit 96c00f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/tensor/rewriting/test_subtensor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,10 @@ def test_slice_canonicalize():
24112411
# Test case 1
24122412
y = x[0:None, 0:5, 0:7, 0:9:1]
24132413
f = pytensor.function([x], y, allow_input_downcast=True)
2414+
2415+
# Get the DeepCopy input and assert that the Op is a DeepCopy
24142416
test_y = f.maker.fgraph.outputs[0].owner.inputs[0]
2417+
assert isinstance(f.maker.fgraph.outputs[0].owner.op, DeepCopyOp)
24152418

24162419
expected_y = x[None:None:None, None:None:None, None:7:None]
24172420

@@ -2427,7 +2430,10 @@ def test_slice_canonicalize():
24272430
# Test case 2
24282431
y1 = x[0:-1, 0:5, 0:7, 0:-1:-1]
24292432
f1 = pytensor.function([x], y1, allow_input_downcast=True)
2433+
2434+
# Get the DeepCopy input and assert that the Op is a DeepCopy
24302435
test_y1 = f1.maker.fgraph.outputs[0].owner.inputs[0]
2436+
assert isinstance(f1.maker.fgraph.outputs[0].owner.op, DeepCopyOp)
24312437

24322438
expected_y1 = x[None:-1:None, None:None:None, None:7:None, None:-1:-1]
24332439

0 commit comments

Comments
 (0)