Squeeze and unsqueeze cost on GPU

In my model, I need to change data dimension (i.e: add 1 and remove 1), so I use squeeze and unsqueeze few times for each sample. How do squeeze and unsqueeze impact on computation cost. Does it slow down my model a lot ?

1 Like

Neither squeeze nor unsqueeze allocate new memory, they just change the view of the tensor, so I am tempted to say it should not matter much, but I could be wrong.

2 Likes