From 65dd7ec2d6a51ccaff6e37c8c694058bdc2de908 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Mon, 20 May 2019 02:21:58 -0500 Subject: [PATCH] add clear ops in dygraph optimizers,test=develop (#17484) --- python/paddle/fluid/optimizer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/paddle/fluid/optimizer.py b/python/paddle/fluid/optimizer.py index 5d9f7d1ee7d..4f21ace2021 100644 --- a/python/paddle/fluid/optimizer.py +++ b/python/paddle/fluid/optimizer.py @@ -499,6 +499,9 @@ class Optimizer(object): optimize_ops = self.apply_optimize( loss, startup_program=startup_program, params_grads=params_grads) + if framework.in_dygraph_mode(): + framework._dygraph_tracer()._clear_ops() + return optimize_ops, params_grads -- GitLab