樣板函式 torch_tensorrt::ptq::make_int8_calibrator¶
定義於 檔案 ptq.h
函式文件¶
-
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)¶ 一個工廠函式,用於從 torch 資料載入器建構訓練後量化校正器。
建立一個校正器,用於訓練後量化。預設情況下,傳回的校正器使用 TensorRT Entropy v2 演算法來執行校正。建議用於前饋網路。您可以覆寫演算法選擇(例如使用 NLP 任務建議的 MinMax 校正器),方法是使用校正器類別作為樣板參數來呼叫 make_int8_calibrator。
例如:
torch_tensorrt::ptq::make_int8_calibrator<nvinfer1::IInt8MinMaxCalibrator>(std::move(calibration_dataloader), calibration_cache_file, use_cache);
- 樣板參數
Algorithm – class nvinfer1::IInt8Calibrator (預設值:nvinfer1::IInt8EntropyCalibrator2) - 要使用的演算法
DataLoader – std::unique_ptr<torch::data::DataLoader> - DataLoader 類型
- 參數
dataloader – std::unique_ptr<torch::data::DataLoader> - 包含資料的 DataLoader
cache_file_path – const std::string& - 讀取/寫入校正快取的路徑
use_cache – bool - 使用校正快取
- 傳回
Int8Calibrator<Algorithm, DataLoader>