Torch.cat, torch.stack. Which one?

For fusing two feature maps, which method does it faster (less memory needed) and more efficient?

Torch.cat() or Torch.stack()?
Thanks!

1 Like

Hi,

Both methods will have the exact same speed and memory footprint.
The only different is that one works with an existing dimension, while the other adds a new dimension.
You can see stack as just calling unsqueeze() on each tensor, then cat.

6 Likes

Thanks @albanD. It clear now!