CUDA operations are executed asynchronously, so to get a valid timing you would have to manually synchronize the code before starting and stopping the timer via torch.cuda.synchronize().
In your current code you might ptofile the kernel launches and the first blocking operation would accumulate the timings of other kernels.