-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Typing][C-21,C-22,C-23,C-24] Add type annotations for python/paddle/distributed/communication/{reduce_scatter.py, scatter.py, send.py, all_gather.py}
#66864
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
13e76d7
补全参数类型信息
Lans1ot feb3ba9
修改参数类型信息
Lans1ot f7dac7a
追加遗漏的类型信息
Lans1ot b4d048e
Merge branch 'develop' into develop+type_hint_2
Lans1ot 0e4d12c
Update python/paddle/distributed/communication/scatter.py
Lans1ot 8c7e446
按要求进行修改
Lans1ot bb40649
Merge branch 'develop+type_hint_2' of https://github.com/Lans1ot/Padd…
Lans1ot 4c0c198
Update python/paddle/distributed/communication/scatter.py
Lans1ot f488c7d
修改导入错误
Lans1ot 3d4abf3
根据建议进行修改
Lans1ot 9f1f05f
追加类型信息
Lans1ot 3832021
ignore [union-attr]
SigureMo 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 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 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 |
---|---|---|
|
@@ -12,6 +12,15 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Any, Sequence | ||
|
||
if TYPE_CHECKING: | ||
from paddle import Tensor | ||
from paddle.base.core import task | ||
from paddle.distributed.communication.group import Group | ||
|
||
import numpy as np | ||
|
||
import paddle | ||
|
@@ -25,7 +34,13 @@ | |
) | ||
|
||
|
||
def scatter(tensor, tensor_list=None, src=0, group=None, sync_op=True): | ||
def scatter( | ||
tensor: Tensor, | ||
tensor_list: Sequence[Tensor] | None = None, | ||
src: int = 0, | ||
group: Group | None = None, | ||
sync_op: bool = True, | ||
) -> task | None: | ||
""" | ||
|
||
Scatter a tensor to all participators. As shown below, one process is started with a GPU and the source of the scatter | ||
|
@@ -72,8 +87,11 @@ def scatter(tensor, tensor_list=None, src=0, group=None, sync_op=True): | |
|
||
|
||
def scatter_object_list( | ||
out_object_list, in_object_list=None, src=0, group=None | ||
): | ||
out_object_list: list[Any], | ||
in_object_list: list[Any] | None = None, | ||
Lans1ot marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+90
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 没有导入 |
||
src: int = 0, | ||
group: Group | None = None, | ||
) -> None: | ||
""" | ||
|
||
Scatter picklable objects from the source to all others. Similiar to scatter(), but python object can be passed in. | ||
|
This file contains 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还有下面的检查代码是为了解决什么呢?如果没什么特别需要解决的问题最好还是不要加,因为本任务只涉及类型提示修改,不涉及运行时逻辑修改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是因为我之前做其他任务的时候,有类似的情况。
就是参数只能在特定值中间进行选择,不然就会抛出一个错误
所以我这里就根据
python/paddle/distributed/communication/batch_isend_irecv.py
仿写了一段