Apollo  6.0
Open source self driving car software
entropy_calibrator.h
Go to the documentation of this file.
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 
28 namespace nvinfer1 {
29 class 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 override { return stream_.getBatchSize(); }
37 
38  bool getBatch(void *bindings[], const char *names[], int nbBindings) override;
39 
40  const void *readCalibrationCache(size_t &length) override;
41 
42  void writeCalibrationCache(const void *cache, size_t length) override;
43 
44  private:
46  bool read_cache_ = true;
47  std::string network_ = "yolo";
48  size_t input_count_;
49  void *device_input_ = nullptr;
50  std::vector<char> calibration_cache_;
51 };
52 
53 } // namespace nvinfer1
const void * readCalibrationCache(size_t &length) override
int getBatchSize() const override
Definition: entropy_calibrator.h:36
Definition: batch_stream.h:28
Definition: entropy_calibrator.h:28
int getBatchSize() const
Definition: batch_stream.h:44
void writeCalibrationCache(const void *cache, size_t length) override
Int8EntropyCalibrator(const apollo::perception::inference::BatchStream &stream, int first_batch, bool read_cache, std::string network)
bool getBatch(void *bindings[], const char *names[], int nbBindings) override
Definition: entropy_calibrator.h:29