捷徑

樣板類別 Int8Calibrator

繼承關係

基底類型

  • private Algorithm

類別文件

template<typename Algorithm, typename DataLoaderUniquePtr>
class Int8Calibrator : private Algorithm

基於指定的 TensorRT 校正演算法和 LibTorch DataLoader 的通用 Int8Calibrator 實作。

樣板參數
  • Algorithm – class nvinfer1::IInt8Calibrator (預設值:nvinfer1::IInt8EntropyCalibrator2) - 要使用的演算法

  • DataLoaderUniquePtr – std::unique_ptr<torch::data::DataLoader> - DataLoader 類型

公開函式

inline Int8Calibrator(DataLoaderUniquePtr dataloader, const std::string &cache_file_path, bool use_cache)

建構新的 Int8Calibrator 物件。

使用提供的 DataLoader,建構一個可用於 Torch-TensorRT 的 PTQ 校正器

參數
  • dataloader – std::unqiue_ptr<torch::data::DataLoader> - DataLoader 的 unique pointer,應為從 make_data_loader 工廠傳回的內容

  • cache_file_path – const std::string& - 儲存/尋找校正快取的路徑

  • use_cache – : bool - 是否使用快取 (如果存在)

inline int getBatchSize() const noexcept override

取得下一個批次的批次大小 (由於 TRT 和顯式批次的問題,始終為 1)

傳回

int

inline bool getBatch(void *bindings[], const char *names[], int nbBindings) noexcept override

取得下一個批次。

參數
  • bindings – void*[] - 綁定指標陣列 (從 TensorRT 校正器饋入),這些緩衝區應填入每個輸入的批次資料

  • names – const char*[] - 綁定的名稱

  • nbBindings – int - 綁定數量

傳回

true - 校正器有新的批次要使用

傳回

false - 校正器沒有新的批次要使用

inline const void *readCalibrationCache(size_t &length) noexcept override

讀取校正快取。

如何從校正快取讀取,僅在使用 use_cache 設定時啟用

參數

length

傳回

const void* - 指向快取資料的指標

inline void writeCalibrationCache(const void *cache, size_t length) noexcept override

寫入校正快取。

將 TensorRT 提供的校正快取寫入到指定檔案

參數
  • cache – const void* - 快取資料

  • length – size_t - 快取長度

inline operator nvinfer1::IInt8Calibrator*()

運算子轉換為 nvinfer1::IInt8Calibrator*

方便函數,可轉換為 IInt8Calibrator*,以便輕鬆指派給 CompileSpec 中的 ptq_calibrator 欄位

傳回

nvinfer1::IInt8Calibrator*

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得初學者和進階開發者的深入教學

檢視教學

資源

尋找開發資源並獲得問題解答

檢視資源