模板类 Int8CacheCalibrator¶
定义于 文件 ptq.h
继承关系¶
基类型¶
private Algorithm
类文档¶
-
template<typename Algorithm>
class Int8CacheCalibrator : private Algorithm¶ 基于指定的 TensorRT 校准算法的通用 Int8Calibrator 实现,该算法仅从校准文件中读取数据。
- 模板参数
Algorithm – class nvinfer1::IInt8Calibrator (默认值: nvinfer1::IInt8EntropyCalibrator2) - 要使用的算法
公共函数
-
inline Int8CacheCalibrator(const std::string &cache_file_path)¶
构造一个新的 Int8 缓存校准器对象。
- 参数
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 - 绑定数量
- 返回
假
-
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*