From 5b53a974c4a26c46cd26981c6d38831eddd00d7d Mon Sep 17 00:00:00 2001 From: w30052974 Date: Mon, 13 Jan 2025 20:05:01 +0800 Subject: [PATCH] =?UTF-8?q?NNRT=E5=9C=A8=E7=AE=97=E5=AD=90=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=B6=E5=B0=86=E6=A8=A1=E5=9E=8B=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=86=99=E5=85=A5cache=5Finfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: w30052974 --- .../native/neural_network_runtime/nncompiled_cache.cpp | 4 ++++ frameworks/native/neural_network_runtime/nncompiler.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp index ef71bbf..92a749f 100644 --- a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp +++ b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp @@ -347,6 +347,10 @@ OH_NN_ReturnCode NNCompiledCache::CheckCacheInfo(NNCompiledCacheInfo& modelCache LOGW("[NNCompiledCache] opVersion failed."); } + if (!infoCacheFile.read(reinterpret_cast(&(modelCacheInfo.isExceedRamLimit)), sizeof(uint64_t))) { + LOGW("[NNCompiledCache] isExceedRamLimit failed."); + } + infoCacheFile.close(); return OH_NN_SUCCESS; } diff --git a/frameworks/native/neural_network_runtime/nncompiler.cpp b/frameworks/native/neural_network_runtime/nncompiler.cpp index 76e817e..388f8d7 100644 --- a/frameworks/native/neural_network_runtime/nncompiler.cpp +++ b/frameworks/native/neural_network_runtime/nncompiler.cpp @@ -691,6 +691,12 @@ OH_NN_ReturnCode NNCompiler::RestoreFromCacheFile() *cacheInfoPtr++ = currentOpVersion; + if (modelCacheInfo.isExceedRamLimit) { + *cacheInfoPtr++ = 1; + } else { + *cacheInfoPtr++ = 0; + } + ret = compiledCache.WriteCacheInfo(infoCharNumber, cacheInfo, m_cachePath); if (ret != OH_NN_SUCCESS) { LOGE("[NNCompiledCache] isUpdatable is true to write cache info failed."); -- Gitee