spdl.io.transfer_tensor

transfer_tensor(batch: T, /, *, num_caches: int = 4) → T[source]

Transfer PyTorch tensors from CPU to CUDA in a dedicated stream.

Deprecated since version 0.8.0: Use spdl.io.transfer_tensor_h2d() instead.

Parameters:
  • batch – A torch.Tensor or a composition of tensors with container types such as list, tuple, dict and dataclass.

  • num_caches – Number of recent output batches retained to mitigate allocator races across CUDA streams.

Returns:

An object of the same type as the input, with CPU tensors transferred to CUDA.