Variable Broadcast with Slicing

Hi there, I’m trying to implement something like this
I have a tensor which consists of list of start index:

0
1
2
[torch.IntTensor of size 3]

and the end index as well:

2
1
0
[torch.IntTensor of size 3]

I have a matrix with size of [3, 5, 15]. In this case, I’m trying to access the matrix by using start and end tensor. To give you an idea, this is what I want to do mat[ :, start:end, : ]. It seems that I can’t do something like this. The closest that I can come up with is to use python loop to access each rows

for i in index:
val = mat[i, start[i]:end[i], :]

Is there any way smarter than this? Need your suggestion. Thanks a lot guys!

What you had was definitely not supported as you can’t guarantee that end[i]-start[i] is constant.