-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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][B-41,B-48][BUAA] Add type annotations for python/paddle/autograd/ir_backward.py,python/paddle/cost_model/cost_model.py
#66890
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
python/paddle/autograd/ir_backward.py,python/paddle/cost_model/cost_model.py
python/paddle/autograd/ir_backward.py,python/paddle/cost_model/cost_model.py
inputs: Value | Sequence[Value], | ||
grad_outputs: Value | Sequence[Value | None] | None = None, | ||
no_grad_set: set[Value] | None = None, | ||
) -> dict[Value, list[Value]]: |
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.
) -> dict[Value, list[Value]]: | |
) -> ValueDict: |
if TYPE_CHECKING: | ||
from typing import Sequence | ||
|
||
from paddle.base.libpaddle.pir import Value |
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.
from paddle.base.libpaddle.pir import Value | |
from paddle.pir import Value |
inputs: Value | Sequence[Value], | ||
grad_outputs: Value | Sequence[Value | None] | None = None, | ||
no_grad_set: set[Value] | None = None, | ||
) -> list[Value]: |
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.
) -> list[Value]: | |
) -> list[Value | None]: |
only_inputs: bool | None = True, | ||
allow_unused: bool | None = False, | ||
no_grad_vars: Value | Sequence[Value] | None = None, | ||
) -> list[Value]: |
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.
) -> list[Value]: | |
) -> list[Value | None]: |
create_graph: bool | None = False, | ||
only_inputs: bool | None = True, | ||
allow_unused: bool | None = False, | ||
no_grad_vars: Value | Sequence[Value] | None = None, |
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.
no_grad_vars: Value | Sequence[Value] | None = None, | |
no_grad_vars: Value | Sequence[Value] | set[Value] | None = None, |
if TYPE_CHECKING: | ||
from paddle.base.compiler import CompiledProgram | ||
from paddle.base.framework import Program | ||
|
||
|
||
class CostModel: | ||
def __init__(self): |
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.
def __init__(self): | |
def __init__(self) -> None: |
startup_program: Program | CompiledProgram, | ||
main_program: Program | CompiledProgram, | ||
device: str = 'gpu', | ||
fetch_cost_list: Sequence = ['time'], |
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.
fetch_cost_list: Sequence = ['time'], | |
fetch_cost_list: Sequence[???] = ['time'], |
|
||
import json | ||
import os | ||
from typing import TYPE_CHECKING, Sequence |
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.
从 collections.abc
导入 Sequence
@@ -59,6 +60,11 @@ | |||
""" | |||
__all__ = ['grad', 'calc_gradient', 'calc_gradient_helper'] | |||
|
|||
if TYPE_CHECKING: | |||
from typing import Sequence |
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.
从 collections.abc
导入
@Luohongzhige 请按照 PR 模板提交,不然 tracking issue 跟踪不到,无法 review ~ |
关联 #65008 |
已修改 |
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.
LGTM ~
if TYPE_CHECKING: | ||
from collections.abc import Sequence | ||
|
||
from paddle.pir import Value |
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.
要紧随其它 import,放在 55 行,不要放在这里
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.
PR Category
User Experience
PR Types
Improvements
Description
#65008
B-41,B-48