Remove deprecated torch.eig (#70982)

The time has come to remove deprecated linear algebra related functions. This PR removes `torch.eig`.

cc @jianyuh @nikitaved @pearu @mruberry @walterddr @IvanYashchuk @xwang233 @Lezcano
Pull Request resolved: https://github.com/pytorch/pytorch/pull/70982
Approved by: https://github.com/Lezcano, https://github.com/malfet
This commit is contained in:
Ivan Yashchuk
2022-09-09 21:31:57 +00:00
committed by PyTorch MergeBot
parent c4a5255df7
commit 01c54ad6de
27 changed files with 27 additions and 714 deletions

View File

@ -3999,92 +3999,6 @@ Example::
""",
)
add_docstr(
torch.eig,
r"""
eig(input, eigenvectors=False, *, out=None) -> (Tensor, Tensor)
Computes the eigenvalues and eigenvectors of a real square matrix.
.. note::
Since eigenvalues and eigenvectors might be complex, backward pass is supported only
if eigenvalues and eigenvectors are all real valued.
When :attr:`input` is on CUDA, :func:`torch.eig() <torch.eig>` causes
host-device synchronization.
.. warning::
:func:`torch.eig` is deprecated in favor of :func:`torch.linalg.eig`
and will be removed in a future PyTorch release.
:func:`torch.linalg.eig` returns complex tensors of dtype `cfloat` or `cdouble`
rather than real tensors mimicking complex tensors.
``L, _ = torch.eig(A)`` should be replaced with
.. code :: python
L_complex = torch.linalg.eigvals(A)
``L, V = torch.eig(A, eigenvectors=True)`` should be replaced with
.. code :: python
L_complex, V_complex = torch.linalg.eig(A)
Args:
input (Tensor): the square matrix of shape :math:`(n \times n)` for which the eigenvalues and eigenvectors
will be computed
eigenvectors (bool): ``True`` to compute both eigenvalues and eigenvectors;
otherwise, only eigenvalues will be computed
Keyword args:
out (tuple, optional): the output tensors
Returns:
(Tensor, Tensor): A namedtuple (eigenvalues, eigenvectors) containing
- **eigenvalues** (*Tensor*): Shape :math:`(n \times 2)`. Each row is an eigenvalue of ``input``,
where the first element is the real part and the second element is the imaginary part.
The eigenvalues are not necessarily ordered.
- **eigenvectors** (*Tensor*): If ``eigenvectors=False``, it's an empty tensor.
Otherwise, this tensor of shape :math:`(n \times n)` can be used to compute normalized (unit length)
eigenvectors of corresponding eigenvalues as follows.
If the corresponding `eigenvalues[j]` is a real number, column `eigenvectors[:, j]` is the eigenvector
corresponding to `eigenvalues[j]`.
If the corresponding `eigenvalues[j]` and `eigenvalues[j + 1]` form a complex conjugate pair, then the
true eigenvectors can be computed as
:math:`\text{true eigenvector}[j] = eigenvectors[:, j] + i \times eigenvectors[:, j + 1]`,
:math:`\text{true eigenvector}[j + 1] = eigenvectors[:, j] - i \times eigenvectors[:, j + 1]`.
Example::
Trivial example with a diagonal matrix. By default, only eigenvalues are computed:
>>> a = torch.diag(torch.tensor([1, 2, 3], dtype=torch.double))
>>> e, v = torch.eig(a)
>>> e
tensor([[1., 0.],
[2., 0.],
[3., 0.]], dtype=torch.float64)
>>> v
tensor([], dtype=torch.float64)
Compute also the eigenvectors:
>>> e, v = torch.eig(a, eigenvectors=True)
>>> e
tensor([[1., 0.],
[2., 0.],
[3., 0.]], dtype=torch.float64)
>>> v
tensor([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]], dtype=torch.float64)
""",
)
add_docstr(
torch.eq,
r"""