From f8202941b6000cbc64d900e975edd8c8bb9a2fba Mon Sep 17 00:00:00 2001 From: zyfncg Date: Tue, 14 Dec 2021 20:14:00 +0800 Subject: [PATCH] fix memory leak problen of set_value op (#38098) * fix bug of set_value op * fix BumpInplaceVersion * polish some comments * revert change of full_like --- paddle/fluid/pybind/imperative.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/pybind/imperative.cc b/paddle/fluid/pybind/imperative.cc index 080323bbc25..00fe2c8da7e 100644 --- a/paddle/fluid/pybind/imperative.cc +++ b/paddle/fluid/pybind/imperative.cc @@ -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; @@ -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 &self, py::handle _index) { -- GitLab