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 authored and Caozhou1995 committed Dec 28, 2021
1 parent d038063 commit dfeb15b
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 @@ -970,6 +970,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 @@ -1137,10 +1142,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 dfeb15b

Please sign in to comment.