calibrator.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef ENTROPY_CALIBRATOR_H
  2. #define ENTROPY_CALIBRATOR_H
  3. #include <NvInfer.h>
  4. #include <string>
  5. #include <vector>
  6. #include "macros.h"
  7. //! \class Int8EntropyCalibrator2
  8. //!
  9. //! \brief Implements Entropy calibrator 2.
  10. //! CalibrationAlgoType is kENTROPY_CALIBRATION_2.
  11. //!
  12. class Int8EntropyCalibrator2 : public nvinfer1::IInt8EntropyCalibrator2
  13. {
  14. public:
  15. Int8EntropyCalibrator2(int batchsize, int input_w, int input_h, const char* img_dir, const char* calib_table_name, const char* input_blob_name, bool read_cache = true);
  16. virtual ~Int8EntropyCalibrator2();
  17. int getBatchSize() const TRT_NOEXCEPT override;
  18. bool getBatch(void* bindings[], const char* names[], int nbBindings) TRT_NOEXCEPT override;
  19. const void* readCalibrationCache(size_t& length) TRT_NOEXCEPT override;
  20. void writeCalibrationCache(const void* cache, size_t length) TRT_NOEXCEPT override;
  21. private:
  22. int batchsize_;
  23. int input_w_;
  24. int input_h_;
  25. int img_idx_;
  26. std::string img_dir_;
  27. std::vector<std::string> img_files_;
  28. size_t input_count_;
  29. std::string calib_table_name_;
  30. const char* input_blob_name_;
  31. bool read_cache_;
  32. void* device_input_;
  33. std::vector<char> calib_cache_;
  34. };
  35. #endif // ENTROPY_CALIBRATOR_H