Slicing a tensor with tensor
I want to make a tensor of moving window. I'm using a list comprehension, but, this is sequential making it extremely slow.
weight_list = [w[:, :, :, i : i + self.l_c] for i in range(n)]

I want to find
weight = torch.for_example.index_slice(w, start_indices=n, slice_length=self.l_c, dim=-1)

I've seen methods of &quot;indexing&quot;. But not slicing. Is there a method for this?

It seems like you are looking for unfolding of w with kernel size (1, self.l_c).
