ProgressMonitor¶
- class tensorrt.IProgressMonitor(self: tensorrt.tensorrt.IProgressMonitor)¶
Application-implemented progress reporting interface for TensorRT.
The IProgressMonitor is a user-defined object that TensorRT uses to report back when an internal algorithm has started or finished a phase to help provide feedback on the progress of the optimizer.
The IProgressMonitor will trigger its start function when a phase is entered and will trigger its finish function when that phase is exited. Each phase consists of one or more steps. When each step is completed, the step_complete function is triggered. This will allow an application using the builder to communicate progress relative to when the optimization step is expected to complete.
The implementation of IProgressMonitor must be thread-safe so that it can be called from multiple internal threads. The lifetime of the IProgressMonitor must exceed the lifetime of all TensorRT objects that use it.
- phase_finish(self: tensorrt.tensorrt.IProgressMonitor, phase_name: str) None ¶
Signal that a phase of the optimizer has finished.
- Parameters:
phase_name – The name of the phase that has finished.
The phase_finish function signals to the application that the phase is complete. This function may be called before all steps in the range [0, num_steps) have been reported to step_complete. This scenario can be triggered by error handling, internal optimizations, or when step_complete returns False to request cancellation of the build.
- phase_start(self: tensorrt.tensorrt.IProgressMonitor, phase_name: str, parent_phase: str, num_steps: int) None ¶
Signal that a phase of the optimizer has started.
- Parameters:
phase_name – The name of this phase for tracking purposes.
parent_phase – The parent phase that this phase belongs to, None if there is no parent.
num_steps – The number of steps that are involved in this phase.
The phase_start function signals to the application that the current phase is beginning, and that it has a certain number of steps to perform. If phase_parent is None, then the phase_start is beginning an independent phase, and if phase_parent is specified, then the current phase, specified by phase_name, is within the scope of the parent phase. num_steps will always be a positive number. The phase_start function implies that the first step is being executed. TensorRT will signal when each step is complete.
Phase names are human readable English strings which are unique within a single phase hierarchy but which can be reused once the previous instance has completed. Phase names and their hierarchies may change between versions of TensorRT.
- step_complete(self: tensorrt.tensorrt.IProgressMonitor, phase_name: str, step: int) bool ¶
Signal that a step of an optimizer phase has finished.
- Parameters:
phase_name – The name of the innermost phase being executed.
step – The step number that was completed.
The step_complete function signals to the application that TensorRT has finished the current step for the phase
phase_name
, and will move on to the next step if there is one. The application can return False for TensorRT to exit the build early. The step value will increase on subsequent calls in the range [0, num_steps).- Returns:
True to continue to the next step or False to stop the build.