-
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
[Dy2St] Add enable_to_static_guard
for dy2st uts
#59670
[Dy2St] Add enable_to_static_guard
for dy2st uts
#59670
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
original_flag_value = program_translator.enable_to_static | ||
program_translator.enable(flag) | ||
try: | ||
program_translator.enable(flag) |
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 删掉 😂
# Why need set `_in_to_static_mode_` here? | ||
# In Dy2St we use `with _to_static_mode_guard_()` to indicate | ||
# that the code block is under @to_static, but in this UT | ||
# an exception is thrown during Dy2St, making the `_in_to_static_mode_` | ||
# a wrong value. So We need set `_in_to_static_mode_` to False manually. | ||
paddle.base.dygraph.base.global_var._in_to_static_mode_ = False |
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.
这里看起来也不需要了,因为现在 _to_static_mode_guard_
有 try-finally 确保恢复 _in_to_static_mode_
,之后删一下
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
PR types
Others
PR changes
Others
Description
增加
enable_to_static_guard
以免泄漏 enable_to_static 状态到单测外PCard-66972