Skip to content

Commit 44f3be5

Browse files
committed
Fix Outplace document and Inplace document comments
1 parent b16094e commit 44f3be5

File tree

1 file changed

+3
-77
lines changed

1 file changed

+3
-77
lines changed

python/paddle/tensor/manipulation.py

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6263,20 +6263,6 @@ def masked_fill_(
62636263
"""
62646264
Inplace version of ``masked_fill`` API, the output Tensor will be inplaced with input ``x``.
62656265
Please refer to :ref:`api_paddle_masked_fill`.
6266-
6267-
Examples:
6268-
.. code-block:: python
6269-
6270-
>>> # doctest: +REQUIRES(env:GPU)
6271-
>>> import paddle
6272-
>>> x = paddle.ones((3, 3), dtype="float32")
6273-
>>> mask = paddle.to_tensor([[True, False, False]])
6274-
>>> out = paddle.masked_fill_(x, mask, 2)
6275-
>>> print(out)
6276-
Tensor(shape=[3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
6277-
[[2., 1., 1.],
6278-
[2., 1., 1.],
6279-
[2., 1., 1.]])
62806266
"""
62816267
if np.isscalar(value):
62826268
value = paddle.full([], value, x.dtype)
@@ -6715,23 +6701,6 @@ def index_add_(
67156701
"""
67166702
Inplace version of ``index_add`` API, the output Tensor will be inplaced with input ``x``.
67176703
Please refer to :ref:`api_paddle_index_add`.
6718-
6719-
Examples:
6720-
.. code-block:: python
6721-
6722-
>>> # doctest: +REQUIRES(env:GPU)
6723-
>>> import paddle
6724-
>>> paddle.device.set_device('gpu')
6725-
6726-
>>> input_tensor = paddle.to_tensor(paddle.ones((3, 3)), dtype="float32")
6727-
>>> index = paddle.to_tensor([0, 2], dtype="int32")
6728-
>>> value = paddle.to_tensor([[1, 1], [1, 1], [1, 1]], dtype="float32")
6729-
>>> inplace_res = paddle.index_add_(input_tensor, index, 1, value)
6730-
>>> print(inplace_res)
6731-
Tensor(shape=[3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
6732-
[[2., 1., 2.],
6733-
[2., 1., 2.],
6734-
[2., 1., 2.]])
67356704
"""
67366705
return _C_ops.index_add_(x, index, value, axis)
67376706

@@ -6745,31 +6714,8 @@ def index_put_(
67456714
name: str | None = None,
67466715
) -> Tensor:
67476716
"""
6748-
Inplace version of ``index_put_`` API, the output Tensor will be inplaced with input ``x``.
6717+
Inplace version of ``index_put`` API, the output Tensor will be inplaced with input ``x``.
67496718
Please refer to :ref:`api_paddle_index_put`.
6750-
6751-
Examples:
6752-
.. code-block:: python
6753-
6754-
>>> import paddle
6755-
6756-
>>> x = paddle.zeros([3, 3])
6757-
>>> value = paddle.ones([3])
6758-
>>> ix1 = paddle.to_tensor([0,1,2])
6759-
>>> ix2 = paddle.to_tensor([1,2,1])
6760-
>>> indices=(ix1,ix2)
6761-
6762-
>>> out = paddle.index_put_(x,indices,value)
6763-
>>> print(x)
6764-
Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
6765-
[[0., 1., 0.],
6766-
[0., 0., 1.],
6767-
[0., 1., 0.]])
6768-
>>> print(out)
6769-
Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
6770-
[[0., 1., 0.],
6771-
[0., 0., 1.],
6772-
[0., 1., 0.]])
67736719
"""
67746720
return _C_ops.index_put_(x, indices, value, accumulate)
67756721

@@ -7204,28 +7150,8 @@ def index_fill_(
72047150
x: Tensor, index: Tensor, axis: int, value: float, name: str | None = None
72057151
):
72067152
"""
7207-
Inplace version of ``index_fill_`` API, the output Tensor will be inplaced with input ``x``.
7208-
Please refer to :ref:`api_paddle_index_fill_`.
7209-
7210-
Examples:
7211-
.. code-block:: python
7212-
7213-
>>> import paddle
7214-
>>> input_tensor = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype='int64')
7215-
>>> index = paddle.to_tensor([0, 2], dtype="int32")
7216-
>>> value = -1
7217-
>>> res = paddle.index_fill_(input_tensor, index, 0, value)
7218-
>>> print(input_tensor)
7219-
Tensor(shape=[3, 3], dtype=int64, place=Place(gpu:0), stop_gradient=True,
7220-
[[-1, -1, -1],
7221-
[ 4, 5, 6],
7222-
[-1, -1, -1]])
7223-
>>> print(res)
7224-
Tensor(shape=[3, 3], dtype=int64, place=Place(gpu:0), stop_gradient=True,
7225-
[[-1, -1, -1],
7226-
[ 4, 5, 6],
7227-
[-1, -1, -1]])
7228-
7153+
Inplace version of ``index_fill`` API, the output Tensor will be inplaced with input ``x``.
7154+
Please refer to :ref:`api_paddle_index_fill`.
72297155
"""
72307156
return _index_fill_impl(x, index, axis, value, True)
72317157

0 commit comments

Comments
 (0)