Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data_ptr method return None bug #49173

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions paddle/fluid/pybind/eager_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1896,9 +1896,10 @@ static PyObject* tensor_data_ptr(TensorObject* self,
PyObject* kwargs) {
EAGER_TRY
if (self->tensor.initialized() && self->tensor.is_dense_tensor()) {
ToPyObject((int64_t)std::dynamic_pointer_cast<phi::DenseTensor>( // NOLINT
self->tensor.impl())
->data());
return ToPyObject(
(int64_t)std::dynamic_pointer_cast<phi::DenseTensor>( // NOLINT
self->tensor.impl())
->data());
}
RETURN_PY_NONE
EAGER_CATCH_AND_THROW_RETURN_NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_tensor_data_ptr(self):
src = paddle.to_tensor(np_src, dtype="float64")
dst = paddle.Tensor()
src._share_buffer_to(dst)
self.assertTrue(src.data_ptr() is not None)
self.assertEqual(src.data_ptr(), dst.data_ptr())


Expand Down