From 85b98070f79c4f08c0dd2a9df0d5cfb814395d90 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Mon, 25 Dec 2017 20:30:53 +0800 Subject: [PATCH] fix a bug of inplace --- python/paddle/v2/fluid/backward.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/paddle/v2/fluid/backward.py b/python/paddle/v2/fluid/backward.py index 0e3c8762fdd..db1b8fa240a 100644 --- a/python/paddle/v2/fluid/backward.py +++ b/python/paddle/v2/fluid/backward.py @@ -99,6 +99,9 @@ def _append_backward_ops_(target, attrs={}), idx)) var_inputs[var_name] = [var_name] for var_name in op_desc.output_arg_names(): + if var_name in op_desc.input_arg_names(): + # in place operator + continue if var_name == core.empty_var_name() or len(var_inputs[ var_name]) == 0: # it's the first time we get the variable @@ -221,6 +224,9 @@ def append_backward(loss, parameter_list=None, no_grad_set=None): if var.stop_gradient: block_no_grad_set.add(_append_grad_suffix_(var.name)) no_grad_set[block.idx] = block_no_grad_set + else: + # FIX ME + no_grad_set = {0: no_grad_set} grad_info_map = dict() root_block = program.block(0) -- GitLab