未验证 提交 fe6aacc0 编写于 作者: X Xiaoxu Chen 提交者: GitHub

replace clone with assign for copying tensor in current block (#45309)

上级 1a0cd447
...@@ -633,7 +633,7 @@ def _single_separate(x): ...@@ -633,7 +633,7 @@ def _single_separate(x):
if x is None: # x maybe none because grad input's v defaults to none. if x is None: # x maybe none because grad input's v defaults to none.
return x return x
if not x.stop_gradient: if not x.stop_gradient:
return paddle.clone(x) return paddle.assign(x)
else: # use detach to share memory when no need gradients. else: # use detach to share memory when no need gradients.
x = x.detach() x = x.detach()
x.stop_gradient = False x.stop_gradient = False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册