Skip to content

Commit

Permalink
【Hackathon 5th No.27】为 Paddle 新增 select_scatter API (#6352)
Browse files Browse the repository at this point in the history
* add doc_cn for select_scatter

* remove en
  • Loading branch information
YibinLiu666 authored Dec 7, 2023
1 parent 3fa29e0 commit e4f4dea
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ tensor 数学操作
" :ref:`paddle.polygamma <cn_api_paddle_polygamma>` ", "对输入 Tensor 每个元素计算多伽马函数"
" :ref:`paddle.hypot <cn_api_paddle_hypot>` ", "对输入 直角三角形的直角边 Tensor x, y, 计算其斜边"
" :ref:`paddle.combinations <cn_api_paddle_combinations>` ", "对输入 Tensor 计算长度为 r 的情况下的所有组合"
" :ref:`paddle.select_scatter <cn_api_paddle_select_scatter>` ", "根据 axis 和 index(整数) 填充 value 值至输入 Tensor"
.. _tensor_math_inplace:

tensor 数学操作原位(inplace)版本
Expand Down
11 changes: 11 additions & 0 deletions docs/api/paddle/Tensor_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3126,3 +3126,14 @@ diagonal_scatter(x, y, offset=0, axis1=0, axis2=1, name=None)
返回类型:Tensor

请参考 :ref:`cn_api_paddle_diagonal_scatter`

select_scatter(x, values, axis, index, name=None)
:::::::::

将 ``values`` 矩阵的值嵌入到 ``x`` 矩阵的第 ``axis`` 维的 ``index`` 列, ``values`` 的形状需要与 ``x`` 矩阵除去第 ``axis`` 维后的形状一致

返回:计算后的 Tensor

返回类型:Tensor

请参考 :ref:`cn_api_paddle_select_scatter`
25 changes: 25 additions & 0 deletions docs/api/paddle/select_scatter_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. _cn_api_paddle_select_scatter:

select_scatter
-------------------------------

.. py:function:: paddle.select_scatter(x, values, axis, index, name=None)
将 ``values`` 矩阵的值嵌入到 ``x`` 矩阵的第 ``axis`` 维的 ``index`` 列

参数
:::::::::
- **x** (Tensor) - 输入的 Tensor 作为目标矩阵,数据类型为: `bool`、 `float16`、 `float32`、 `float64`、 `uint8`、 `int8`、 `int16`、 `int32`、 `int64`、 `bfloat16`、 `complex64`、 `complex128`。
- **values** (Tensor) - 需要插入的值,形状需要与 ``x`` 矩阵除去第 ``axis`` 维后的形状一致,数据类型为: `bool`、 `float16`、 `float32`、 `float64`、 `uint8`、 `int8`、 `int16`、 `int32`、 `int64`、 `bfloat16`、 `complex64`、 `complex128`。
- **axis** (int) - 指定沿着哪个维度嵌入对应的值,数据类型为:int。
- **index** (int) - 指定沿着 ``axis`` 维的哪一列嵌入对应的值,数据类型为:int。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
:::::::::

输出 Tensor, ``x`` 矩阵的第 ``axis`` 维的第 ``index`` 列会被插入 ``value``,与 ``x`` 数据类型相同。

代码示例
:::::::::

COPY-FROM: paddle.select_scatter

0 comments on commit e4f4dea

Please sign in to comment.