Class used for int8 calibration
| 81 | |
| 82 | // Class used for int8 calibration |
| 83 | class Int8EntropyCalibrator2 : public nvinfer1::IInt8EntropyCalibrator2 { |
| 84 | public: |
| 85 | Int8EntropyCalibrator2(int32_t batchSize, int32_t inputW, int32_t inputH, const std::string &calibDataDirPath, |
| 86 | const std::string &calibTableName, const std::string &inputBlobName, |
| 87 | const std::array<float, 3> &subVals = {0.f, 0.f, 0.f}, const std::array<float, 3> &divVals = {1.f, 1.f, 1.f}, |
| 88 | bool normalize = true, bool readCache = true); |
| 89 | virtual ~Int8EntropyCalibrator2(); |
| 90 | // Abstract base class methods which must be implemented |
| 91 | int32_t getBatchSize() const noexcept override; |
| 92 | bool getBatch(void *bindings[], char const *names[], int32_t nbBindings) noexcept override; |
| 93 | void const *readCalibrationCache(std::size_t &length) noexcept override; |
| 94 | void writeCalibrationCache(void const *ptr, std::size_t length) noexcept override; |
| 95 | |
| 96 | private: |
| 97 | const int32_t m_batchSize; |
| 98 | const int32_t m_inputW; |
| 99 | const int32_t m_inputH; |
| 100 | int32_t m_imgIdx; |
| 101 | std::vector<std::string> m_imgPaths; |
| 102 | size_t m_inputCount; |
| 103 | const std::string m_calibTableName; |
| 104 | const std::string m_inputBlobName; |
| 105 | const std::array<float, 3> m_subVals; |
| 106 | const std::array<float, 3> m_divVals; |
| 107 | const bool m_normalize; |
| 108 | const bool m_readCache; |
| 109 | void *m_deviceInput; |
| 110 | std::vector<char> m_calibCache; |
| 111 | }; |
| 112 | |
| 113 | // Class to extend TensorRT logger |
| 114 | class Logger : public nvinfer1::ILogger { |
nothing calls this directly
no outgoing calls
no test coverage detected