From 5031b4436f300247276dc25e9ebe3778dbf31359 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Thu, 23 Mar 2023 19:45:10 +0800 Subject: [PATCH] [Dy2St]Fix clone for test state problem (#51966) * [Dy2St]Fix clone for test state problem * clean code --- python/paddle/jit/dy2static/partial_program.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/python/paddle/jit/dy2static/partial_program.py b/python/paddle/jit/dy2static/partial_program.py index 840ebdb86c0..f46c3a65cfe 100644 --- a/python/paddle/jit/dy2static/partial_program.py +++ b/python/paddle/jit/dy2static/partial_program.py @@ -108,15 +108,6 @@ class LazyInitialized: return val -def _change_is_test_status(program, is_test): - # change all `is_test` attributes - for block in program.blocks: - for op in block.ops: - if op.has_attr('is_test'): - op._set_attr('is_test', is_test) - return program - - class ProgramInfo: """ A helper class to recoder Program information @@ -618,8 +609,7 @@ class PartialProgramLayer: @switch_to_static_graph def _append_backward_desc(self, main_program): - # make sure all status of is_test are False in train mode. - program = _change_is_test_status(main_program.clone(), is_test=False) + program = main_program.clone(for_test=False) if self._hooker: program = self._hooker.before_append_backward(program) targets = [] -- GitLab