Apollo 11.0
自动驾驶开放平台
nvinfer1::Int8EntropyCalibrator类 参考

#include <entropy_calibrator.h>

类 nvinfer1::Int8EntropyCalibrator 继承关系图:
nvinfer1::Int8EntropyCalibrator 的协作图:

Public 成员函数

 Int8EntropyCalibrator (const apollo::perception::inference::BatchStream &stream, int first_batch, bool read_cache, std::string network)
 
virtual ~Int8EntropyCalibrator ()
 
int getBatchSize () const noexcept override
 
bool getBatch (void *bindings[], const char *names[], int nbBindings) noexcept override
 
const void * readCalibrationCache (size_t &length) noexcept override
 
void writeCalibrationCache (const void *cache, size_t length) noexcept override
 

详细描述

在文件 entropy_calibrator.h 第 29 行定义.

构造及析构函数说明

◆ Int8EntropyCalibrator()

nvinfer1::Int8EntropyCalibrator::Int8EntropyCalibrator ( const apollo::perception::inference::BatchStream &  stream,
int  first_batch,
bool  read_cache,
std::string  network 
)

在文件 entropy_calibrator.cc 第 33 行定义.

36 : stream_(stream), read_cache_(read_cache), network_(network) {
37 DimsNCHW dims = stream_.getDims();
38 input_count_ = stream_.getBatchSize() * dims.c() * dims.h() * dims.w();
39 cudaMalloc(&device_input_, input_count_ * sizeof(float));
40 stream_.reset(first_batch);
41}

◆ ~Int8EntropyCalibrator()

nvinfer1::Int8EntropyCalibrator::~Int8EntropyCalibrator ( )
virtual

在文件 entropy_calibrator.cc 第 43 行定义.

43 {
44 if (device_input_) {
45 (cudaFree(device_input_));
46 }
47}

成员函数说明

◆ getBatch()

bool nvinfer1::Int8EntropyCalibrator::getBatch ( void *  bindings[],
const char *  names[],
int  nbBindings 
)
overridenoexcept

在文件 entropy_calibrator.cc 第 49 行定义.

50 {
51 if (!stream_.next()) {
52 return false;
53 }
54
55 (cudaMemcpy(device_input_, stream_.getBatch(), input_count_ * sizeof(float),
56 cudaMemcpyHostToDevice));
57 bindings[0] = device_input_;
58 return true;
59}

◆ getBatchSize()

int nvinfer1::Int8EntropyCalibrator::getBatchSize ( ) const
inlineoverridenoexcept

在文件 entropy_calibrator.h 第 36 行定义.

36{ return stream_.getBatchSize(); }

◆ readCalibrationCache()

const void * nvinfer1::Int8EntropyCalibrator::readCalibrationCache ( size_t &  length)
overridenoexcept

在文件 entropy_calibrator.cc 第 61 行定义.

62 {
63 calibration_cache_.clear();
64 std::ifstream input(
65 apollo::perception::inference::locateFile(network_, "CalibrationTable"),
66 std::ios::binary);
67 input >> std::noskipws;
68 if (read_cache_ && input.good()) {
69 std::copy(std::istream_iterator<char>(input), std::istream_iterator<char>(),
70 std::back_inserter(calibration_cache_));
71 }
72
73 length = calibration_cache_.size();
74 return length ? &calibration_cache_[0] : nullptr;
75}
std::string locateFile(const std::string &network, const std::string &input)
Definition mi_utils.cc:63

◆ writeCalibrationCache()

void nvinfer1::Int8EntropyCalibrator::writeCalibrationCache ( const void *  cache,
size_t  length 
)
overridenoexcept

在文件 entropy_calibrator.cc 第 77 行定义.

78 {
79 std::ofstream output(
80 apollo::perception::inference::locateFile(network_, "CalibrationTable"),
81 std::ios::binary);
82 output.write(reinterpret_cast<const char *>(cache), length);
83}

该类的文档由以下文件生成: