MCPcopy Create free account
hub / github.com/pytorch/tutorials / get_perf

Function get_perf

intermediate_source/jacobians_hessians.py:112–119  ·  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

110# microseconds and milliseconds measurements:
111
112def get_perf(first, first_descriptor, second, second_descriptor):
113 """takes torch.benchmark objects and compares delta of second vs first."""
114 faster = second.times[0]
115 slower = first.times[0]
116 gain = (slower-faster)/slower
117 if gain < 0: gain *=-1
118 final_gain = gain*100
119 print(f" Performance delta: {final_gain:.4f} percent improvement with {second_descriptor} ")
120
121######################################################################
122# And then run the performance comparison:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected