Template Function torch_tensorrt::ptq::make_int8_cache_calibrator¶
定義於 檔案 ptq.h
函數文件¶
-
template<typename Algorithm = nvinfer1::IInt8EntropyCalibrator2>
inline Int8CacheCalibrator<Algorithm> torch_tensorrt::ptq::make_int8_cache_calibrator(const std::string &cache_file_path)¶ 一個工廠,用於從僅使用校正快取的 torch dataloader 建置訓練後量化校正器。
建立一個用於訓練後量化的校正器,該校正器從先前建立的校正快取讀取,因此您可以擁有一個需要 dataloader 和資料集的校正快取產生程式,然後儲存快取以供稍後在另一個需要從頭開始校正且沒有資料集依賴性的程式中使用。但是,如果網路結構發生變化,或輸入資料集發生變化,也應重新校正網路,應用程式有責任確保這一點。
預設情況下,傳回的校正器使用 TensorRT Entropy v2 演算法執行校正。這適用於前饋網路。您可以透過使用校正器類別作為範本參數呼叫 make_int8_calibrator 來覆寫演算法選擇(例如使用 NLP 任務推薦的 MinMax 校正器)。
例如:torch_tensorrt::ptq::make_int8_cache_calibrator<nvinfer1::IInt8MinMaxCalibrator>(calibration_cache_file);
- 範本參數
Algorithm – class nvinfer1::IInt8Calibrator(預設值:nvinfer1::IInt8EntropyCalibrator2)- 要使用的演算法
- 參數
cache_file_path – const std::string& - 讀取/寫入校正快取的路徑
- 傳回
Int8CacheCalibrator<Algorithm>