Skip to content

Commit

Permalink
Silence an annoying warning (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmke8 committed May 10, 2023
2 parents 59485d6 + ebc8e4b commit e3f4db6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion conduit/data/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ def _collate(self, batch: Any) -> Any:
# If we're in a background process, concatenate directly into a
# shared memory tensor to avoid an extra copy
numel = sum(x.numel() for x in batch)
storage = elem.storage()._new_shared(numel)
if hasattr(elem, "_typed_storage"): # in PyTorch 2.0, it's called _typed_storage
storage = elem._typed_storage()._new_shared(numel, device=elem.device)
else:
storage = elem.storage()._new_shared(numel)
out = elem.new(storage).resize_(len(batch), *list(elem.size()))
ndims = elem.dim()
# If 'batch' is a sequence of sub-batched tensors we concatenate the elements along the
Expand Down

0 comments on commit e3f4db6

Please sign in to comment.