The fastest way to do this in PyTorch would be to repeatedly append to a list, then call torch.cat on the whole list once at the end. Assuming you’re on GPU, each call to torch.cat is a kernel invocation while appending to a list doesn’t touch the GPU.