Skip to content

Commit 81a5090

Browse files
committed
[FIX] use untyped_storage() instead of storage() if available
1 parent 8067d60 commit 81a5090

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nitorch/core/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,10 @@ def explore_dtype(x, n_pass=1):
637637
def same_storage(x, y):
638638
# type: (torch.Tensor, torch.Tensor) -> bool
639639
"""Return true if `x` and `y` share the same underlying storage."""
640-
return x.storage().data_ptr() == y.storage().data_ptr()
640+
if hasattr(x, 'untyped_storage'):
641+
return x.untyped_storage().data_ptr() == y.untyped_storage().data_ptr()
642+
else:
643+
return x.storage().data_ptr() == y.storage().data_ptr()
641644

642645

643646
def all_resident_tensors(no_duplicates=True):

0 commit comments

Comments
 (0)