From 148a35bbed33e42b35abbc373d9ca9cb8214ac62 Mon Sep 17 00:00:00 2001 From: jiachengdai <221310411@mail.dhu.edu.cn> Date: Wed, 27 Nov 2024 11:51:38 +0800 Subject: [PATCH 1/2] add figure to scatter_en --- python/paddle/tensor/manipulation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index 3c452ada7b887..404133dca35d8 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -4169,6 +4169,11 @@ def scatter( **Scatter Layer** Output is obtained by updating the input on selected indices based on updates. + In the following figure, when overwrite is True, update the output of the same index using the overlay mode, in turn updating ``x[index[i]]`` to ``update[i]``; When overwrite is False, the output of the same index is updated using the summative mode, which first updates ``x[index[i]]`` to a Tensor of the same size as the row with values of 0. Add ``update[i]`` to ``x[index[i]]`` in turn to produce output. + + .. image:: https://githubraw.cdn.bcebos.com/PaddlePaddle/docs/develop/docs/images/api_legend/scatter.png + :alt: Legend - scatter behavior display + .. code-block:: python :name: scatter-example-1 From ba20a75e2ed8506cafa8054eb8073f2135364c16 Mon Sep 17 00:00:00 2001 From: jiachengdai <221310411@mail.dhu.edu.cn> Date: Wed, 27 Nov 2024 19:37:51 +0800 Subject: [PATCH 2/2] update the description for scatter --- python/paddle/tensor/manipulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index 404133dca35d8..4597dd00c03fa 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -4169,7 +4169,7 @@ def scatter( **Scatter Layer** Output is obtained by updating the input on selected indices based on updates. - In the following figure, when overwrite is True, update the output of the same index using the overlay mode, in turn updating ``x[index[i]]`` to ``update[i]``; When overwrite is False, the output of the same index is updated using the summative mode, which first updates ``x[index[i]]`` to a Tensor of the same size as the row with values of 0. Add ``update[i]`` to ``x[index[i]]`` in turn to produce output. + As shown in the figure, when ``overwrite`` is set to ``True``, the output for the same index is updated in overwrite mode, where ``x[index[i]]`` is directly replaced with ``update[i]`` sequentially; When ``overwrite`` is set to ``False``, the output for the same index is updated in accumulation mode. In this mode, ``x[index[i]]`` is first initialized with elements set to 0. Then, ``update[i]`` is sequentially added to ``x[index[i]]`` to produce the output. .. image:: https://githubraw.cdn.bcebos.com/PaddlePaddle/docs/develop/docs/images/api_legend/scatter.png :alt: Legend - scatter behavior display