forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【Hackathon 5th No.4】为 Paddle 新增 masked_scatter API (PaddlePaddle#6405)
* add masked_scatter docs * fix * fix
- Loading branch information
1 parent
2854d27
commit 5f5e8c1
Showing
7 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. _cn_api_paddle_masked_scatter_: | ||
|
||
masked_scatter\_ | ||
------------------------------- | ||
|
||
.. py:function:: paddle.masked_scatter_(x, mask, value, name=None) | ||
Inplace 版本的 :ref:`cn_api_paddle_masked_scatter` API,对输入 x 采用 Inplace 策略。 | ||
|
||
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。 | ||
|
||
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. _cn_api_paddle_masked_scatter: | ||
|
||
masked_scatter | ||
------------------------------- | ||
|
||
.. py:function:: paddle.masked_scatter(x, mask, value, name=None) | ||
返回一个 N-D 的 Tensor,Tensor 的值是根据 ``mask`` 信息,将 ``value`` 中的值逐个填充到 ``x`` 中 ``mask`` 对应为 ``True`` 的位置,``mask`` 的数据类型是 bool。 | ||
|
||
参数 | ||
:::::::::::: | ||
|
||
- **x** (Tensor) - 输入 Tensor,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。 | ||
- **mask** (Tensor) - 布尔张量,表示要填充的位置。mask 的数据类型必须为 bool。 | ||
- **value** (Tensor) - 用于填充目标张量的值,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 | ||
|
||
返回 | ||
:::::::::::: | ||
返回一个根据 ``mask`` 将对应位置逐个填充 ``value`` 中的 Tensor,数据类型与 ``x`` 相同。 | ||
|
||
|
||
代码示例 | ||
:::::::::::: | ||
|
||
COPY-FROM: paddle.masked_scatter |
22 changes: 22 additions & 0 deletions
22
...nvert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.masked_scatter.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## [ 参数完全一致 ] torch.Tensor.masked_scatter | ||
|
||
### [torch.Tensor.masked_scatter](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_scatter.html?highlight=masked_scatter#torch.Tensor.masked_scatter) | ||
|
||
```python | ||
torch.Tensor.masked_scatter(mask, value) | ||
``` | ||
|
||
### [paddle.Tensor.masked_scatter](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#masked-scatter-mask-value-name-non) | ||
|
||
```python | ||
paddle.Tensor.masked_scatter(mask, value, name=None) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
|---------|--------------| -------------------------------------------------- | | ||
| mask | mask | 布尔张量,表示要填充的位置 | | ||
| value | value | 用于填充目标张量的值 | |
22 changes: 22 additions & 0 deletions
22
...vert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.masked_scatter_.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## [ 参数完全一致 ] torch.Tensor.masked_scatter_ | ||
|
||
### [torch.Tensor.masked_scatter_](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_scatter_.html?highlight=masked_scatter#torch.Tensor.masked_scatter_) | ||
|
||
```python | ||
torch.Tensor.masked_scatter_(mask, value) | ||
``` | ||
|
||
### [paddle.Tensor.masked_scatter_]() | ||
|
||
```python | ||
paddle.Tensor.masked_scatter_(mask, value, name=None) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
|---------|--------------| -------------------------------------------------- | | ||
| mask | mask | 布尔张量,表示要填充的位置 | | ||
| value | value | 用于填充目标张量的值 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters