joschu / cgt

Computation Graph Toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Negative step when slicing

joschu opened this issue · comments

Currently you can't do x[::-1] or x[:,::-1]. Currently x[start:stop:step] produces a GetSli Op with those arguments, however some of the logic assumes that step is positive. We have two choices

  1. generalize GetSli to work with negative step
  2. assume that if a symbolic value for step is provided, it's positive. If it's negative at runtime, throw an exception. If it's non-symbolic and negative, use a Flip Op.

Fixed in a43259d
step must be an int when you call the indexing functions.
Hopefully no one needs step to be determined at runtime.