Skip to content

Commit f3519fd

Browse files
zou3519soumith
authored andcommitted
Add missing trtrs, orgqr, ormqr docs (#3720)
* trtrs docs * orgqr and ormqr docs
1 parent f816029 commit f3519fd

File tree

1 file changed

+94
-11
lines changed

1 file changed

+94
-11
lines changed

torch/_torch_docs.py

Lines changed: 94 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3140,14 +3140,39 @@
31403140
[torch.FloatTensor of size 2x3]
31413141
""")
31423142

3143-
# TODO
3144-
# add_docstr(torch._C.orgqr,
3145-
# """
3146-
# """)
3143+
add_docstr(torch._C.orgqr,
3144+
"""
3145+
orgqr(a, tau) -> Tensor
3146+
3147+
Computes the orthogal matrix `Q` of a QR factorization, from the `(a, tau)` tuple
3148+
returned by :func:`torch.geqrf`.
3149+
3150+
This directly calls the underlying LAPACK function `?orgqr`.
3151+
See `?orgqr LAPACK documentation`_ for further details.
3152+
3153+
Args:
3154+
a (Tensor): The `a` from :func:`torch.geqrf`.
3155+
tau (Tensor): The `tau` from `torch.geqrf`.
3156+
3157+
.. _?orgqr LAPACK documentation:
3158+
https://software.intel.com/en-us/mkl-developer-reference-c-orgqr
3159+
3160+
""")
3161+
3162+
add_docstr(torch._C.ormqr,
3163+
"""
3164+
ormqr(a, tau, mat, left=True, transpose=False) -> (Tensor, Tensor)
31473165
3148-
# add_docstr(torch._C.ormqr,
3149-
# """
3150-
# """)
3166+
Multiplies `mat` by the orthogonal `Q` matrix of the QR factorization
3167+
formed by :func:`torch.geqrf` that is represented by `(a, tau)`.
3168+
3169+
This directly calls the underlying LAPACK function `?ormqr`.
3170+
See `?ormqr LAPACK documentation`_ for further details.
3171+
3172+
.. _?ormqr LAPACK documentation:
3173+
https://software.intel.com/en-us/mkl-developer-reference-c-ormqr
3174+
3175+
""")
31513176

31523177
add_docstr(torch._C.potrf,
31533178
"""
@@ -4723,10 +4748,68 @@
47234748
47244749
""")
47254750

4726-
# TODO
4727-
# add_docstr(torch._C.trtrs,
4728-
# """
4729-
# """)
4751+
add_docstr(torch._C.trtrs,
4752+
"""
4753+
trtrs(b, A, upper=True, transpose=False, unitriangular=False) -> (Tensor, Tensor)
4754+
4755+
Solves a system of equations with a triangular coefficient matrix `A`
4756+
and multiple right-hand sides `b`.
4757+
4758+
In particular, solves :math:`AX = b` and assumes `A` is upper-triangular
4759+
with the default keyword arguments.
4760+
4761+
This method is NOT implemented for CUDA tensors.
4762+
4763+
Args:
4764+
A (Tensor): the input triangular coefficient matrix.
4765+
b (Tensor): multiple right-hand sides. Each column of `b` is a
4766+
right-hand side for the system of equations.
4767+
upper (bool, optional): Solves the upper-triangular system
4768+
of equations if True, lower-triangular if False. Default: True.
4769+
transpose (bool, optional): If `A` should be transposed before
4770+
being sent into the solver. Default: False.
4771+
unitriangular (bool, optional): If `A` is unit triangular.
4772+
If True, the diagonal elements of `A` are assumed to be
4773+
1 and not referenced from `A`. Default: False.
4774+
4775+
Returns:
4776+
A tuple (X, M) where `M` is a clone of `A` and `X` is the solution to
4777+
`AX = b` (or whatever variant of the system of equations, depending on
4778+
the keyword arguments.)
4779+
4780+
Shape:
4781+
- A: :math:`(N, N)`
4782+
- b: :math:`(N, C)`
4783+
- output[0]: :math:`(N, C)`
4784+
- output[1]: :math:`(N, N)`
4785+
4786+
Examples::
4787+
4788+
>>> A = torch.randn(2,2).triu()
4789+
>>> A
4790+
4791+
-1.8793 0.1567
4792+
0.0000 -2.1972
4793+
[torch.FloatTensor of size 2x2]
4794+
4795+
>>> b = torch.randn(2,3)
4796+
>>> b
4797+
4798+
1.8776 -0.0759 1.6590
4799+
-0.5676 0.4771 0.7477
4800+
[torch.FloatTensor of size 2x3]
4801+
4802+
>>> torch.trtrs(b, A)
4803+
4804+
(
4805+
-0.9775 0.0223 -0.9112
4806+
0.2583 -0.2172 -0.3403
4807+
[torch.FloatTensor of size 2x3],
4808+
-1.8793 0.1567
4809+
0.0000 -2.1972
4810+
[torch.FloatTensor of size 2x2])
4811+
4812+
""")
47304813

47314814
add_docstr(torch._C.trunc,
47324815
"""

0 commit comments

Comments
 (0)