MCPcopy Index your code
hub / github.com/OpenPPL/ppq / MyProfiler

Class MyProfiler

ppq/utils/TensorRTUtil.py:266–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264
265
266class MyProfiler(trt.IProfiler):
267 def __init__(self, steps: int):
268 trt.IProfiler.__init__(self)
269 self.total_runtime = 0.0
270 self.recorder = defaultdict(lambda: 0.0)
271 self.steps = steps
272
273 def report_layer_time(self, layer_name: str, ms: float):
274 self.total_runtime += ms * 1000 / self.steps
275 self.recorder[layer_name] += ms * 1000 / self.steps
276
277 def report(self):
278 MeasurePrinter(data=self.recorder, measure='RUNNING TIME(us)', order=None).print()
279 print(f'\nTotal Inference Time: {self.total_runtime:.4f}(us)')
280 print('You should notice that inference time != Lantancy, cause layer can be executed concurrently.')
281
282
283def Benchmark(engine_file: str, steps: int = 10000) -> float:

Callers 1

ProfilingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected