Skip to content

Commit

Permalink
conduct stop_gradient for pylayer output when not_inplace (#64567)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghuancoder authored May 24, 2024
1 parent e8cedeb commit 5b79bca
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions paddle/fluid/pybind/eager_py_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ PyObject* new_tensor_with_impl(paddle::Tensor* tensor) {
new (&(v->tensor)) paddle::Tensor();
v->tensor.set_impl(tensor->impl());
v->tensor.set_name(egr::Controller::Instance().GenerateUniqueName());
egr::EagerUtils::autograd_meta(&v->tensor)
->SetStopGradient(
egr::EagerUtils::autograd_meta(tensor)->StopGradient());
} else {
PADDLE_THROW(platform::errors::Fatal(
"tp_alloc return null, can not new a PyObject."));
Expand Down

0 comments on commit 5b79bca

Please sign in to comment.