MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / writeCalibrationCache

Function writeCalibrationCache

python/src/infer/pyInt8.cpp:112–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 }
111
112 void writeCalibrationCache(const void* ptr, std::size_t length) noexcept override
113 {
114 try
115 {
116 py::gil_scoped_acquire gil{};
117
118 py::function pyWriteCalibrationCache
119 = utils::getOverride(static_cast<Derived*>(this), "write_calibration_cache");
120
121 #if PYBIND11_VERSION_MAJOR < 2 || PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR < 6
122 py::buffer_info info{
123 const_cast<void*>(ptr), /* Pointer to buffer */
124 sizeof(uint8_t), /* Size of one scalar */
125 py::format_descriptor<uint8_t>::format(), /* Python struct-style format descriptor */
126 1, /* Number of dimensions */
127 {length}, /* Buffer dimensions */
128 { sizeof(uint8_t) } /* Strides (in bytes) for each index */
129 };
130 py::memoryview cache{info};
131 #else
132 py::memoryview cache{
133 py::memoryview::from_buffer(static_cast<const uint8_t*>(ptr), {length}, {sizeof(uint8_t)})};
134 #endif
135 pyWriteCalibrationCache(cache);
136 }
137 catch (std::exception const& e)
138 {
139 std::cerr << "[ERROR] Exception caught in write_calibration_cache(): " << e.what() << std::endl;
140 }
141 catch (...)
142 {
143 std::cerr << "[ERROR] Exception caught in write_calibration_cache()" << std::endl;
144 }
145 }
146
147private:
148 py::buffer mCache{};

Callers

nothing calls this directly

Calls 1

getOverrideFunction · 0.85

Tested by

no test coverage detected