Deprecated torch lstsq
simonamaggio opened this issue · 1 comments
simonamaggio commented
GradMatch code for orthogonal matching pursuit (on GPU) uses torch.lstsq
which has been deprecated.
This line:
x_i, _ = torch.lstsq(torch.matmul(A_i, b).view(-1, 1), temp)
Should be replaced by:
lstsq_out = torch.linalg.lstsq(temp, torch.matmul(A_i, b).view(-1, 1))
x_i = torch.cat((lstsq_out.solution, lstsq_out.residuals))
Here is additional information:
# UserWarning: torch.lstsq is deprecated in favor of torch.linalg.lstsq and has been removed.
# torch.linalg.lstsq has reversed arguments and does not return the QR decomposition in the returned tuple (although it returns other information about the problem).
# To get the qr decomposition consider using torch.linalg.qr.
# The returned solution in torch.lstsq stored the residuals of the solution in the last m - n columns of the returned value whenever m > n.
# In torch.linalg.lstsq, the residuals in the field 'residuals' of the returned named tuple.
# The unpacking of the solution, as in
# X = torch.lstsq(B, A)[0][:A.size(1)]
# should be replaced with
# X = torch.linalg.lstsq(A, B).solution
Chengcheng-Guo commented
Appreciate your information! We'll update this part of the code soon.