Skip to content

Commit 14c4eaa

Browse files
committed
Don't return useless subtensor for local_useless_slice
1 parent 2266bd8 commit 14c4eaa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pytensor/tensor/rewriting/subtensor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ def local_useless_slice(fgraph, node):
351351
new_idxs[dim] = slice(start, stop, step)
352352

353353
if change_flag or ((last_useful_idx + 1) < len(idxs)):
354-
out = x[tuple(new_idxs[: last_useful_idx + 1])]
354+
new_idxs = tuple(new_idxs[: last_useful_idx + 1])
355+
out = x[new_idxs] if new_idxs else x
355356
# Copy over previous output stacktrace
356357
copy_stack_trace(node.outputs, out)
357358
return [out]

0 commit comments

Comments
 (0)