trtutils.inspect package¶
Module contents¶
Submodule containing tools for inspecting TensorRT engines.
Classes¶
LayerInfoDetailed information about a single layer in a TensorRT network.
Functions¶
get_engine_names()Get the input/output names of a TensorRT engine in order.
get_tensor_size()Calculate the size of a TensorRT tensor in bytes.
inspect_engine()Inspect a TensorRT engine.
inspect_onnx_layers()Inspect the layers of an ONNX model.
- class trtutils.inspect.LayerInfo(index: int, name: str, layer_type: str, precision: trt.DataType, input_tensor_size: int, output_tensor_size: int, dla_compatible: bool)[source]¶
Bases:
objectInformation about a single layer in a TensorRT network.
- precision¶
The precision of the layer.
- Type:
trt.DataType
- precision: trt.DataType¶
- trtutils.inspect.get_engine_names(engine: TRTEngine | Path | str) tuple[list[str], list[str]][source]¶
Get the input/output names of a TensorRT engine in order.
- trtutils.inspect.get_tensor_size(tensor: ITensor) int[source]¶
Calculate the size of a tensor in bytes.
Computes the total memory footprint by multiplying the number of elements (derived from the tensor shape) by the per-element byte size of the dtype. Dynamic dimensions (
-1) are treated as1.- Parameters:
tensor (trt.ITensor) – The TensorRT tensor.
- Returns:
Size in bytes.
- Return type:
- trtutils.inspect.inspect_engine(engine: Path | str | ICudaEngine, *, verbose: bool | None = None) tuple[int, int, list[tuple[str, tuple[int, ...], DataType, TensorFormat]], list[tuple[str, tuple[int, ...], DataType, TensorFormat]]][source]¶
Inspect a TensorRT engine.
- trtutils.inspect.inspect_onnx_layers(onnx: trt.INetworkDefinition | Path | str, config: trt.IBuilderConfig | None = None, *, verbose: bool | None = None) list[LayerInfo][source]¶
Inspect the layers that TensorRT would create from an ONNX model.
Returns detailed per-layer information including tensor sizes, precision, and DLA compatibility. On non-DLA systems,
dla_compatibleis alwaysFalse.- Parameters:
onnx (Path | str | trt.INetworkDefinition) – Path to the ONNX model or an already constructed TensorRT network.
config (trt.IBuilderConfig | None, optional) – The TensorRT builder config. Required if
onnxis a pre-built network and DLA compatibility checking is desired.verbose (bool | None, optional) – When True, logs detailed layer information.
- Returns:
Per-layer information.
- Return type:
- Raises:
ValueError – If
onnxis a network andconfigis not provided.