快捷方式

模板类 Int8CacheCalibrator

继承关系

基类

  • private Algorithm

类文档

template<typename Algorithm>
class Int8CacheCalibrator : private Algorithm

通用的 Int8Calibrator 实现,基于指定的 TensorRT 校准算法,仅从校准文件中读取数据。

模板参数

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

公共函数

inline Int8CacheCalibrator(const std::string &cache_file_path)

构造一个新的 Int8CacheCalibrator 对象。

参数

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 calibrator 提供),这些缓冲区应填充每个输入的批次数据

  • 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*

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源