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

[Dy2St] Add enable_to_static_guard for dy2st uts #59670

Merged

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Dec 4, 2023

PR types

Others

PR changes

Others

Description

增加 enable_to_static_guard 以免泄漏 enable_to_static 状态到单测外

PCard-66972

Copy link

paddle-bot bot commented Dec 4, 2023

你的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.

original_flag_value = program_translator.enable_to_static
program_translator.enable(flag)
try:
program_translator.enable(flag)
Copy link
Member Author

Choose a reason for hiding this comment

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

多写了一遍,之后 PR 删掉 😂

Comment on lines +506 to +511
# 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
Copy link
Member Author

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_,之后删一下

Copy link
Contributor

@2742195759 2742195759 left a comment

Choose a reason for hiding this comment

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

LGTM

@SigureMo SigureMo merged commit bf341b2 into PaddlePaddle:develop Dec 5, 2023
@SigureMo SigureMo deleted the dy2st/add-enable-to-static-guard branch December 5, 2023 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants