Skip to content

TensorRT

model_navigator.api.config.TensorRTPrecision

Bases: Enum

Precisions supported during TensorRT conversions.

model_navigator.api.config.TensorRTPrecisionMode

Bases: Enum

Precision modes for TensorRT conversions.

model_navigator.api.config.TensorRTConfig dataclass

Bases: CustomConfigForFormat

TensorRT custom config used for TensorRT conversion.

Parameters:

Name Type Description Default
precision Union[Union[str, TensorRTPrecision], Tuple[Union[str, TensorRTPrecision], ...]]

TensorRT precision.

DEFAULT_TENSORRT_PRECISION
max_workspace_size Optional[int]

Max workspace size used by converter.

DEFAULT_MAX_WORKSPACE_SIZE
trt_profile Optional[TensorRTProfile]

TensorRT profile.

None

format: Format property

Format represented by CustomConfig.

Returns:

Type Description
Format

TensorRTConfig format

__post_init__()

Parse dataclass enums.

Source code in model_navigator/api/config.py
def __post_init__(self) -> None:
    """Parse dataclass enums."""
    self.precision_mode = TensorRTPrecisionMode(self.precision_mode)
    precision = (self.precision,) if not isinstance(self.precision, (list, tuple)) else self.precision
    self.precision = tuple(TensorRTPrecision(p) for p in precision)

defaults()

Update parameters to defaults.

Source code in model_navigator/api/config.py
def defaults(self) -> None:
    """Update parameters to defaults."""
    self.precision = tuple(TensorRTPrecision(p) for p in DEFAULT_TENSORRT_PRECISION)
    self.precision_mode = DEFAULT_TENSORRT_PRECISION_MODE
    self.trt_profile = None
    self.max_workspace_size = DEFAULT_MAX_WORKSPACE_SIZE

from_dict(config_dict) classmethod

Instantiate TensorRTConfig from adictionary.

Source code in model_navigator/api/config.py
@classmethod
def from_dict(cls, config_dict: Dict[str, Any]) -> "TensorRTConfig":
    """Instantiate TensorRTConfig from  adictionary."""
    if "trt_profile" in config_dict and not isinstance(config_dict["trt_profile"], TensorRTProfile):
        config_dict["trt_profile"] = TensorRTProfile.from_dict(config_dict["trt_profile"])
    return cls(**config_dict)

name() classmethod

Name of the config.

Source code in model_navigator/api/config.py
@classmethod
def name(cls) -> str:
    """Name of the config."""
    return "TensorRT"