Skip to content

Commit 54629ca

Browse files
wanghuancoderchen2021673
authored andcommitted
conduct stop_gradient for pylayer output when not_inplace (PaddlePaddle#64567)
1 parent 04db220 commit 54629ca

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

paddle/fluid/pybind/eager_py_layer.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ PyObject* new_tensor_with_impl(paddle::Tensor* tensor) {
119119
new (&(v->tensor)) paddle::Tensor();
120120
v->tensor.set_impl(tensor->impl());
121121
v->tensor.set_name(egr::Controller::Instance().GenerateUniqueName());
122+
egr::EagerUtils::autograd_meta(&v->tensor)
123+
->SetStopGradient(
124+
egr::EagerUtils::autograd_meta(tensor)->StopGradient());
122125
} else {
123126
PADDLE_THROW(platform::errors::Fatal(
124127
"tp_alloc return null, can not new a PyObject."));

0 commit comments

Comments
 (0)