Rename gesv to solve (#18060)

Summary:
Changelog:

- Renames `gesv` to `solve` to remain consistent with `cholesky_solve`.
- Rename all tests, fix callsites
- Create a tentative alias for `solve` under the name `gesv`, and add a deprecated warning to not promote usage.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18060

Differential Revision: D14503117

Pulled By: zou3519

fbshipit-source-id: 99c16d94e5970a19d7584b5915f051c030d49ff5
This commit is contained in:
Vishwak Srinivasan
2019-03-18 16:01:02 -07:00
committed by Facebook Github Bot
parent 0eb4f7aa71
commit 421b508d55
21 changed files with 144 additions and 133 deletions

View File

@ -2018,9 +2018,9 @@ Example::
[ 4., 8., 12.]])
""")
add_docstr(torch.gesv,
add_docstr(torch.solve,
r"""
torch.gesv(B, A, out=None) -> (Tensor, Tensor)
torch.solve(B, A, out=None) -> (Tensor, Tensor)
This function returns the solution to the system of linear
equations represented by :math:`AX = B` and the LU factorization of
@ -2028,15 +2028,10 @@ A, in order as a tuple `X, LU`.
`LU` contains `L` and `U` factors for LU factorization of `A`.
`torch.gesv(B, A)` can take in 2D inputs `B, A` or inputs that are
`torch.solve(B, A)` can take in 2D inputs `B, A` or inputs that are
batches of 2D matrices. If the inputs are batches, then returns
batched outputs `X, LU`.
.. note::
The :attr:`out` keyword only supports 2D matrix inputs, that is,
`B, A` must be 2D matrices.
.. note::
Irrespective of the original strides, the returned matrices
@ -2061,7 +2056,7 @@ Example::
>>> B = torch.tensor([[4.02, 6.19, -8.22, -7.57, -3.03],
[-1.56, 4.00, -8.67, 1.75, 2.86],
[9.81, -4.09, -4.57, -8.61, 8.99]]).t()
>>> X, LU = torch.gesv(B, A)
>>> X, LU = torch.solve(B, A)
>>> torch.dist(B, torch.mm(A, X))
tensor(1.00000e-06 *
7.0977)
@ -2069,7 +2064,7 @@ Example::
>>> # Batched solver example
>>> A = torch.randn(2, 3, 1, 4, 4)
>>> B = torch.randn(2, 3, 1, 4, 6)
>>> X, LU = torch.gesv(B, A)
>>> X, LU = torch.solve(B, A)
>>> torch.dist(B, A.matmul(X))
tensor(1.00000e-06 *
3.6386)