Public Member Functions | |
def | __init__ (self, engine, name=None) |
def | get_input_metadata (self) |
def | activate_impl (self) |
def | set_shapes_from_feed_dict (self, feed_dict) |
def | infer_impl (self, feed_dict) |
def | deactivate_impl (self) |
def | last_inference_time (self) |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_value, traceback) |
def | activate (self) |
def | infer_impl (self) |
def | infer (self, feed_dict) |
def | deactivate (self) |
Public Attributes | |
owns_engine | |
owns_context | |
engine | |
context | |
host_output_buffers | |
stream | |
inference_time | |
name | |
is_active | |
Static Public Attributes | |
RUNNER_COUNTS = defaultdict(int) | |
Private Attributes | |
_engine_or_context | |
Runs inference using a TensorRT engine.
def polygraphy.backend.trt.runner.TrtRunner.__init__ | ( | self, | |
engine, | |||
name = None |
|||
) |
Args: engine (Callable() -> Union[trt.ICudaEngine, trt.IExecutionContext]): A callable that can supply either a TensorRT engine or execution context. If an engine is provided, the runner will create a context automatically. Otherwise, it will use the provided context. If instead of a callable, the object is provided directly, then the runner will *not* take ownership of it, and therefore will not destroy it. name (str): The human-readable name prefix to use for this runner. A runner count and timestamp will be appended to this prefix.
Reimplemented from polygraphy.backend.base.runner.BaseRunner.
def polygraphy.backend.trt.runner.TrtRunner.get_input_metadata | ( | self | ) |
Returns information about the inputs of the model. Shapes here may include dynamic dimensions, represented by ``None``. Must be called only after activate() and before deactivate(). Returns: TensorMetadata: Input names, shapes, and data types.
Reimplemented from polygraphy.backend.base.runner.BaseRunner.
def polygraphy.backend.trt.runner.TrtRunner.activate_impl | ( | self | ) |
Implementation for runner activation. Derived classes should override this function rather than ``activate()``.
Reimplemented from polygraphy.backend.base.runner.BaseRunner.
def polygraphy.backend.trt.runner.TrtRunner.set_shapes_from_feed_dict | ( | self, | |
feed_dict | |||
) |
Sets context shapes according to the provided feed_dict, then resizes buffers as needed. Args: feed_dict (OrderedDict[str, numpy.ndarray]): A mapping of input tensor names to corresponding input NumPy arrays. Returns: Tuple[int, int]: The start and end binding indices of the modified bindings.
def polygraphy.backend.trt.runner.TrtRunner.infer_impl | ( | self, | |
feed_dict | |||
) |
def polygraphy.backend.trt.runner.TrtRunner.deactivate_impl | ( | self | ) |
Implementation for runner deactivation. Derived classes should override this function rather than ``deactivate()``.
Reimplemented from polygraphy.backend.base.runner.BaseRunner.
|
inherited |
Returns the total inference time required during the last call to ``infer()``. Returns: float: The time in seconds, or None if runtime was not measured by the runner.
|
inherited |
|
inherited |
|
inherited |
Activate the runner for inference. This may involve allocating GPU buffers, for example.
|
inherited |
Implementation for runner inference. Derived classes should override this function rather than ``infer()``
|
inherited |
Runs inference using the provided feed_dict. Args: feed_dict (OrderedDict[str, numpy.ndarray]): A mapping of input tensor names to corresponding input NumPy arrays. Returns: OrderedDict[str, numpy.ndarray]: A mapping of output tensor names to their corresponding NumPy arrays. IMPORTANT: Runners may reuse these output buffers. Thus, if you need to save outputs from multiple inferences, you should make a copy with ``copy.copy(outputs)``.
|
inherited |
Deactivate the runner.
|
private |
polygraphy.backend.trt.runner.TrtRunner.owns_engine |
polygraphy.backend.trt.runner.TrtRunner.owns_context |
polygraphy.backend.trt.runner.TrtRunner.engine |
polygraphy.backend.trt.runner.TrtRunner.context |
polygraphy.backend.trt.runner.TrtRunner.host_output_buffers |
polygraphy.backend.trt.runner.TrtRunner.stream |
polygraphy.backend.trt.runner.TrtRunner.inference_time |
|
staticinherited |
|
inherited |
|
inherited |