Skip to content

Canonicalize Subtensor slices #58

Closed
@ricardoV94

Description

@ricardoV94

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]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions