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

tensor add storage method #10311

Merged
merged 3 commits into from
Aug 9, 2023
Merged
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
5 changes: 5 additions & 0 deletions python/oneflow/framework/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ def _conj_physical(self):
return flow._C.conj_physical(self)


def _storage(self):
return self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这只是个快速的修复,oneflow tensor 貌似内部还没有 storage 这个接口暴露出来,而是直接有个 data_ptr

{"data_ptr", PyTensorObject_data_ptr, METH_NOARGS, NULL},



@property
def _layout(self):
return flow.strided
Expand Down Expand Up @@ -610,6 +614,7 @@ def RegisterMethods():
Tensor.conj = _conj
Tensor.conj_physical = _conj_physical
Tensor.layout = _layout
Tensor.storage = _storage


def register_tensor_op(op_name):
Expand Down
Loading