Apollo 11.0
自动驾驶开放平台
entropy_calibrator.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <string>
20#include <vector>
21
22#include "NvInfer.h"
23#include "NvInferPlugin.h"
24
27
28namespace nvinfer1 {
29class Int8EntropyCalibrator : public IInt8EntropyCalibrator {
30 public:
32 const apollo::perception::inference::BatchStream &stream, int first_batch,
33 bool read_cache, std::string network);
34
35 virtual ~Int8EntropyCalibrator();
36 int getBatchSize() const noexcept override { return stream_.getBatchSize(); }
37
38 bool getBatch(void *bindings[],
39 const char *names[], int nbBindings) noexcept override;
40
41 const void *readCalibrationCache(size_t &length) noexcept override;
42
43 void writeCalibrationCache(const void *cache,
44 size_t length) noexcept override;
45
46 private:
48 bool read_cache_ = true;
49 std::string network_ = "yolo";
50 size_t input_count_;
51 void *device_input_ = nullptr;
52 std::vector<char> calibration_cache_;
53};
54
55} // namespace nvinfer1
void writeCalibrationCache(const void *cache, size_t length) noexcept override
int getBatchSize() const noexcept override
const void * readCalibrationCache(size_t &length) noexcept override
bool getBatch(void *bindings[], const char *names[], int nbBindings) noexcept override