Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence an annoying warning #299

Merged
merged 1 commit into from
May 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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