Skip to content

# Template Function trtorch::ptq::make_int8_calibrator

- Defined in File trtorch.h

## Function Documentation

template<typename `Algorithm` = nvinfer1::IInt8EntropyCalibrator2, typename `DataLoader` >
TRTORCH_API Int8Calibrator< Algorithm , DataLoader > `ptq::trtorch `::`` `make_int8_calibrator` ( DataLoader dataloader , const std::string & cache_file_path , bool use_cache )

  A factory to build a post training quantization calibrator from a torch dataloader.

  Creates a calibrator to use for post training quantization. By default the returned calibrator uses TensorRT Entropy v2 algorithm to perform calibration. This is recommended for feed forward networks. You can override the algorithm selection (such as to use the MinMax Calibrator recomended for NLP tasks) by calling make_int8_calibrator with the calibrator class as a template parameter.

  e.g. `trtorch::ptq::make_int8_calibrator<nvinfer1::IInt8MinMaxCalibrator>(std::move(calibration_dataloader), calibration_cache_file, use_cache);`

  Return

    Int8Calibrator<Algorithm, DataLoader>

  Template Parameters

    - `Algorithm` : class nvinfer1::IInt8Calibrator (Default: nvinfer1::IInt8EntropyCalibrator2) - Algorithm to use

    - `DataLoader` : std::unique_ptr<torch::data::DataLoader> - DataLoader type

  Parameters

    - `dataloader` : std::unique_ptr<torch::data::DataLoader> - DataLoader containing data

    - `cache_file_path` : const std::string& - Path to read/write calibration cache

    - `use_cache` : bool - use calibration cache