提交 6295f843 编写于 作者: M Megvii Engine Team

fix(mge/tensor): fix mem leak when getting value in trace

GitOrigin-RevId: 8bca2e738016f9ed45a3c413b1024976ea0cd952
上级 5db17907
......@@ -1002,8 +1002,7 @@ class CompiledTensorProxy:
else:
# c++ will throw TraceReadError
return None
if self._isscalar:
self.__value = self.__value.squeeze()
# c++ side will handle scalar case
return self.__value
def _dev_tensor(self):
......
......@@ -393,7 +393,9 @@ PyObject* TensorWrapper::numpy() {
throw TraceReadError("value of this tensor is not read in trace");
}
if (m_tensor->m_flags & Tensor::Flags::SCALAR) {
np_val = PyArray_Squeeze(reinterpret_cast<PyArrayObject*>(np_val));
PyObject *np_scalar = PyArray_Squeeze(reinterpret_cast<PyArrayObject*>(np_val));
Py_DECREF(np_val);
return np_scalar;
}
return np_val;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册