MCPcopy Create free account
hub / github.com/alibaba/MNN / updateCacheFile

Method updateCacheFile

source/core/Interpreter.cpp:196–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196ErrorCode Interpreter::updateCacheFile(Session* session, int flag) {
197 if (mNet->cacheFile.empty()) {
198 return NOT_SUPPORT;
199 }
200 std::lock_guard<std::mutex> _l(mNet->lock);
201
202 // Backend_Auto and no Async work, then don't need updateCache
203 if (mNet->modes.backendMode == Session_Backend_Auto && !(session->hasAsyncWork())) {
204 return NO_ERROR;
205 }
206
207 // Get cache and write to file
208 auto buffer = session->getCache();
209
210 // When current cacheSize bigger than previous, update
211 if (buffer.first != nullptr && buffer.second > mNet->lastCacheSize) {
212 MNN_PRINT("Update cache to %s, from size:%zu -> size:%zu\n", mNet->cacheFile.c_str(), mNet->lastCacheSize,
213 buffer.second);
214 writeCacheFile(mNet, buffer);
215 mNet->lastCacheSize = buffer.second;
216 }
217 // Reset cache
218 session->loadCache(nullptr, 0);
219 return NO_ERROR;
220}
221
222Interpreter::Interpreter(Content* net) {
223 MNN_ASSERT(nullptr != net);

Callers 4

modelTestFunction · 0.95
test_mainFunction · 0.80
mainFunction · 0.80

Calls 6

loadCacheMethod · 0.80
writeCacheFileFunction · 0.70
emptyMethod · 0.45
hasAsyncWorkMethod · 0.45
getCacheMethod · 0.45
c_strMethod · 0.45

Tested by 1

test_mainFunction · 0.64