Skip to content

Commit

Permalink
use ShareBufferWith instead of ShareDataWith for ops with view mechan…
Browse files Browse the repository at this point in the history
…ism (#37464)
  • Loading branch information
Feiyu Chan authored Nov 23, 2021
1 parent e91141f commit 8134997
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions paddle/fluid/pybind/op_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static inline void HandleViewBetweenInputAndOutput(

auto* view_output_tensor =
view_output_var->MutableVar()->GetMutable<framework::LoDTensor>();
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()
Expand Down Expand Up @@ -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_t>(size));
} else {
PADDLE_THROW(platform::errors::InvalidArgument(
"%s(): argument (position %d) must be "
Expand Down Expand Up @@ -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_t>(size)));
} else {
PADDLE_THROW(platform::errors::InvalidArgument(
"%s(): argument (position %d) must be "
Expand Down Expand Up @@ -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<size_t>(key_len));
auto iter = attr_type_map->find(key);
if (iter == attr_type_map->end()) {
continue;
Expand Down

0 comments on commit 8134997

Please sign in to comment.