From 1d98ab40983a66a63fff59a0efaa99fa3e6af7b3 Mon Sep 17 00:00:00 2001 From: maoyong Date: Mon, 6 May 2024 11:51:40 +0800 Subject: [PATCH 1/4] fix code warning Signed-off-by: maoyong --- .../nncompiled_cache.cpp | 32 +++++++++++++++++++ .../neural_network_runtime/nncompiled_cache.h | 1 + 2 files changed, 33 insertions(+) diff --git a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp index 4aad156..d19cd7d 100644 --- a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp +++ b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp @@ -197,6 +197,7 @@ OH_NN_ReturnCode NNCompiledCache::GenerateCacheModel(const std::vector(version); *cacheInfoPtr++ = static_cast(m_backendID); // Should call SetBackend first. + OH_NN_ReturnCode ret = OH_NN_SUCCESS; for (size_t i = 0; i < cacheNumber; ++i) { std::string cacheModelFile = cacheDir + "/" + m_modelName + std::to_string(i) + ".nncache"; char path[PATH_MAX]; @@ -205,6 +206,12 @@ OH_NN_ReturnCode NNCompiledCache::GenerateCacheModel(const std::vector Date: Mon, 6 May 2024 11:51:40 +0800 Subject: [PATCH 2/4] fix code warning Signed-off-by: maoyong --- frameworks/native/neural_network_runtime/nncompiled_cache.cpp | 2 +- frameworks/native/neural_network_runtime/nncompiled_cache.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp index d19cd7d..9fa5084 100644 --- a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp +++ b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp @@ -406,7 +406,7 @@ OH_NN_ReturnCode NNCompiledCache::GetCacheFileLength(std::ifstream& ifs, int& fi return OH_NN_SUCCESS; } -OH_NN_ReturnCode NNCompiledCache::VerifyCachePath(const std::string& cachePath) +OH_NN_ReturnCode NNCompiledCache::VerifyCachePath(const std::string& cachePath) const { if (cachePath.find('/') != size_t(0)) { LOGE("[NNCompiledCache] VerifyCachePath failed, input file dir=%{public}s is invalid, " diff --git a/frameworks/native/neural_network_runtime/nncompiled_cache.h b/frameworks/native/neural_network_runtime/nncompiled_cache.h index 2020b5a..1140fab 100644 --- a/frameworks/native/neural_network_runtime/nncompiled_cache.h +++ b/frameworks/native/neural_network_runtime/nncompiled_cache.h @@ -65,7 +65,7 @@ private: OH_NN_ReturnCode ReadCacheModelFile(const std::string& file, Buffer& cache) const; unsigned short GetCrc16(char* buffer, size_t length) const; OH_NN_ReturnCode GetCacheFileLength(std::ifstream& ifs, int& fileSize) const; - OH_NN_ReturnCode VerifyCachePath(const std::string& cachePath); + OH_NN_ReturnCode VerifyCachePath(const std::string& cachePath) const; private: size_t m_backendID {0}; -- Gitee From fe7de6c88fda9a7e520c018bab97c4ef9406e7ae Mon Sep 17 00:00:00 2001 From: maoyong Date: Mon, 6 May 2024 14:54:45 +0800 Subject: [PATCH 3/4] fix cache bug --- .../native/neural_network_runtime/nncompiled_cache.cpp | 6 +++--- frameworks/native/neural_network_runtime/nncompiler.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp index 9fa5084..c380d7e 100644 --- a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp +++ b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp @@ -203,7 +203,7 @@ OH_NN_ReturnCode NNCompiledCache::GenerateCacheModel(const std::vector Date: Mon, 6 May 2024 15:18:08 +0800 Subject: [PATCH 4/4] fix cache bug --- .../native/neural_network_runtime/nncompiled_cache.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp index c380d7e..d9bd049 100644 --- a/frameworks/native/neural_network_runtime/nncompiled_cache.cpp +++ b/frameworks/native/neural_network_runtime/nncompiled_cache.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "common/utils.h" #include "backend_manager.h" @@ -206,7 +208,7 @@ OH_NN_ReturnCode NNCompiledCache::GenerateCacheModel(const std::vector