Skip to content

Commit 80abad3

Browse files
authored
Handle Tensor.__deepcopy__ via clone(), on IPU (#89129) (#89999)
Currently it falls through to a call to `storage()`, which the IPU doesn't support. I've made the minimal change here for ease of merging (this'd help us if it was in for 1.13.1), however... **QUESTION**: Is there any reason why `not torch._C._has_storage(self)` needs to *also* be guarded on `self.device.type == privateuseone`? in other words, could the condition for using `clone` not be this? ```python self.is_sparse or self.device.type in ["lazy", "xla", "mps", "ort", "meta", "hpu", "ipu"] or not torch._C._has_storage(self) or (type(self) is not Tensor and self.data_ptr() == 0) ``` If the condition fails, the very next thing is a call to `self._typed_storage()` which will fail, so it feels to me like *any* case without storage shouldn't fall through to the `storage()` call. The original PR for adding the 'no storage and device is `PrivateUse1`' condition ([86557](#86557)) doesn't discuss whether this could be broadened. Pull Request resolved: #89129 Approved by: https://github.com/albanD
1 parent 73a852a commit 80abad3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

torch/_tensor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def __deepcopy__(self, memo):
113113
# Update the test in test_serialization if you remove 'meta' from here
114114
if (
115115
self.is_sparse
116-
or self.device.type in ["lazy", "xla", "mps", "ort", "meta", "hpu"]
116+
or self.device.type
117+
in ["lazy", "xla", "mps", "ort", "meta", "hpu", "ipu"]
117118
or (
118119
not torch._C._has_storage(self)
119120
and self.device.type == "privateuseone"

0 commit comments

Comments
 (0)