-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【Hackathon 5th No.28】为 Paddle 新增 slice_scatter API #6409
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. _cn_api_paddle_slice_scatter: | ||
|
||
slice_scatter | ||
------------------------------- | ||
|
||
.. py:function:: paddle.slice_scatter(x, value, axes, starts, ends, strides, name=None) | ||
|
||
沿着 `axes` 将 `value` 矩阵的值嵌入到 `x` 矩阵。返回一个新的 Tensor 而不是试图。 `axes` 需要与 `starts`, `ends` 和 `strides` 尺寸一致。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改~ |
||
|
||
参数 | ||
::::::::: | ||
- **x** (Tensor) - 输入的 Tensor 作为目标矩阵,数据类型为: `bool`、 `float16`、 `float32`、 `float64`、 `uint8`、 `int8`、 `int16`、 `int32`、 `int64`、 `bfloat16`、 `complex64`、 `complex128`。 | ||
- **value** (Tensor) - 需要插入的值,数据类型为: `bool`、 `float16`、 `float32`、 `float64`、 `uint8`、 `int8`、 `int16`、 `int32`、 `int64`、 `bfloat16`、 `complex64`、 `complex128`。 | ||
- **axes** (list|tuple) - 指定沿着哪几个维度嵌入对应的值。 | ||
- **starts** (list|tuple) - 嵌入的起始索引。 | ||
- **ends** (list|tuple) - 嵌入的截止索引。 | ||
- **strides** (list|tuple) - 嵌入的步长。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 `None`。 | ||
|
||
返回 | ||
::::::::: | ||
|
||
Tensor, 与 ``x`` 数据类型与形状相同。 | ||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.slice_scatter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## [ 参数不一致 ]torch.Tensor.slice_scatter | ||
|
||
### [torch.Tensor.slice_scatter](https://pytorch.org/docs/stable/generated/torch.Tensor.slice_scatter.html#torch-tensor-slice-scatter) | ||
|
||
```python | ||
Tensor.slice_scatter(src, dim=0, start=None, end=None, step=1) | ||
``` | ||
|
||
### [paddle.Tensor.slice_scatter](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#slice_scatter-value-axes-starts-ends-strides-name-none) | ||
|
||
```python | ||
Tensor.slice_scatter(value, axes, starts, ends, strides, name=None) | ||
``` | ||
|
||
两者功能一致,参数不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| src | value | 嵌入的值,仅参数名不一致。 | | ||
| dim | axes | 嵌入的维度,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
| start | starts | 嵌入起始索引,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
| end | ends | 嵌入截至索引,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
| step | strides | 嵌入步长,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
x.slice_scatter(src, dim=0, start=1, end=5, step=2) | ||
|
||
# Paddle 写法 | ||
x.slice_scatter(value, axes=[0], starts=[1], ends=[5], strides=[2]) | ||
``` |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zhwesky2010 辛苦review 一下~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## [ 参数不一致 ]torch.Tensor.slice_scatter | ||
|
||
### [torch.slice_scatter](https://pytorch.org/docs/stable/generated/torch.slice_scatter.html#torch.slice_scatter) | ||
|
||
```python | ||
torch.slice_scatter(input, src, dim=0, start=None, end=None, step=1) | ||
``` | ||
|
||
### [paddle.slice_scatter](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/slice_scatter.html) | ||
|
||
```python | ||
paddle.slice_scatter(x, value, axes, starts, ends, strides, name=None) | ||
``` | ||
|
||
两者功能一致,参数不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 输入的目标矩阵, 仅参数名不一致。 | | ||
| src | value | 嵌入的值,仅参数名不一致。 | | ||
| dim | axes | 嵌入的维度,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
| start | starts | 嵌入起始索引,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
| end | ends | 嵌入截至索引,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
| step | strides | 嵌入步长,PyTorch 为 int 类型,Paddle 为 list of int。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.slice_scatter(input, src, dim=0, start=1, end=5, step=2) | ||
|
||
# Paddle 写法 | ||
paddle.slice_scatter(x, value, axes=[0], starts=[1], ends=[5], strides=[2]) | ||
``` |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zhwesky2010 btw,问一下该文档的映射目录 预览 的显示是对的嘛.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这不是我搞的吧???🥲🥲🥲 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🤪 不是,我记得这问题之前反馈过,这个 PR 先不管这个问题吧 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
试图
是啥?是 视图 吗There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改~