Skip to content

Commit

Permalink
fix memory leak problen of set_value op (PaddlePaddle#38098)
Browse files Browse the repository at this point in the history
* fix bug of set_value op

* fix BumpInplaceVersion

* polish some comments

* revert change of full_like
  • Loading branch information
zyfncg committed Dec 29, 2021
1 parent f6aebf3 commit 9a5472c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions paddle/fluid/pybind/imperative.cc
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,11 @@ void BindImperative(py::module *m_ptr) {
}
};

// NOTE(liym27):
// Increase the version of VarBase self because __setitem__ is an
// inplace operator for the VarBase self.
self->BumpInplaceVersion();

// 1. Check argumnets
bool parse_index = true;

Expand Down Expand Up @@ -1107,10 +1112,6 @@ void BindImperative(py::module *m_ptr) {
SetTensorFromPyArray(self_tensor, self_numpy,
self_tensor->place(), false);
}
// NOTE(liym27):
// Increase the version of VarBase self because __setitem__ is an
// inplace operator for the VarBase self.
self->BumpInplaceVersion();
})
.def("_getitem_index_not_tensor",
[](std::shared_ptr<imperative::VarBase> &self, py::handle _index) {
Expand Down

0 comments on commit 9a5472c

Please sign in to comment.