Standard PyTorch einsum reduces to bmm calls in sequential order, so it’s not memory efficient if you have large intermediates.
There isn’t a built-in way, but from the experience with torch.bilinear, you might get away by computing the result “row-wise” instead of in one go.
Best regards
Thomas