In theory no. Mostly because ops like transpose or squeeze don’t actually touch the content of the Tensor. And so won’t even need to run anything on the GPU: they only change the Tensor metadata stored in ram.
In practice, GPU optimization is quite hard and there is no silver bullet there. So you can actually see wildly different behaviors for similar ops just because you transpose or unsqueeze a different dimension.
So you will have to run the code to see which one is faster in practice.
Don’t forget the proper synchronization with torch.cuda.synchronize() to get proper timings on the GPU.