#include <entropy_calibrator.h>
◆ Int8EntropyCalibrator()
在文件 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}
void reset(int firstBatch)
nvinfer1::DimsNCHW getDims() const
◆ ~Int8EntropyCalibrator()
| nvinfer1::Int8EntropyCalibrator::~Int8EntropyCalibrator |
( |
| ) |
|
|
virtual |
◆ 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 |
◆ readCalibrationCache()
| const void * nvinfer1::Int8EntropyCalibrator::readCalibrationCache |
( |
size_t & |
length | ) |
|
|
overridenoexcept |
在文件 entropy_calibrator.cc 第 61 行定义.
62 {
63 calibration_cache_.clear();
64 std::ifstream input(
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)
◆ writeCalibrationCache()
| void nvinfer1::Int8EntropyCalibrator::writeCalibrationCache |
( |
const void * |
cache, |
|
|
size_t |
length |
|
) |
| |
|
overridenoexcept |
在文件 entropy_calibrator.cc 第 77 行定义.
78 {
79 std::ofstream output(
81 std::ios::binary);
82 output.write(reinterpret_cast<const char *>(cache), length);
83}
该类的文档由以下文件生成: