-
Couldn't load subscription status.
- Fork 869
【Hackathon 5th No.26】为 Paddle 新增 diagonal_scatter API #6289
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
40fd415
add diagonal scatter docs
DanGuge 1f84d65
Merge branch 'develop' into diagonal_scatter
DanGuge 075b972
update
DanGuge 33c7fa7
fix: name
DanGuge ffeaced
Update docs/api/paddle/diagonal_scatter_cn.rst
DanGuge 40ee6b3
fix review suggestions
DanGuge aa9c2c5
update
DanGuge 2473507
update
DanGuge 1163d03
add difference compare
DanGuge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
| .. _cn_api_paddle_diagonal_scatter: | ||
|
|
||
| diagonal_scatter | ||
| ------------------------------- | ||
|
|
||
| .. py:function:: paddle.diagonal_scatter(x, y, offset=0, axis1=0, axis2=1, name=None) | ||
|
|
||
|
|
||
| 根据参数 ``offset``、``axis1``、``axis2``,将张量 ``y`` 填充到张量 ``x`` 的对应位置。 | ||
|
|
||
| 这个函数将会返回一个新的 ``Tensor``。 | ||
|
|
||
| 参数 ``offset`` 确定从指定的二维平面中获取对角线的位置: | ||
|
|
||
| - 如果 offset = 0,则嵌入主对角线。 | ||
| - 如果 offset > 0,则嵌入主对角线右上的对角线。 | ||
| - 如果 offset < 0,则嵌入主对角线左下的对角线。 | ||
|
|
||
| 参数 | ||
| :::::::::::: | ||
|
|
||
| - **x** (Tensor) - 输入张量,张量的维度至少为 2 维,支持 float16、float32、float64、bfloat16、uint8、int8、int16、int32、int64、bool、complex64、complex128 数据类型。 | ||
| - **y** (Tensor) - 嵌入张量,将会被嵌入到输入张量中,支持 float16、float32、float64、bfloat16、uint8、int8、int16、int32、int64、bool、complex64、complex128 数据类型。 | ||
| - **offset** (int, 可选) - 从指定的二维平面嵌入对角线的位置,默认值为 0,即主对角线。 | ||
| - **axis1** (int, 可选) - 对角线的第一个维度,默认值为 0。 | ||
| - **axis2** (int, 可选) - 对角线的第二个维度,默认值为 1。 | ||
| - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 | ||
|
|
||
| 返回 | ||
| :::::::::::: | ||
| ``Tensor``,返回一个根据给定的轴 ``axis`` 和偏移量 ``offset``,将张量 ``y`` 填充到张量 ``x`` 对应位置的新 ``Tensor``。 | ||
|
|
||
|
|
||
| 代码示例 | ||
| :::::::::::: | ||
|
|
||
| COPY-FROM: paddle.diagonal_scatter |
25 changes: 25 additions & 0 deletions
25
...ert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.diagonal_scatter.md
This file contains hidden or 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,25 @@ | ||
| ## [ 参数完全一致 ] torch.Tensor.diagonal_scatter | ||
|
|
||
| ### [torch.Tensor.diagonal_scatter](https://pytorch.org/docs/stable/generated/torch.Tensor.diagonal_scatter.html?highlight=diagonal_scatter#torch.Tensor.diagonal_scatter) | ||
|
|
||
| ```python | ||
| torch.Tensor.diagonal_scatter(input, src, offset=0, dim1=0, dim2=1) | ||
| ``` | ||
|
|
||
| ### [paddle.Tensor.diagonal_scatter](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#diagonal-scatter-x-y-offset-0-axis1-0-axis2-1-name-none) | ||
|
|
||
| ```python | ||
| paddle.Tensor.diagonal_scatter(x, y, offset=0, axis1=0, axis2=1) | ||
| ``` | ||
|
|
||
| 两者功能一致且参数用法一致,仅参数名不一致,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| |---------|--------------| -------------------------------------------------- | | ||
| | input | x | 输入张量,被嵌入的张量,仅参数名不一致。 | | ||
| | src | y | 用于嵌入的张量,仅参数名不一致。 | | ||
| | offset | offset | 从指定的二维平面嵌入对角线的位置,默认值为 0,即主对角线。 | | ||
| | dim1 | axis1 | 对角线的第一个维度,默认值为 0,仅参数名不一致。 | | ||
| | dim2 | axis2 | 对角线的第二个维度,默认值为 1,仅参数名不一致。 | |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.