From e12e117fbefa21355cebfa671a0e2919f46ca323 Mon Sep 17 00:00:00 2001 From: chenyemeng Date: Wed, 6 Jan 2021 17:40:23 +0800 Subject: [PATCH 1/3] assign invalid valiu while not find --- ge/graph/load/new_model_manager/davinci_model.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index cc2bc9ed..a4d8cb8d 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -1872,6 +1872,8 @@ Status DavinciModel::GetAippType(uint32_t index, InputAippType &aipp_type, size_ const auto it = aipp_type_list_.find(index); if (it == aipp_type_list_.end()) { GELOGW("There is no aipp releated info with index %u.", index); + aipp_type = DATA_WITHOUT_AIPP; + aipp_index = 0xFFFFFFFF; return SUCCESS; } From f11a336f238b582919c3c6b166ac58e29ca80167 Mon Sep 17 00:00:00 2001 From: chenyemeng Date: Wed, 6 Jan 2021 17:50:45 +0800 Subject: [PATCH 2/3] assign invalid valiu while not find --- ge/graph/load/new_model_manager/davinci_model.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index a4d8cb8d..37c6a11c 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -1869,6 +1869,7 @@ Status DavinciModel::InitAippType(uint32_t index, const OpDescPtr &op_desc, cons } Status DavinciModel::GetAippType(uint32_t index, InputAippType &aipp_type, size_t &aipp_index) const { + GE_CHK_BOOL_RET_STATUS(index < input_addrs_list_.size(), PARAM_INVALID, "Index %u is invalid", index); const auto it = aipp_type_list_.find(index); if (it == aipp_type_list_.end()) { GELOGW("There is no aipp releated info with index %u.", index); From 668457ec9c91fda8facec09c8c571e11034718e8 Mon Sep 17 00:00:00 2001 From: chenyemeng Date: Wed, 6 Jan 2021 18:25:53 +0800 Subject: [PATCH 3/3] Fix UT --- tests/ut/ge/graph/load/davinci_model_unittest.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ut/ge/graph/load/davinci_model_unittest.cc b/tests/ut/ge/graph/load/davinci_model_unittest.cc index fe7c70c9..2d8035f1 100644 --- a/tests/ut/ge/graph/load/davinci_model_unittest.cc +++ b/tests/ut/ge/graph/load/davinci_model_unittest.cc @@ -487,7 +487,7 @@ TEST_F(UtestDavinciModel, init_data_aipp_static) { InputAippType aipp_type; size_t aipp_index = 0; - EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); + EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), PARAM_INVALID); EXPECT_EQ(model.InitNodes(graph), SUCCESS); EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); EXPECT_EQ(aipp_type, DATA_WITH_STATIC_AIPP); @@ -519,7 +519,7 @@ TEST_F(UtestDavinciModel, init_data_aipp_dynamic) { InputAippType aipp_type; size_t aipp_index = 0; - EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); + EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), PARAM_INVALID); EXPECT_EQ(model.InitNodes(graph), SUCCESS); EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); @@ -559,7 +559,7 @@ TEST_F(UtestDavinciModel, init_data_aipp_releated) { InputAippType aipp_type; size_t aipp_index = 0; - EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); + EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), PARAM_INVALID); EXPECT_EQ(model.InitNodes(graph), SUCCESS); EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); EXPECT_EQ(aipp_type, DATA_WITH_DYNAMIC_AIPP); @@ -590,7 +590,7 @@ TEST_F(UtestDavinciModel, init_data_aipp_dynamic_conf) { InputAippType aipp_type; size_t aipp_index = 0; - EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); + EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), PARAM_INVALID); EXPECT_EQ(model.InitNodes(graph), SUCCESS); EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); EXPECT_EQ(aipp_type, DYNAMIC_AIPP_NODE); @@ -621,7 +621,7 @@ TEST_F(UtestDavinciModel, init_data_aipp_dynamic_invalid) { InputAippType aipp_type; size_t aipp_index = 0; - EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), SUCCESS); + EXPECT_EQ(model.GetAippType(0, aipp_type, aipp_index), PARAM_INVALID); EXPECT_EQ(model.InitNodes(graph), ACL_ERROR_GE_AIPP_MODE_INVALID); EXPECT_EQ(model.input_addrs_list_.size(), 1);