Skip to content
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

[Docathon][Add API Legend No.55、22] add paddle.index_fill and paddle.shard_index API Paddle #70215

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

xu8117
Copy link

@xu8117 xu8117 commented Dec 13, 2024

PR Category

PR Types

Description

Copy link

paddle-bot bot commented Dec 13, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Dec 13, 2024
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Dec 16, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 图例部分不要写在代码示例的下面,和中文文档保持同步,写在api介绍的下方
  • .. image:: .... 和上方文字空一行,否则无法渲染

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci过不了,是否要重新提交一个pr

Comment on lines 7296 to 7299
A two-dimensional tensor with a shape of [3, 3], through the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1,
all elements in the first and third rows are filled with -1, thereby obtaining a new tensor with a shape still [3, 3] but some elements changed. A two-dimensional
tensor with the shape [3, 3], by means of the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1,
all the elements in the first and third rows are filled with -1, thus getting a new tensor with the same shape [3, 3] but some elements changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图例解释可以精简一些,如

Suggested change
A two-dimensional tensor with a shape of [3, 3], through the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1,
all elements in the first and third rows are filled with -1, thereby obtaining a new tensor with a shape still [3, 3] but some elements changed. A two-dimensional
tensor with the shape [3, 3], by means of the index_fill operation, when axis = 0, the index tensor index is [0, 2], and the fill value value = -1,
all the elements in the first and third rows are filled with -1, thus getting a new tensor with the same shape [3, 3] but some elements changed.
As shown below, a 2D tensor with shape [3, 3] is updated using the ``index_fill`` operation. With ``axis=0``, ``index=[0, 2]``, and ``value=-1``, the elements in the first and third rows are replaced with ``-1``.
The resulting tensor retains the same shape [3, 3], but with updated values.

Comment on lines 741 to 744
A two-dimensional tensor with a shape of [2, 1], through the shard_index operation, when index_num = 20, nshards = 2, and shard_id = 0, calculates
the shard size shard_size = (20 + 2 - 1) // 2 = 10. For the element values in label, such as 16, because 16 >= 10 (not within the [0, 10) interval
of shard 0), its value is set to ignore_value (i.e., -1) according to the formula; while the element value 1, since 0 <= 1 < 10 (within shard 0),
the updated value is 1 - 0 * 10 = 1, and finally a new tensor with the same shape [2, 1] but some elements changed (such as shard_label) is obtained.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A two-dimensional tensor with a shape of [2, 1], through the shard_index operation, when index_num = 20, nshards = 2, and shard_id = 0, calculates
the shard size shard_size = (20 + 2 - 1) // 2 = 10. For the element values in label, such as 16, because 16 >= 10 (not within the [0, 10) interval
of shard 0), its value is set to ignore_value (i.e., -1) according to the formula; while the element value 1, since 0 <= 1 < 10 (within shard 0),
the updated value is 1 - 0 * 10 = 1, and finally a new tensor with the same shape [2, 1] but some elements changed (such as shard_label) is obtained.
As shown below, a 2D tensor with shape [2, 1] is updated using the ``shard_index`` operation. With ``index_num=20``, ``nshards=2``, and ``shard_id=0``, the shard size is calculated as ``shard_size = (20 + 2 - 1) // 2 = 10``.
For each element in label: If the value is within the shard range ``[0, 10)``, it is adjusted to its offset in the range. For example, ``1`` is updated to ``1 - 0 * 10 = 1``; Otherwise, it is set to the ``ignore_value`` (default ``-1``). For example, ``16`` is outside the range ``[0, 10)`` and becomes ``-1``.

Copy link

paddle-ci-bot bot commented Dec 26, 2024

Sorry to inform you that dce184d's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@luotao1
Copy link
Contributor

luotao1 commented Dec 31, 2024

不需要重新提交,把 PR-CI-Codestyle-Check 流水线过了就行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants