Skip to content

Canonicalize Subtensor slices #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ricardoV94 opened this issue Nov 29, 2022 · 0 comments · Fixed by #761
Closed

Canonicalize Subtensor slices #58

ricardoV94 opened this issue Nov 29, 2022 · 0 comments · Fixed by #761

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Nov 29, 2022

Please describe the purpose of filing this issue

Unless I am missing something subtle about how slices work, I think those could all be treated equally:

import pytensor
import pytensor.tensor as at

x = pt.vector("x")
y1 = x[:-1]
y2 = x[0:-1]
y3 = x[0:-1:1]

f = pytensor.function([x], [y1, y2, y3])
pytensor.dprint(f)
DeepCopyOp [id A] ''   1
 |Subtensor{:int64:} [id B] ''   0
   |x [id C]
   |ScalarConstant{-1} [id D]
DeepCopyOp [id E] ''   3
 |Subtensor{int64:int64:} [id F] ''   2
   |x [id C]
   |ScalarConstant{0} [id G]
   |ScalarConstant{-1} [id D]
DeepCopyOp [id H] ''   5
 |Subtensor{int64:int64:int64} [id I] ''   4
   |x [id C]
   |ScalarConstant{0} [id G]
   |ScalarConstant{-1} [id D]
   |ScalarConstant{1} [id J]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant