I think it is an elementary question about programming with GPU.
First, i tried to use time.time() in python module, to measure the operation time of some modules in NNs.
such as
def forward(self, x):
  end = time.time()
  output1 = self.layer1(x)
  time_output1 = time.time()
  output2 = self.layer2(output1)
  time_output2 = time.time()
  print(time_output1 - end, time_output2-end)

However, i found that the time information is inaccurate, and i have to use below link:

  
    
    
    How to measure time in PyTorch 
  
  
    I have seen lots of ways to measure time in PyTorch. But what is the most proper way to do it now (both for cpu and cuda)? 
Should I clear the memory cache if I use timeit? 
And is it possible to get accurate results if I’m computing on a cluster? And is it a way to make this results reproducible? 
And what is better: timeit or profiler?
  


Although i measure the correct time by the methods in the link,
i want to know why profiling with time.time() gives inaccurate results.
an example: https://github.com/facebookresearch/moco/issues/66 18
Thank you !