MCPcopy Index your code
hub / github.com/pytorch/tutorials / get_perf

Function get_perf

intermediate_source/per_sample_grads.py:191–200  ·  view source on GitHub ↗

takes torch.benchmark objects and compares delta of second vs first.

(first, first_descriptor, second, second_descriptor)

Source from the content-addressed store, hash-verified

189# some results on our build machines:
190
191def get_perf(first, first_descriptor, second, second_descriptor):
192 """takes torch.benchmark objects and compares delta of second vs first."""
193 second_res = second.times[0]
194 first_res = first.times[0]
195
196 gain = (first_res-second_res)/first_res
197 if gain < 0: gain *=-1
198 final_gain = gain*100
199
200 print(f"Performance delta: {final_gain:.4f} percent improvement with {first_descriptor} ")
201
202from torch.utils.benchmark import Timer
203

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected