Skip to content

Commit

Permalink
[doc] Fix linalg.slogdet doc consistency issues (#51353)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #51353

Re-created from #51300 because of issues with ghstack.

This PR is part of a larger effort to ensure torch.linalg documentation is consistent (see #50287).

Updated torch.linalg.slogdet to include notes about cross-device synchronization, backend routines used and fix signature missing out argument.

Test Plan: Imported from OSS

Reviewed By: H-Huang

Differential Revision: D26148678

Pulled By: heitorschueroff

fbshipit-source-id: 40f6340226ecb72e4ec347c5606012f31f5877fb
  • Loading branch information
heitorschueroff authored and facebook-github-bot committed Feb 2, 2021
1 parent c0d58bc commit 1caed16
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions torch/linalg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,29 @@
""")

slogdet = _add_docstr(_linalg.linalg_slogdet, r"""
linalg.slogdet(input) -> (Tensor, Tensor)
linalg.slogdet(input, *, out=None) -> (Tensor, Tensor)
Calculates the sign and natural logarithm of the absolute value of a square matrix's determinant,
or of the absolute values of the determinants of a batch of square matrices :attr`input`.
or of the absolute values of the determinants of a batch of square matrices :attr:`input`.
The determinant can be computed with ``sign * exp(logabsdet)``.
Supports input of float, double, cfloat and cdouble datatypes.
.. note:: When given inputs on a CUDA device, this function synchronizes that device with the CPU.
.. note:: The determinant is computed using LU factorization. LAPACK's `getrf` is used for CPU inputs,
and MAGMA's `getrf` is used for CUDA inputs.
.. note:: For matrices that have zero determinant, this returns ``(0, -inf)``.
If :attr:`input` is batched then the entries in the result tensors corresponding to matrices with
the zero determinant have sign 0 and the natural logarithm of the absolute value of the determinant -inf.
Arguments:
Args:
input (Tensor): the input matrix of size :math:`(n, n)` or the batch of matrices of size :math:`(*, n, n)`
where `*` is one or more batch dimensions.
where :math:`*` is one or more batch dimensions.
Keyword args:
out (tuple, optional): tuple of two tensors to write the output to.
Returns:
A namedtuple (sign, logabsdet) containing the sign of the determinant and the natural logarithm
Expand Down

0 comments on commit 1caed16

Please sign in to comment.