Skip to content

# torch_tensorrt.ptq

class `torch_tensorrt.ptq.` `CacheCalibrator` ( * args , ** kwargs )

  Bases: `object`

  Constructs a calibrator class in TensorRT which directly uses pre-existing cache file for calibration. :param cache_file: path to cache file. :param algo_type: choice of calibration algorithm.

class `torch_tensorrt.ptq.` `CalibrationAlgo` ( value )

  Bases: `enum.Enum`

  An enumeration.

  `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>

class `torch_tensorrt.ptq.` `DataLoaderCalibrator` ( * args , ** kwargs )

  Bases: `object`

  Constructs a calibrator class in TensorRT and uses pytorch dataloader to load/preproces data which is passed during calibration. :param dataloader: an instance of pytorch dataloader which iterates through a given dataset. :param algo_type: choice of calibration algorithm. :param cache_file: path to cache file. :param use_cache: flag which enables usage of pre-existing cache. :param device: device on which calibration data is copied to.

`torch_tensorrt.ptq.` `get_batch` ( self , names )

`torch_tensorrt.ptq.` `get_batch_size` ( self )

`torch_tensorrt.ptq.` `get_cache_mode_batch` ( self )

`torch_tensorrt.ptq.` `read_calibration_cache` ( self )

`torch_tensorrt.ptq.` `write_calibration_cache` ( self , cache )

# Classes

class `torch_tensorrt.ptq.` `DataLoaderCalibrator` ( * args , ** kwargs )

  Constructs a calibrator class in TensorRT and uses pytorch dataloader to load/preproces data which is passed during calibration. :param dataloader: an instance of pytorch dataloader which iterates through a given dataset. :param algo_type: choice of calibration algorithm. :param cache_file: path to cache file. :param use_cache: flag which enables usage of pre-existing cache. :param device: device on which calibration data is copied to.

  `__init__` ( ** kwargs )

    Initialize self. See help(type(self)) for accurate signature.

class `torch_tensorrt.ptq.` `CacheCalibrator` ( * args , ** kwargs )

  Constructs a calibrator class in TensorRT which directly uses pre-existing cache file for calibration. :param cache_file: path to cache file. :param algo_type: choice of calibration algorithm.

  `__init__` ( ** kwargs )

    Initialize self. See help(type(self)) for accurate signature.

# Enums

class `torch_tensorrt.ptq.` `CalibrationAlgo` ( value )

  An enumeration.