模板函数 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 Calibrator)。
例如:torch_tensorrt::ptq::make_int8_cache_calibrator<nvinfer1::IInt8MinMaxCalibrator>(calibration_cache_file);
- 模板参数
Algorithm – 类 nvinfer1::IInt8Calibrator(默认值:nvinfer1::IInt8EntropyCalibrator2)- 要使用的算法
- 参数
cache_file_path – const std::string& - 读取/写入校准缓存的路径
- 返回值
Int8CacheCalibrator<Algorithm>