From 927439cb92722d36401af139899288d824f333c2 Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 16 Jul 2021 11:14:50 +0800 Subject: [PATCH 1/7] fix error code and add complex128 support --- ge/generator/ge_generator.cc | 1 - ge/graph/build/memory/graph_mem_assigner.cc | 2 +- ge/graph/build/memory/memory_assigner.cc | 5 +++-- ge/graph/manager/graph_manager.cc | 4 ++-- ge/offline/single_op_parser.cc | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 45eaed59..d35d7d6e 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -1157,7 +1157,6 @@ Status GeGenerator::Impl::BuildModel(const Graph &graph, const vector if (ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "build graph failed, graph id:%u, ret:%d", graph_id, ret); GELOGE(GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED, "[Build][Graph] fail, graph id: %u", graph_id); - ret = GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED; } RtContextUtil::GetInstance().DestroyRtContexts(session_id); diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index f8878383..542b6215 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -275,7 +275,7 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map({"size", "item", "maxsize"}), std::vector({std::to_string(total_mem_offset), "featuremap", std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())})); - return ge::FAILED; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } return SUCCESS; } diff --git a/ge/graph/build/memory/memory_assigner.cc b/ge/graph/build/memory/memory_assigner.cc index 6e49827f..5846e922 100755 --- a/ge/graph/build/memory/memory_assigner.cc +++ b/ge/graph/build/memory/memory_assigner.cc @@ -29,9 +29,10 @@ Status MemoryAssigner::AssignMemory(bool is_loop_graph, map &m } // Reassign memory for special nodes - if (graph_mem_assigner.ReAssignMemory(is_loop_graph, mem_offset) != ge::SUCCESS) { + Status ret = graph_mem_assigner.ReAssignMemory(is_loop_graph, mem_offset) + if (ret != ge::SUCCESS) { GELOGE(ge::FAILED, "[ReAssign][Memory] failed, graph:%s", compute_graph_->GetName().c_str()); - return ge::FAILED; + return ret; } // Assign memory (block and offset) for zero copy nodes diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 7d72d85b..9749010a 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -1482,8 +1482,8 @@ Status GraphManager::BuildGraph(const GraphId &graph_id, const std::vectorSetRunFlag(false); if (ret != SUCCESS) { - GELOGE(GE_GRAPH_PRERUN_FAILED, "[Call][StartForRunGraph] failed! graph_id:%u.", graph_id); - return GE_GRAPH_PRERUN_FAILED; + GELOGE(ret, "[Call][StartForRunGraph] failed! graph_id:%u.", graph_id); + return ret; } GELOGI("[BuildGraph] build graph success, graph_id=%u.", graph_id); diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc index 6bc5cb3d..aeb73116 100644 --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -89,7 +89,8 @@ map kDataTypeDict = { {"float", DT_FLOAT}, {"float32", DT_FLOAT}, {"double", DT_DOUBLE}, - {"complex64", DT_COMPLEX64} + {"complex64", DT_COMPLEX64}, + {"complex128", DT_COMPLEX128} }; map kFormatDict = { From a5137fb87f65cb8bd6c940f4d153f430692b767f Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 16 Jul 2021 11:23:15 +0800 Subject: [PATCH 2/7] fix error code and add complex128 support --- ge/graph/build/memory/memory_assigner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/build/memory/memory_assigner.cc b/ge/graph/build/memory/memory_assigner.cc index 5846e922..41171164 100755 --- a/ge/graph/build/memory/memory_assigner.cc +++ b/ge/graph/build/memory/memory_assigner.cc @@ -29,7 +29,7 @@ Status MemoryAssigner::AssignMemory(bool is_loop_graph, map &m } // Reassign memory for special nodes - Status ret = graph_mem_assigner.ReAssignMemory(is_loop_graph, mem_offset) + Status ret = graph_mem_assigner.ReAssignMemory(is_loop_graph, mem_offset); if (ret != ge::SUCCESS) { GELOGE(ge::FAILED, "[ReAssign][Memory] failed, graph:%s", compute_graph_->GetName().c_str()); return ret; From eee6bc92d1b2bcd150b18621274222ba511ee5bd Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 16 Jul 2021 16:13:45 +0800 Subject: [PATCH 3/7] fix error code and add complex128 support --- tests/ut/ge/graph_ir/ge_ir_build_unittest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc b/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc index 60f33ed3..500dbc2a 100644 --- a/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc +++ b/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc @@ -367,7 +367,7 @@ TEST(UtestIrBuild, check_data_op_attr_index_valid) { }; ModelBufferData model; graphStatus ret = aclgrphBuildModel(graph, build_options, model); - EXPECT_EQ(ret, GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED); + EXPECT_EQ(ret, ge::FAILED); } // set attr index invalid, when not set input shape range @@ -377,7 +377,7 @@ TEST(UtestIrBuild, check_data_attr_index_succ_no_input_range) { const map build_options; ModelBufferData model; graphStatus ret = aclgrphBuildModel(graph, build_options, model); - EXPECT_EQ(ret, GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED); + EXPECT_EQ(ret, ge::FAILED); } TEST(UtestIrBuild, check_modify_mixlist_param) { From 4cb9aff399e1a8564cc12827bffda9a3a540749d Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 16 Jul 2021 17:21:22 +0800 Subject: [PATCH 4/7] fix error code and add complex128 support --- .../ge/graph/build/graph_mem_assigner_unittest.cc | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc diff --git a/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc b/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc new file mode 100644 index 00000000..983f1763 --- /dev/null +++ b/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc @@ -0,0 +1,85 @@ +/** + * Copyright 2019-2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "graph/anchor.h" +#include "graph/attr_value.h" +#include "graph/debug/ge_attr_define.h" +#include "graph/utils/graph_utils.h" +#include "graph/utils/node_utils.h" +#include "graph/utils/op_desc_utils.h" +#include "graph/utils/tensor_utils.h" +#include "omg/omg_inner_types.h" +#include "../passes/graph_builder_utils.h" + +#define protected public +#define private public +#include "graph/build/memory/binary_block_mem_assigner.h" +#include "graph/build/memory/graph_mem_assigner_unittest.h" +#include "graph/build/memory/hybrid_mem_assigner.h" +#include "graph/build/memory/max_block_mem_assigner.h" +#include "graph/manager/graph_var_manager.h" +#undef protected +#undef private + +using namespace std; +using namespace testing; +using namespace ge; +using domi::GetContext; + +class UtestTaskGeneratorTest : public testing::Test { + public: + ge::ComputeGraphPtr BuildGraphWithVar(int64_t session_id) { + // init + MemManager::Instance().Initialize(std::vector({RT_MEMORY_HBM})); + VarManager::Instance(session_id)->Init(0, 0, 0, 0); + ge::ut::GraphBuilder builder("graph"); + auto var_input = builder.AddNode("var", "Variable", 1, 1); + auto const_input = builder.AddNode("const", "Const", 1, 1); + auto assign = builder.AddNode("assgin", "Assign", 2, 1); + // add link + builder.AddDataEdge(var_input, 0, assign, 0); + builder.AddDataEdge(const_input, 0, assign, 1); + // set offset + var_input->GetOpDesc()->SetOutputOffset({10000}); + const_input->GetOpDesc()->SetOutputOffset({1000}); + assign->GetOpDesc()->SetInputOffset({10100, 1000}); + assign->GetOpDesc()->SetOutputOffset({10100}); + // set inner offset + int64_t inner_offset = 100; + ge::AttrUtils::SetInt(assign->GetOpDesc()->MutableInputDesc(0), ATTR_NAME_INNER_OFFSET, inner_offset); + ge::AttrUtils::SetInt(assign->GetOpDesc()->MutableOutputDesc(0), ATTR_NAME_INNER_OFFSET, inner_offset); + // add var addr + VarManager::Instance(session_id)->var_resource_->var_offset_map_.emplace(10000, RT_MEMORY_HBM); + + return builder.GetGraph(); + } + +protected: + void SetUp() {} + void TearDown() {} +}; + +TEST_F(UtestMemoryAssignerTest, graph_memory_assign_continuous_input) { + ge::ComputeGraphPtr compute_graph = make_shared(""); + GraphMemoryAssigner graph_mem_assigner(compute_graph); + map mem_type_to_offset = {}; + Status ret = ReAssignMemory(false, mem_type_to_offset); + EXPECT_EQ(ret, ge::FAILED); +} + From 7e6461f7f17fcc824f1b91c98ceb54a01cc2df15 Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 16 Jul 2021 17:32:17 +0800 Subject: [PATCH 5/7] fix error code and add complex128 support --- tests/ut/ge/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index 773a2686..a5b3942d 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -677,6 +677,7 @@ set(MULTI_PARTS_TEST_FILES "graph/build/stream_allocator_unittest.cc" "graph/build/model_builder_unittest.cc" "graph/build/mem_assigner_unittest.cc" + "graph/build/graph_mem_assigner_unittest.cc" "graph/build/task_generator_unittest.cc" "graph/build/buffer_pool_mem_assigner_unittest.cc" "graph/execute/graph_execute_unittest.cc" From 8b7ae630863eac1d2aef3b20cf0496139554c420 Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 16 Jul 2021 17:35:08 +0800 Subject: [PATCH 6/7] fix error code and add complex128 support --- tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc b/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc index 983f1763..4bff9b38 100644 --- a/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc +++ b/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc @@ -30,7 +30,7 @@ #define protected public #define private public #include "graph/build/memory/binary_block_mem_assigner.h" -#include "graph/build/memory/graph_mem_assigner_unittest.h" +#include "graph/build/memory/graph_mem_assigner.h" #include "graph/build/memory/hybrid_mem_assigner.h" #include "graph/build/memory/max_block_mem_assigner.h" #include "graph/manager/graph_var_manager.h" From f98a41081af2d7f23434cc1c63be84d0bef9d49c Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 16 Jul 2021 18:25:05 +0800 Subject: [PATCH 7/7] fix error code and add complex128 support --- tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc b/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc index 4bff9b38..703ac3b4 100644 --- a/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc +++ b/tests/ut/ge/graph/build/graph_mem_assigner_unittest.cc @@ -34,6 +34,7 @@ #include "graph/build/memory/hybrid_mem_assigner.h" #include "graph/build/memory/max_block_mem_assigner.h" #include "graph/manager/graph_var_manager.h" +#include "graph/manager/graph_mem_manager.h" #undef protected #undef private @@ -42,7 +43,7 @@ using namespace testing; using namespace ge; using domi::GetContext; -class UtestTaskGeneratorTest : public testing::Test { +class UtestGraphMemAssigner : public testing::Test { public: ge::ComputeGraphPtr BuildGraphWithVar(int64_t session_id) { // init @@ -75,11 +76,15 @@ protected: void TearDown() {} }; -TEST_F(UtestMemoryAssignerTest, graph_memory_assign_continuous_input) { +TEST_F(UtestGraphMemAssigner, graph_memory_assign_fail_case) { ge::ComputeGraphPtr compute_graph = make_shared(""); GraphMemoryAssigner graph_mem_assigner(compute_graph); + MemoryOffset mem_offset(2, 10000); + graph_mem_assigner.memory_offset_.insert({2, mem_offset}); + VarManager::Instance(0)->graph_mem_max_size_ = 0; + map mem_type_to_offset = {}; - Status ret = ReAssignMemory(false, mem_type_to_offset); - EXPECT_EQ(ret, ge::FAILED); + Status ret = graph_mem_assigner.ReAssignMemory(false, mem_type_to_offset); + EXPECT_EQ(ret, ACL_ERROR_GE_MEMORY_ALLOCATION); }