Hi!
Most of the time; i do
my_list = []  # will create the list on the CPU
for x in some_tensor:  # elements of some_tensor are on GPU
     v =  process(x) # Return a tensor(val, device='cuda:0')
     my_list.append(v)

# convert my_list back into a tensor ---> and move the list back to the GPU
my_list = torch.from_numpy(my_list)
my_list = my_list.to(device)

Is it possible to create an empty tensor my_list = torch.cuda.FloatTensor(...) and directly use it as an accumulator? If yes, how to initialize the size of the list  when i don’t know the size.
Using a list and then converting the list back to a tensor and moving the tensor back on the GPU  is overloading. (I guess). I assume creating a numpy list in the forward function happens on the CPU.
How can I accumulate tensor and do the work while on the GPU?
Thank you.