Solving a tensor linear system

Hey guys, I am trying to solve a tensor linear system using PyTorch. That being said, I’m looking for something similar to torch.solve but can handle tensors. Of course, I can reshape the pppp tensor to p^2p^2 matrix, and p*p tensor to p^2 vector to solve, but it will slow the code by far I assume? Thanks.

Actually the operation view applied to a tensor is almost free, since it leaves the storage intact:

import torch
x = torch.rand(2, 2, 2, 2)
y = x.view(4, 4)
print(y.data_ptr() == x.data_ptr()) # <- prints True

if it’s almost free, it’s GREAT!