torch.cat is fast when you are doing it once. But if you are preparing data and doing cat in each iteration, it gets really slow when the tensor you are generating gets very large. My solution was to cat into a temp tensor and move it to the real tensor every N iterations. Not sure if there is a more elegant solution to this.