MCPcopy
hub / github.com/OpenPPL/ppq / Profiling

Function Profiling

ppq/utils/TensorRTUtil.py:306–325  ·  view source on GitHub ↗

Profiling TensorRT Engine

(engine_file: str, steps: int = 1000)

Source from the content-addressed store, hash-verified

304
305
306def Profiling(engine_file: str, steps: int = 1000):
307 """ Profiling TensorRT Engine """
308 logger = trt.Logger(trt.Logger.ERROR)
309 import pycuda.autoinit
310
311 with open(engine_file, 'rb') as f, trt.Runtime(logger) as runtime:
312 engine = runtime.deserialize_cuda_engine(f.read())
313
314 with engine.create_execution_context() as context:
315 context.profiler = MyProfiler(steps)
316 inputs, outputs, bindings, stream = allocate_buffers(context.engine)
317
318 for input in inputs:
319 input.host = convert_any_to_numpy(torch.rand(input.host.shape).float())
320
321 for _ in tqdm(range(steps), desc='TensorRT is running...'):
322 do_inference_v2(
323 context, bindings=bindings, inputs=inputs,
324 outputs=outputs, stream=stream)
325 context.profiler.report()
326
327
328def TestAlignment(engine_file: str, graph: BaseGraph, samples: Iterable, collate_fn: Callable = None) -> dict:

Callers 3

yolo_5.pyFile · 0.90
02_Quantization.pyFile · 0.90

Calls 5

convert_any_to_numpyFunction · 0.90
MyProfilerClass · 0.85
allocate_buffersFunction · 0.70
do_inference_v2Function · 0.70
reportMethod · 0.45

Tested by

no test coverage detected