Shortcuts

Template Function torch_tensorrt::ptq::make_int8_calibrator

Function Documentation

template<typename Algorithm = nvinfer1::IInt8EntropyCalibrator2, typename DataLoader>
inline Int8Calibrator<Algorithm, DataLoader> torch_tensorrt::ptq::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. torch_tensorrt::ptq::make_int8_calibrator<nvinfer1::IInt8MinMaxCalibrator>(std::move(calibration_dataloader), calibration_cache_file, use_cache);

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

Returns

Int8Calibrator<Algorithm, DataLoader>

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