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

[PIR] Fix IrGuard bug #63959

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/paddle/pir_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

def _switch_to_pir_():
paddle.base.framework.global_var._use_pir_api_ = True
paddle.framework.set_flags({"FLAGS_enable_pir_in_executor": True})
paddle.pir.register_paddle_dialect()
# TODO find a better place to init the registion of dist dialect.
paddle.pir.register_dist_dialect()
Expand All @@ -42,7 +41,6 @@ def _switch_to_pir_():

def _switch_to_old_ir_():
paddle.base.framework.global_var._use_pir_api_ = False
paddle.framework.set_flags({"FLAGS_enable_pir_in_executor": False})

paddle.base.Program = paddle.base.framework.Program
paddle.base.program_guard = paddle.base.framework.program_guard
Expand All @@ -68,6 +66,9 @@ def __enter__(self):
self.old_flag = paddle.base.framework.get_flags("FLAGS_enable_pir_api")[
"FLAGS_enable_pir_api"
]
self.old_exe_flag = paddle.base.framework.get_flags(
"FLAGS_enable_pir_in_executor"
)["FLAGS_enable_pir_in_executor"]
if self.in_dygraph_outside:
paddle.enable_static()
if not self.old_flag:
Expand All @@ -84,6 +85,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):
paddle.base.framework.global_var._use_pir_api_ = False
bind_vartype()
self._switch_to_old_ir()
if not self.old_exe_flag:
paddle.framework.set_flags({"FLAGS_enable_pir_in_executor": False})

def _switch_to_pir(self):
if paddle.base.framework.get_flags("FLAGS_enable_pir_api")[
Expand Down