Efficiently converting a 2D list, given 1 row at a time, to a Tensor

Is there a faster way than accumulating a 2d list (the program is given 1 row at a time), then converting the whole list all at once to a PyTorch Tensor? Is using torch.cat or torch.stack (converting each row to a Tensor first) more efficient?

This is to be inputted into a neural network, so the rows should be adjacent in memory.

I don’t see torch.cat / torch.stack to be more efficient than accumulating into a 2d list and then converting it to a tensor. You could try it and see how it goes, though.