Skip to content

Commit 296af1b

Browse files
committed
fix conflict
1 parent 099b9c2 commit 296af1b

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

python/paddle/_paddle_docs.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,151 @@ def isnan(
515515
# lousiyu
516516

517517
# zhengshijie
518+
add_doc_and_signature(
519+
"tril",
520+
r"""
521+
Returns the lower triangular part of a matrix (2-D tensor) or batch
522+
of matrices :attr:`x`, the other elements of the result tensor are set
523+
to 0. The lower triangular part of the matrix is defined as the elements
524+
on and below the diagonal.
525+
526+
Args:
527+
x (Tensor): The input x which is a Tensor.
528+
Support data types: ``bool``, ``float64``, ``float32``, ``int32``, ``int64``, ``complex64``, ``complex128``.
529+
diagonal (int, optional): The diagonal to consider, default value is 0.
530+
If :attr:`diagonal` = 0, all elements on and below the main diagonal are
531+
retained. A positive value includes just as many diagonals above the main
532+
diagonal, and similarly a negative value excludes just as many diagonals below
533+
the main diagonal. The main diagonal are the set of indices
534+
:math:`\{(i, i)\}` for :math:`i \in [0, \min\{d_{1}, d_{2}\} - 1]` where
535+
:math:`d_{1}, d_{2}` are the dimensions of the matrix.
536+
name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
537+
out(Tensor, optional): The output tensor.
538+
539+
Returns:
540+
Tensor: Results of lower triangular operation by the specified diagonal of input tensor x,
541+
it's data type is the same as x's Tensor.
542+
543+
Examples:
544+
.. code-block:: python
545+
546+
>>> import paddle
547+
548+
>>> data = paddle.arange(1, 13, dtype="int64").reshape([3,-1])
549+
>>> print(data)
550+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
551+
[[1 , 2 , 3 , 4 ],
552+
[5 , 6 , 7 , 8 ],
553+
[9 , 10, 11, 12]])
554+
555+
>>> tril1 = paddle.tril(data)
556+
>>> print(tril1)
557+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
558+
[[1 , 0 , 0 , 0 ],
559+
[5 , 6 , 0 , 0 ],
560+
[9 , 10, 11, 0 ]])
561+
562+
>>> # example 2, positive diagonal value
563+
>>> tril2 = paddle.tril(data, diagonal=2)
564+
>>> print(tril2)
565+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
566+
[[1 , 2 , 3 , 0 ],
567+
[5 , 6 , 7 , 8 ],
568+
[9 , 10, 11, 12]])
569+
570+
>>> # example 3, negative diagonal value
571+
>>> tril3 = paddle.tril(data, diagonal=-1)
572+
>>> print(tril3)
573+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
574+
[[0 , 0 , 0 , 0 ],
575+
[5 , 0 , 0 , 0 ],
576+
[9 , 10, 0 , 0 ]])
577+
""",
578+
"""
579+
def tril(
580+
x: Tensor,
581+
diagonal: int = 0,
582+
name: str | None = None,
583+
*,
584+
out: Tensor | None = None,
585+
) -> Tensor
586+
""",
587+
)
588+
589+
590+
add_doc_and_signature(
591+
"triu",
592+
r"""
593+
Return the upper triangular part of a matrix (2-D tensor) or batch of matrices
594+
:attr:`x`, the other elements of the result tensor are set to 0.
595+
The upper triangular part of the matrix is defined as the elements on and
596+
above the diagonal.
597+
598+
Args:
599+
x (Tensor): The input x which is a Tensor.
600+
Support data types: ``float64``, ``float32``, ``int32``, ``int64``, ``complex64``, ``complex128``.
601+
diagonal (int, optional): The diagonal to consider, default value is 0.
602+
If :attr:`diagonal` = 0, all elements on and above the main diagonal are
603+
retained. A positive value excludes just as many diagonals above the main
604+
diagonal, and similarly a negative value includes just as many diagonals below
605+
the main diagonal. The main diagonal are the set of indices
606+
:math:`\{(i, i)\}` for :math:`i \in [0, \min\{d_{1}, d_{2}\} - 1]` where
607+
:math:`d_{1}, d_{2}` are the dimensions of the matrix.
608+
name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
609+
out(Tensor, optional): The output tensor.
610+
611+
Returns:
612+
Tensor: Results of upper triangular operation by the specified diagonal of input tensor x,
613+
it's data type is the same as x's Tensor.
614+
615+
Examples:
616+
.. code-block:: python
617+
618+
>>> import paddle
619+
620+
>>> x = paddle.arange(1, 13, dtype="int64").reshape([3,-1])
621+
>>> print(x)
622+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
623+
[[1 , 2 , 3 , 4 ],
624+
[5 , 6 , 7 , 8 ],
625+
[9 , 10, 11, 12]])
626+
627+
>>> # example 1, default diagonal
628+
>>> triu1 = paddle.tensor.triu(x)
629+
>>> print(triu1)
630+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
631+
[[1 , 2 , 3 , 4 ],
632+
[0 , 6 , 7 , 8 ],
633+
[0 , 0 , 11, 12]])
634+
635+
>>> # example 2, positive diagonal value
636+
>>> triu2 = paddle.tensor.triu(x, diagonal=2)
637+
>>> print(triu2)
638+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
639+
[[0, 0, 3, 4],
640+
[0, 0, 0, 8],
641+
[0, 0, 0, 0]])
642+
643+
>>> # example 3, negative diagonal value
644+
>>> triu3 = paddle.tensor.triu(x, diagonal=-1)
645+
>>> print(triu3)
646+
Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
647+
[[1 , 2 , 3 , 4 ],
648+
[5 , 6 , 7 , 8 ],
649+
[0 , 10, 11, 12]])
650+
651+
""",
652+
"""
653+
def triu(
654+
x: Tensor,
655+
diagonal: int = 0,
656+
name: str | None = None,
657+
*,
658+
out: Tensor | None = None,
659+
) -> Tensor
660+
""",
661+
)
662+
518663
add_doc_and_signature(
519664
"bmm",
520665
"""

0 commit comments

Comments
 (0)