fn
rot90
→Tensorrot90(x: Tensor, k: int = ..., dims: Sequence[int] = ...)Rotate a tensor by 90° in a chosen plane.
Applies k successive 90° rotations in the plane spanned by the
two axes dims = (d_0, d_1). The rotation direction is from
d_0 toward d_1 (counter-clockwise when those axes are
displayed as the usual (row, column) pair).
Parameters
xTensorInput tensor (any rank ).
kintNumber of 90° rotations to apply. Negative values rotate in the
opposite direction. Reduced modulo 4 — values outside
{0, 1, 2, 3} are equivalent to one of those four. Defaults
to 1.dimsSequence[int]Pair of axes defining the rotation plane. Defaults to
(0, 1).Returns
TensorTensor of the same rank as x; the two axes in dims are
permuted and one of them is flipped (their lengths swap when
k is odd).
Notes
Implemented via flip + axis-swap:
Applying rot90 four times returns the original tensor.
Examples
>>> import lucid
>>> x = lucid.tensor([[1., 2.], [3., 4.]])
>>> lucid.rot90(x)
Tensor([[2., 4.],
[1., 3.]])