Profiler

class tensorrt.IProfiler(self: tensorrt.tensorrt.IProfiler) None

Abstract base Profiler class.

To implement a custom profiler, ensure that you explicitly instantiate the base class in __init__() :

class MyProfiler(trt.IProfiler):
    def __init__(self):
        trt.IProfiler.__init__(self)

    def report_layer_time(self, layer_name, ms):
        ... # Your implementation here

When this class is added to an IExecutionContext, the profiler will be called once per layer for each invocation of IExecutionContext.execute_v2().

It is not recommended to run inference with profiler enabled when the inference execution time is critical since the profiler may affect execution time negatively.

report_layer_time(self: tensorrt.tensorrt.IProfiler, layer_name: str, ms: float) None

Reports time in milliseconds for each layer. This function must be overriden a derived class.

Parameters
  • layer_name – The name of the layer, set when constructing the INetworkDefinition . If the engine is built with profiling verbosity set to NONE, the layerName is the decimal index of the layer.

  • ms – The time in milliseconds to execute the layer.

class tensorrt.Profiler(self: tensorrt.tensorrt.Profiler) None

When this class is added to an IExecutionContext, the profiler will be called once per layer for each invocation of IExecutionContext.execute_v2().

It is not recommended to run inference with profiler enabled when the inference execution time is critical since the profiler may affect execution time negatively.

report_layer_time(self: tensorrt.tensorrt.IProfiler, layer_name: str, ms: float) None

Prints time in milliseconds for each layer to stdout.

Parameters
  • layer_name – The name of the layer, set when constructing the INetworkDefinition .

  • ms – The time in milliseconds to execute the layer.