Skip to content

Commit 74e6ef6

Browse files
[Docathon][Add API Legend No.45] 给index_add添加图示 (#6938)
* 给index_add添加图示 * 修改第二张图以及修改文档内容 * Update docs/api/paddle/index_add_cn.rst * Update docs/api/paddle/index_add_cn.rst * Update docs/api/paddle/index_add_cn.rst * Update docs/api/paddle/index_add_cn.rst --------- Co-authored-by: zachary sun <[email protected]>
1 parent 81d9b63 commit 74e6ef6

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

docs/api/paddle/index_add_cn.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,73 @@ index_add
99
1010
沿着指定轴 ``axis`` 将 ``index`` 中指定位置的 ``x`` 与 ``value`` 相加,并写入到结果 Tensor 中的对应位置。这里 ``index`` 是一个 ``1-D`` Tensor。除 ``axis`` 轴外,返回的 Tensor 其余维度大小和输入 ``x`` 相等, ``axis`` 维度的大小等于 ``index`` 的大小。
1111

12+
**示例**
13+
14+
::
15+
16+
- 示例 1 (输入为 2-D Tensor, axis=0 ):
17+
输入:
18+
x.shape = [3, 3]
19+
x.data = [[1., 1., 1.],
20+
[1., 1., 1.],
21+
[1., 1., 1.]]
22+
23+
参数:
24+
index.shape = [2]
25+
index.data = [0, 2]
26+
27+
axis = 0
28+
29+
value.shape = [2, 3]
30+
value.data = [[1., 1., 1.],
31+
[1., 1., 1.]]
32+
输出:
33+
out.shape = [3, 3]
34+
out.data = [[2., 2., 2.],
35+
[1., 1., 1.],
36+
[2., 2., 2.]]
37+
38+
- 示例 2 (输入为 2-D Tensor, axis=1 ):
39+
输入:
40+
x.shape = [3, 3]
41+
x.data = [[1., 1., 1.],
42+
[1., 1., 1.],
43+
[1., 1., 1.]]
44+
45+
参数:
46+
index.shape = [2]
47+
index.data = [0, 2]
48+
49+
axis = 1
50+
51+
value.shape = [3, 2]
52+
value.data = [[1., 1.],
53+
[1., 1.],
54+
[1., 1.]]
55+
输出:
56+
out.shape = [3, 3]
57+
out.data = [[2., 1., 2.],
58+
[1., 1., 1.],
59+
[2., 1., 2.]]
60+
61+
**示例 1 图解说明**
62+
63+
下图展示了示例 1 中的情形——一个形状为 [3,3] 的二维张量通过 index_add 操作在 axis=0 轴上对指定位置的元素进行相加,同时保持了除 ``axis`` 轴外,返回的 Tensor 其余维度大小和输入 ``x`` 相等。
64+
65+
.. figure:: ../../images/api_legend/index_add/index_add-1.png
66+
:width: 500
67+
:alt: 示例 1 图示
68+
:align: center
69+
70+
**示例 2 图解说明**
71+
72+
下图展示了示例 2 中的情形——一个形状为 [3,3] 的二维张量通过 index_add 操作在 axis=1 轴上对指定位置的元素进行相加,同时保持了除 ``axis`` 轴外,返回的 Tensor 其余维度大小和输入 ``x`` 相等。
73+
74+
.. figure:: ../../images/api_legend/index_add/index_add-2.png
75+
:width: 500
76+
:alt: 示例 2 图示
77+
:align: center
78+
1279
参数
1380
:::::::::
1481

72.3 KB
Loading
74.8 KB
Loading

0 commit comments

Comments
 (0)