Does torch.rot90 support gradient flow?

Thank you much ahead…

Yes, it does:

x = torch.randn(2, 2, requires_grad=True)
out = torch.rot90(x)
out.grad_fn
# <Rot90Backward0 at 0x7f21c7f4e110>

out.mean().backward()
print(x.grad)
# tensor([[0.2500, 0.2500],
#         [0.2500, 0.2500]])
1 Like