-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Typing][C-17] Add type annotations for python/paddle/distributed/communication/gather.py
#66276
Changes from 3 commits
62d585d
f06a8da
a2e0536
77ee40c
24f2149
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,26 @@ | |
# limitations under the License. | ||
|
||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from paddle import framework | ||
from paddle.distributed.communication import stream | ||
|
||
if TYPE_CHECKING: | ||
from paddle import Tensor | ||
from paddle.base.core import task | ||
from paddle.distributed.communication.group import Group | ||
|
||
|
||
def gather(tensor, gather_list=None, dst=0, group=None, sync_op=True): | ||
def gather( | ||
tensor: Tensor, | ||
gather_list: list = None, | ||
dst: int = 0, | ||
group: Group | None = None, | ||
sync_op: bool = True, | ||
) -> task | None: | ||
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. 返回值是 Union 的情况优先考虑使用 overload 进行区分,这里可以使用 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. 可参考 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. @overload @overload def lu( 是也要像这样写多了def lu()吗?还是把返回值改成tuple就行? 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. overload 就是要写多个的 |
||
""" | ||
|
||
Gather tensors from all participators. | ||
|
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.
泛型必须写明参数类型