From fe6aacc01914aa98d49024c194f5fd7c1609eea8 Mon Sep 17 00:00:00 2001 From: Xiaoxu Chen Date: Tue, 23 Aug 2022 16:32:05 +0800 Subject: [PATCH] replace clone with assign for copying tensor in current block (#45309) --- python/paddle/incubate/autograd/functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/incubate/autograd/functional.py b/python/paddle/incubate/autograd/functional.py index 3be95c88d1..79ba7d3309 100644 --- a/python/paddle/incubate/autograd/functional.py +++ b/python/paddle/incubate/autograd/functional.py @@ -633,7 +633,7 @@ def _single_separate(x): if x is None: # x maybe none because grad input's v defaults to none. return x if not x.stop_gradient: - return paddle.clone(x) + return paddle.assign(x) else: # use detach to share memory when no need gradients. x = x.detach() x.stop_gradient = False -- GitLab