Skip to content

Commit ecd2c71

Browse files
fakeYanpytorchmergebot
authored andcommitted
Implement the get_device method in the storage base class. (#99818)
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
1 parent e514532 commit ecd2c71

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

torch/storage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def size(self) -> int:
3939
def type(self, dtype: str = None, non_blocking: bool = False) -> T: ... # noqa: E704
4040
def cuda(self, device=None, non_blocking=False, **kwargs) -> T: ... # noqa: E704
4141
def element_size(self) -> int: ... # noqa: E704
42-
def get_device(self) -> int: ... # noqa: E704
42+
43+
def get_device(self) -> int:
44+
return self.device.index
45+
4346
def data_ptr(self) -> int: ... # noqa: E704
4447

4548
# Defined in torch/csrc/generic/StorageSharing.cpp

0 commit comments

Comments
 (0)