提交 b05c253c 编写于 作者: F fengjiayi

fix an error

上级 6812e4f4
...@@ -53,7 +53,8 @@ def _is_all_in_set_(cands, s): ...@@ -53,7 +53,8 @@ def _is_all_in_set_(cands, s):
def _strip_grad_suffix_(name): def _strip_grad_suffix_(name):
return name[:name.find(core.grad_var_suffix())] pos = name.find(core.grad_var_suffix())
return name[:pos] if pos != -1 else name
def _append_grad_suffix_(name): def _append_grad_suffix_(name):
...@@ -139,7 +140,7 @@ def _append_backward_ops_(target, ...@@ -139,7 +140,7 @@ def _append_backward_ops_(target,
to_insert = [] to_insert = []
for idx, op_desc in enumerate(grad_op_descs): for idx, op_desc in enumerate(grad_op_descs):
for arg in op_desc.input_arg_names(): for arg in op_desc.input_arg_names():
if arg in no_grad_set[block.idx]: if core.grad_var_suffix() in arg and arg in no_grad_set[block.idx]:
to_insert.append((arg, idx)) to_insert.append((arg, idx))
for ele in reversed(to_insert): for ele in reversed(to_insert):
arg = ele[0] arg = ele[0]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册