Profiler¶
- class tensorrt.IProfiler(self: tensorrt.tensorrt.IProfiler)¶
抽象基类 Profiler 类。
要实现自定义 profiler,请确保在
__init__()
中显式实例化基类class MyProfiler(trt.IProfiler): def __init__(self): trt.IProfiler.__init__(self) def report_layer_time(self, layer_name, ms): ... # Your implementation here
当此类添加到
IExecutionContext
时,对于每次调用IExecutionContext.execute_v2()
,将为每个层调用 profiler 一次。当推理执行时间至关重要时,不建议启用 profiler 运行推理,因为 profiler 可能会对执行时间产生负面影响。
- report_layer_time(self: tensorrt.tensorrt.IProfiler, layer_name: str, ms: float) None ¶
报告每个层的毫秒时间。此函数必须在派生类中被覆盖。
- 参数:
layer_name – 层的名称,在构建
INetworkDefinition
时设置。如果引擎构建时分析详细程度设置为 NONE,则 layerName 是层的十进制索引。ms – 执行层的时间,以毫秒为单位。
- class tensorrt.Profiler(self: tensorrt.tensorrt.Profiler)¶
当此类添加到
IExecutionContext
时,对于每次调用IExecutionContext.execute_v2()
,将为每个层调用 profiler 一次。当推理执行时间至关重要时,不建议启用 profiler 运行推理,因为 profiler 可能会对执行时间产生负面影响。
- report_layer_time(self: tensorrt.tensorrt.IProfiler, layer_name: str, ms: float) None ¶
将每个层的毫秒时间打印到标准输出。
- 参数:
layer_name – 层的名称,在构建
INetworkDefinition
时设置。ms – 执行层的时间,以毫秒为单位。