Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def prune_gradient_clip(self, block, shard):
if deperate_op:
deperate_op_idx.add(idx)
for output_name in op.desc.output_arg_names():
deperated_vars.add(output_name)
if output_name not in op.desc.input_arg_names():
deperated_vars.add(output_name)

if not deperated_vars:
# got no gradient_clip op
Expand Down
11 changes: 8 additions & 3 deletions python/paddle/fluid/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,14 @@ def _static_clip(self, params_grads):
continue

with p.block.program._optimized_guard([p, g]):
new_grad = layers.elementwise_mul(x=g, y=scale_var)
param_new_grad_name_dict[p.name] = new_grad.name
params_and_grads.append((p, new_grad))
p.block.append_op(
type='elementwise_mul',
inputs={'X': g,
'Y': scale_var},
outputs={'Out': g})

param_new_grad_name_dict[p.name] = g.name
params_and_grads.append((p, g))

_correct_clip_op_role_var(params_and_grads, param_new_grad_name_dict)
return params_and_grads
Expand Down