From 81349970dcf4a3b16350327332c7363b490d861f Mon Sep 17 00:00:00 2001 From: Feiyu Chan Date: Tue, 23 Nov 2021 18:59:08 +0800 Subject: [PATCH] use ShareBufferWith instead of ShareDataWith for ops with view mechanism (#37464) --- paddle/fluid/pybind/op_function.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/pybind/op_function.h b/paddle/fluid/pybind/op_function.h index eaa70adcc89..997cb610faf 100644 --- a/paddle/fluid/pybind/op_function.h +++ b/paddle/fluid/pybind/op_function.h @@ -188,7 +188,7 @@ static inline void HandleViewBetweenInputAndOutput( auto* view_output_tensor = view_output_var->MutableVar()->GetMutable(); - view_output_tensor->ShareDataWith(input_tensor); + view_output_tensor->ShareBufferWith(input_tensor); view_output_tensor->ShareInplaceVersionCounterWith(input_tensor); VLOG(3) << "Perform View between Output Var(" << view_output_var->Name() @@ -314,7 +314,7 @@ static inline void CastPyArg2AttrString( Py_ssize_t size; const char* data; data = PyUnicode_AsUTF8AndSize(obj, &size); - attrs[key] = std::string(data, (size_t)size); + attrs[key] = std::string(data, static_cast(size)); } else { PADDLE_THROW(platform::errors::InvalidArgument( "%s(): argument (position %d) must be " @@ -674,7 +674,7 @@ static inline void CastPyArg2AttrStrings( Py_ssize_t size; const char* data; data = PyUnicode_AsUTF8AndSize(item, &size); - value.emplace_back(std::string(data, (size_t)size)); + value.emplace_back(std::string(data, static_cast(size))); } else { PADDLE_THROW(platform::errors::InvalidArgument( "%s(): argument (position %d) must be " @@ -737,7 +737,7 @@ static inline void ConstructAttrMapFromPyArgs( op_type, arg_pos, ((PyTypeObject*)obj->ob_type)->tp_name)); // NOLINT } - std::string key(key_ptr, (size_t)key_len); + std::string key(key_ptr, static_cast(key_len)); auto iter = attr_type_map->find(key); if (iter == attr_type_map->end()) { continue; -- GitLab