It is an old post, but in case someone gets here looking to reverse a Torch tensor, I use the following:
In your case, imagine a tensor x like
x = torch.Tensor(batch_size, dim, seq_len)
which you want to reverse in the x dimension.
The code to do so is:
x = x:index(3 ,torch.linspace(seq_len,1,seq_len):long()) -- the first argument to index is 3 because you want to reverse the 3rd dimension
This code is using the index function:
https://github.com/torch/torch7/blob/master/doc/tensor.md#tensor-indexdim-indexand then creating a tensor of indexes in reverse order with linspace.
Note that the index vector is casted to LongTensor type with :long() because it is the required type for the index function.