Shortcuts

torch_tensorrt.ts.ptq

These components are legacy quantization utilities designed to work with the TorchScript Frontend. They have been replaced by the TensorRT Model Optimizer toolkit which can be used with the dynamo frontend:

Classes

class torch_tensorrt.ts.ptq.DataLoaderCalibrator(*args: Any, **kwargs: Any)[source]

Constructs a calibrator class in TensorRT and uses pytorch dataloader to load/preprocess data which is passed during calibration.

Parameters
  • dataloader (torch.utils.data.DataLoader) – an instance of pytorch dataloader which iterates through a given dataset.

  • algo_type (CalibrationAlgo) – choice of calibration algorithm.

  • cache_file (str) – path to cache file.

  • use_cache (bool) – flag which enables usage of pre-existing cache.

  • device (Device) – device on which calibration data is copied to.

class torch_tensorrt.ts.ptq.CacheCalibrator(*args: Any, **kwargs: Any)[source]

Constructs a calibrator class in TensorRT which directly uses pre-existing cache file for calibration.

Parameters
  • cache_file (str) – path to cache file.

  • algo_type (CalibrationAlgo) – choice of calibration algorithm.

Enums

class torch_tensorrt.ts.ptq.CalibrationAlgo(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
ENTROPY_CALIBRATION = <CalibrationAlgo.ENTROPY_CALIBRATION: 1>
ENTROPY_CALIBRATION_2 = <CalibrationAlgo.ENTROPY_CALIBRATION_2: 2>
LEGACY_CALIBRATION = <CalibrationAlgo.LEGACY_CALIBRATION: 0>
MINMAX_CALIBRATION = <CalibrationAlgo.MINMAX_CALIBRATION: 3>

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources