Shortcuts

模板函数 torch_tensorrt::ptq::make_int8_cache_calibrator

函数文档

template<typename Algorithm = nvinfer1::IInt8EntropyCalibrator2>
inline Int8CacheCalibrator<算法> torch_tensorrt::ptq::make_int8_cache_calibrator(const std::string &cache_file_path)

一个工厂,用于从仅使用校准缓存的torch数据加载器构建训练后量化校准器。

创建一个校准器,用于训练后量化,该校准器从先前创建的校准缓存中读取,因此您可以有一个需要数据加载器和数据集的校准缓存生成程序,然后将缓存保存以便在需要从头开始校准且没有数据集依赖性的不同程序中使用。然而,如果网络结构发生变化或输入数据集发生变化,也应重新校准网络,应用程序有责任确保这一点。

默认情况下,返回的校准器使用TensorRT Entropy v2算法执行校准。这适用于前馈网络。您可以通过调用make_int8_calibrator并指定校准器类作为模板参数来覆盖算法选择(例如使用推荐用于NLP任务的MinMax校准器)。

例如 torch_tensorrt::ptq::make_int8_cache_calibrator(calibration_cache_file);

Template Parameters

算法 – 类 nvinfer1::IInt8Calibrator (默认: nvinfer1::IInt8EntropyCalibrator2) - 使用的算法

Parameters

cache_file_path – const std::string& - 读取/写入校准缓存的路径

Returns

Int8CacheCalibrator