Hi,
I found the semantic of strided_slice unclear, even after reading the c++ code. In particular, when stride < 0
, it seems end
is default to 0, causing the first element to be excluded by default. Is this a bug or intended behavior? Code snippet to reproduce:
from tvm import relay
from tvm.relay.frontend.common import infer_type
x = relay.var('x', shape=(10,))
y = relay.strided_slice(x, begin=[], end=[], strides=[-1])
f = relay.Function([x], y)
print(infer_type(f))
produces
fn (%x: Tensor[(10), float32]) -> Tensor[(9), float32] {
strided_slice(%x, begin=[], end=[], strides=[-1], axes=None) /* ty=Tensor[(9), float32] */
}
The size is shrunken from 10 to 9. PS, it looks like this LOC is assigning 0 to end
: tvm/transform.h at main · apache/tvm · GitHub.