torch
torch copied to clipboard
einops
https://github.com/arogozhnikov/einops
Cool! The implementation doesn't look very complicated, I wonder how much work it would be to port it to R.
At least a subset of this can be done with torch_einsum, eg:
x <- torch_randn(10, 10)
torch_allclose(x$t(), torch_einsum("i j -> j i", x))
example in the wild of being able to do somewhat complex rearrangements declaratively: https://github.com/lucidrains/mlp-mixer-pytorch/blob/324121d19b9425b2eefe586d6e02de9f263da1e8/mlp_mixer_pytorch/permutator.py#L29