提交 17bd776e 编写于 作者: W WangXi 提交者: sandyhouse

GlobalNormClip use inplace mul

上级 16dc8056
......@@ -111,6 +111,7 @@ class GradientClipHelper(object):
to_check_param - should_check_param)
for var_name in deperated_vars:
block._remove_var(var_name, sync=False)
if block.has_var(var_name):
block._remove_var(var_name, sync=False)
block._sync_with_cpp()
return
......@@ -489,9 +489,14 @@ class ClipGradByGlobalNorm(ClipGradBase):
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] = p.name
params_and_grads.append((p, p))
_correct_clip_op_role_var(params_and_grads, param_new_grad_name_dict)
return params_and_grads
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册