模板类 Int8CacheCalibrator¶
定义于 File ptq.h
继承关系¶
基类型¶
private Algorithm
类文档¶
-
template<typename Algorithm>
class Int8CacheCalibrator : private Algorithm¶ 通用的 Int8Calibrator 实现,基于指定的 TensorRT 校准算法,该算法仅从校准文件读取。
- 模板参数
Algorithm – class nvinfer1::IInt8Calibrator (默认值: nvinfer1::IInt8EntropyCalibrator2) - 要使用的算法
公共函数
-
inline Int8CacheCalibrator(const std::string &cache_file_path)¶
构造一个新的 Int 8 缓存校准器对象。
- 参数
cache_file_path –
-
inline int getBatchSize() const noexcept override¶
获取下一个批次的批次大小(由于 TRT 和显式批次的问题,始终为 1)
- 返回
int
-
inline bool getBatch(void *bindings[], const char *names[], int nbBindings) noexcept override¶
获取下一个批次。
不使用,始终返回 false
- 参数
bindings – void*[] - 绑定指针数组(从 TensorRT 校准器馈入),这些缓冲区应填充每个输入的批次数据
names – const char*[] - 绑定的名称
nbBindings – int - 绑定的数量
- 返回
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*