I implemented this idea, and it turned out that it is very slow.
When I know the size of the tensor and create it with torch::zeros() and fill it in a loop, it is way faster than using torch::cat.
Is there any other way to handle this?