Skip to content

Commit

Permalink
Implement the get_device method in the storage base class. (#99818)
Browse files Browse the repository at this point in the history
Fixes #ISSUE_NUMBER
like #99817, I find a method is missing,
I'm not sure if it was intentionally removed. But I found that the function is still called on the python side, and the function seems to be very simple to implement.
So I made a change in python side.

Pull Request resolved: #99818
Approved by: https://github.com/ezyang
  • Loading branch information
fakeYan authored and pytorchmergebot committed Apr 25, 2023
1 parent e514532 commit ecd2c71
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion torch/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def size(self) -> int:
def type(self, dtype: str = None, non_blocking: bool = False) -> T: ... # noqa: E704
def cuda(self, device=None, non_blocking=False, **kwargs) -> T: ... # noqa: E704
def element_size(self) -> int: ... # noqa: E704
def get_device(self) -> int: ... # noqa: E704

def get_device(self) -> int:
return self.device.index

def data_ptr(self) -> int: ... # noqa: E704

# Defined in torch/csrc/generic/StorageSharing.cpp
Expand Down

0 comments on commit ecd2c71

Please sign in to comment.