mirror of
https://gitee.com/openharmony/ai_neural_network_runtime
synced 2025-02-17 06:32:07 +00:00
nnrt 告警修改 ut & file realpath
Signed-off-by: w30052974 <wangyifan94@huawei.com>
This commit is contained in:
parent
c449355100
commit
e3d9a0f911
@ -111,11 +111,6 @@ OH_NN_ReturnCode NNCompiledCache::Restore(const std::string& cacheDir,
|
||||
|
||||
for (uint32_t i = 0; i < cacheInfo.fileNumber; ++i) {
|
||||
std::string cacheModelPath = cacheDir + "/" + m_modelName + std::to_string(i) + ".nncache";
|
||||
if (access(cacheModelPath.c_str(), 0) != 0) {
|
||||
LOGE("[NNCompiledCache] Restore failed, %{public}s is not exist.", cacheModelPath.c_str());
|
||||
return OH_NN_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
OHOS::NeuralNetworkRuntime::Buffer modelBuffer;
|
||||
ret = ReadCacheModelFile(cacheModelPath, modelBuffer);
|
||||
if (ret != OH_NN_SUCCESS) {
|
||||
@ -343,7 +338,17 @@ OH_NN_ReturnCode NNCompiledCache::ReadCacheModelFile(const std::string& filePath
|
||||
OHOS::NeuralNetworkRuntime::Buffer& cache) const
|
||||
{
|
||||
// filePath is validate in NNCompiledCache::Restore, no need to check again.
|
||||
FILE* pFile = fopen(filePath.c_str(), "rb");
|
||||
char path[PATH_MAX];
|
||||
if (realpath(filePath.c_str(), path) == nullptr) {
|
||||
LOGE("[NNCompiledCache] ReadCacheModelFile failed, fail to get the real path of cacheInfoPath.");
|
||||
return OH_NN_INVALID_PARAMETER;
|
||||
}
|
||||
if (access(path, 0) != 0) {
|
||||
LOGE("[NNCompiledCache] ReadCacheModelFile failed, %{public}s is not exist.", path);
|
||||
return OH_NN_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FILE* pFile = fopen(path, "rb");
|
||||
if (pFile == NULL) {
|
||||
LOGE("[NNCompiledCache] ReadCacheModelFile failed, file fopen failed.");
|
||||
return OH_NN_INVALID_FILE;
|
||||
|
@ -466,19 +466,6 @@ HWTEST_F(NNCompiledCacheTest, nncompiledcachetest_setbackend_002, TestSize.Level
|
||||
EXPECT_EQ(OH_NN_SUCCESS, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: nncompiledcachetest_setmodelname_001
|
||||
* @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(NNCompiledCacheTest, nncompiledcachetest_setmodelname_001, TestSize.Level0)
|
||||
{
|
||||
LOGE("SetModelName nncompiledcachetest_setmodelname_001");
|
||||
NNCompiledCache nncompiledCache;
|
||||
std::string m_modelName;
|
||||
nncompiledCache.SetModelName(m_modelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: nncompiledcachetest_writecacheinfo_001
|
||||
* @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
|
||||
|
Loading…
x
Reference in New Issue
Block a user