MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / dump_cache

Method dump_cache

src/tensorrt/impl/tensorrt_engine_cache.cpp:177–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177void TensorRTEngineCacheIO::dump_cache() {
178 if (m_update_cache)
179 mgb_log_debug(
180 "tensorrt engine cache %s already exists, and will be "
181 "rewritten during dumping cache to this file.",
182 m_filename.c_str());
183 m_ptr = fopen(m_filename.c_str(), "wb");
184 mgb_throw_if(
185 m_ptr == nullptr, SystemError, "failed to open tensorrt engine file %s %s",
186 m_filename.c_str(), strerror(errno));
187 std::unique_ptr<FILE, int (*)(FILE*)> fptr_close{m_ptr, ::fclose};
188 uint32_t nr_engines = m_cache.size();
189 write(nr_engines);
190 for (auto&& cached_engine : m_cache) {
191 uint32_t key_size = cached_engine.first.size();
192 write(key_size);
193 write(cached_engine.first.data(), key_size);
194 cached_engine.second.write_to(*this);
195 }
196}
197
198Maybe<TensorRTEngineCache::Engine> TensorRTEngineCacheIO::get(const std::string& key) {
199 MGB_LOCK_GUARD(m_mtx);

Callers 7

clearMethod · 0.45
flushMethod · 0.45
dump_persistent_cacheMethod · 0.45
dump_tensor_rt_cacheMethod · 0.45
build_infoMethod · 0.45

Calls 4

writeFunction · 0.85
write_toMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected