快捷方式

模板函数 torch_tensorrt::ptq::make_int8_cache_calibrator

函数文档

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>

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源