Tf.reverse equivalent operation in Pytorch?

Hi, I was looking for a tensor operation in PyTorch to reverse the order of values on specific axis. Suppose there is a tensor X of size n x m x k. After the reverse operation on the second axis, the value of X_reversed[0, -1, 0] must be the same as X[0, 0, 0].

I found the exact method in TensorFlow, i.e., tf.reverse (tf.reverse  |  TensorFlow Core v2.6.0), however, I could not found any equivalent method in PyTorch.

I achieved what I need to do by converting a PT tensor to numpy, apply tf.reverse, covert back to numpy, then copied to PT tensor. Though it’s working, I felt it’s really patchworking where it should not be like this mess and I believe it would have been easier if PyTorch had an equivalent implementation already.

If anyone know why the operation is not available in PyTorch (maybe suggested before and rejected?) or if there exists a PyTorch method I just missed, please let me know.

Would something like flip work for you: torch.flip — PyTorch 1.9.1 documentation ?

Oh, I totally missed it! Thanks @eqy !