From 2ce1ed3dbdd54d72be288b64a2eccec4f6dd1e4d Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Thu, 12 Jul 2018 13:38:11 +0800 Subject: [PATCH] add optimized_guard for ModelAverage --- python/paddle/fluid/optimizer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/optimizer.py b/python/paddle/fluid/optimizer.py index 65fef50ead..214f47afa1 100644 --- a/python/paddle/fluid/optimizer.py +++ b/python/paddle/fluid/optimizer.py @@ -1158,7 +1158,8 @@ class ModelAverage(Optimizer): self.params_grads.append((param, grad)) for param, grad in self.params_grads: - self._append_average_accumulate_op(param) + with param.block.program.optimized_guard(param): + self._append_average_accumulate_op(param) self.apply_program = Program() block = self.apply_program.global_block() -- GitLab