I want to transfer multiple unrelated tensors at once from the GPU to the CPU. What’s the best way to accomplish this from a performance and readability perspective? I tried something like this:
batch_transfer = torch.cat((first.unsqueeze(0), second.unsqueeze(0), third.unsqueeze(0))).cpu()
first = batch_transfer[0]
second = batch_transfer[1]
third = batch_transfer[2]

This works but it’s problematic from a readability perspective and I’m also forced to group tensors batch on their shape. If I want to transfer tensors with different shapes, I need to transfer them separately. Is there a better way to do this?