未验证 提交 27ecc5d5 编写于 作者: O openharmony_ci 提交者: Gitee

!9083 修复 acts 仓安全告警问题

Merge pull request !9083 from scholar-lc/master
......@@ -34,6 +34,11 @@ sptr<INnrtDevice> INnrtDevice::Get(const std::string &serviceName, bool isStub)
return mockIDevice;
}
MockIDevice::MockIDevice()
{
m_bufferFd = 0;
}
MockIDevice::~MockIDevice()
{
for (auto ash : m_ashmems) {
......
......@@ -89,7 +89,7 @@ public:
static MockIDevice *GetInstance();
MockIDevice() = default;
MockIDevice();
virtual ~MockIDevice();
private:
......
......@@ -278,7 +278,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
LOGE("[NNRtTest] OH_NNExecutor_SetInputWithMemory failed! ret=%d\n", ret);
return ret;
}
memcpy_s(inputMemory->data, operandTem.length, (void *) operandTem.data, operandTem.length);
memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length);
OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
......
......@@ -67,7 +67,7 @@ struct OHNNCompileParam {
bool enableFp16 = false;
};
int BuildSingleOpGraph(OH_NNModel *modelptr, const OHNNGraphArgs &args);
int BuildSingleOpGraph(OH_NNModel *model, const OHNNGraphArgs &graphArgs);
int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, OH_NN_Memory *OHNNMemory[],
float* expect);
......
......@@ -68,7 +68,7 @@ public:
}
protected:
OHNNCompileParam compileParam;
OHNNCompileParam m_compileParam;
AddModel addModel;
OHNNGraphArgs graphArgs = addModel.graphArgs;
};
......@@ -835,8 +835,8 @@ HWTEST_F(CompileTest, SUB_AI_NNR_Func_North_Compilation_Combine_0100, Function |
OH_NNCompilation *compilation2 = OH_NNCompilation_Construct(model2);
ASSERT_NE(nullptr, compilation2);
std::thread th1(CompileModel, compilation1, compileParam);
std::thread th2(CompileModel, compilation2, compileParam);
std::thread th1(CompileModel, compilation1, m_compileParam);
std::thread th2(CompileModel, compilation2, m_compileParam);
th1.join();
th2.join();
Free(model1, compilation1);
......
......@@ -1135,7 +1135,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0400, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
......@@ -1205,7 +1205,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_Run(executor));
// check result
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(outputMemory->data)),
(float*) addModel.expectValue));
static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, 0, &outputMemory);
ASSERT_EQ(outputMemory, nullptr);
......
......@@ -776,7 +776,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0100, Function |
ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
graphArgs.outputIndices.end()) {
......@@ -815,7 +815,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0200, Function |
OH_NN_Memory *inputMemory = OH_NNExecutor_AllocateInputMemory(executor, inputIndex, operandTem.length);
ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
}
}
ASSERT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(executor));
......@@ -847,7 +847,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0300, Function |
auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) addModel.expectValue));
static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
}
......@@ -891,7 +891,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0400, Function |
auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) avgModel.expectValue));
static_cast<float*>(avgModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
}
......
......@@ -42,6 +42,11 @@ MockIDevice::~MockIDevice()
}
}
MockIDevice::MockIDevice()
{
m_bufferFd = 0;
}
MockIPreparedModel::~MockIPreparedModel()
{
for (auto ash : m_ashmems) {
......
......@@ -92,7 +92,7 @@ public:
static MockIDevice *GetInstance();
MockIDevice() = default;
MockIDevice();
virtual ~MockIDevice();
private:
......
......@@ -278,7 +278,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
LOGE("[NNRtTest] OH_NNExecutor_SetInputWithMemory failed! ret=%d\n", ret);
return ret;
}
memcpy_s(inputMemory->data, operandTem.length, (void *) operandTem.data, operandTem.length);
memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length);
OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
......
......@@ -67,7 +67,7 @@ struct OHNNCompileParam {
bool enableFp16 = false;
};
int BuildSingleOpGraph(OH_NNModel *modelptr, const OHNNGraphArgs &args);
int BuildSingleOpGraph(OH_NNModel *model, const OHNNGraphArgs &graphArgs);
int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, OH_NN_Memory *OHNNMemory[],
float* expect);
......
......@@ -68,7 +68,7 @@ public:
}
protected:
OHNNCompileParam compileParam;
OHNNCompileParam m_compileParam;
AddModel addModel;
OHNNGraphArgs graphArgs = addModel.graphArgs;
};
......@@ -835,8 +835,8 @@ HWTEST_F(CompileTest, SUB_AI_NNR_Func_North_Compilation_Combine_0100, Function |
OH_NNCompilation *compilation2 = OH_NNCompilation_Construct(model2);
ASSERT_NE(nullptr, compilation2);
std::thread th1(CompileModel, compilation1, compileParam);
std::thread th2(CompileModel, compilation2, compileParam);
std::thread th1(CompileModel, compilation1, m_compileParam);
std::thread th2(CompileModel, compilation2, m_compileParam);
th1.join();
th2.join();
Free(model1, compilation1);
......
......@@ -1240,7 +1240,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0400, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
......@@ -1310,7 +1310,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_Run(executor));
// check result
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(outputMemory->data)),
(float*) addModel.expectValue));
static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, 0, &outputMemory);
ASSERT_EQ(outputMemory, nullptr);
......
......@@ -776,7 +776,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0100, Function |
ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
graphArgs.outputIndices.end()) {
......@@ -815,7 +815,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0200, Function |
OH_NN_Memory *inputMemory = OH_NNExecutor_AllocateInputMemory(executor, inputIndex, operandTem.length);
ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
}
}
ASSERT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(executor));
......@@ -847,7 +847,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0300, Function |
auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) addModel.expectValue));
static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
}
......@@ -891,7 +891,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0400, Function |
auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) avgModel.expectValue));
static_cast<float*>(avgModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册