From 81d226b36b26d4253d32428fd48bfe256b9d3d21 Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 1 Jul 2021 16:12:24 +0800 Subject: [PATCH 01/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/graph/load/model_manager/davinci_model.h | 1 + .../compiledsubgraph/known_node_executor.cc | 21 +++++--- .../compiledsubgraph/known_node_executor.h | 2 + ge/offline/main.cc | 4 +- tests/ut/ge/hybrid/known_node_executor_unittest.cc | 57 +++++++++++++++++++++- 5 files changed, 75 insertions(+), 10 deletions(-) diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index 1e964855..daf0c7e6 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -300,6 +300,7 @@ class DavinciModel { return op_list_.at(index); } + void SetGlobalStep(void *global_step) { global_step_addr_ = global_step; } void *GetGlobalStep() const { return global_step_addr_; } // get task info for profiling diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 4db223e0..ea6e2965 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -182,6 +182,19 @@ Status KnownNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) cons return SUCCESS; } +void KnownNodeExecutor::SettingDaviciModel(const HybridModel &model, const NodePtr &node, + std::shared_ptr &davinci_model) const { + // set known node flag as true + davinci_model->SetKnownNode(true); + davinci_model->SetId(model.GetModelId()); + davinci_model->SetDumpModelName(model.GetModelName()); + davinci_model->SetOmName(model.GetOmName()); + TensorValue *global_step_var = model.GetVariable(NODE_NAME_GLOBAL_STEP); + davinci_model->SetKnownShapeGlobalStep(global_step_var->MutableData()); + // set model id as root node's node id + davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); +} + Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, shared_ptr &task) const { GELOGI("[%s] KnownNodeExecutor::LoadTask in.", node->GetName().c_str()); @@ -199,13 +212,7 @@ Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node std::shared_ptr davinci_model = MakeShared(0, nullptr); GE_CHECK_NOTNULL(davinci_model); - // set known node flag as true - davinci_model->SetKnownNode(true); - davinci_model->SetId(model.GetModelId()); - davinci_model->SetDumpModelName(model.GetModelName()); - davinci_model->SetOmName(model.GetOmName()); - // set model id as root node's node id - davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); + SettingDaviciModel(model, node, davinci_model); GELOGD("KnownNodeExecutor::LoadTask node id %ld.", node->GetOpDesc()->GetId()); GE_CHK_STATUS_RET(davinci_model->Assign(ge_model), diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h index 11cda846..475feeb1 100644 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h @@ -59,6 +59,8 @@ class KnownNodeExecutor : public NodeExecutor { const NodePtr &node, GeModelPtr &ge_model, ComputeGraphPtr &graph); + void SettingDaviciModel(const HybridModel &model, const NodePtr &node, + std::shared_ptr &davinci_model) const; }; } // namespace hybrid } // namespace ge diff --git a/ge/offline/main.cc b/ge/offline/main.cc index bc3b823d..a50ff931 100755 --- a/ge/offline/main.cc +++ b/ge/offline/main.cc @@ -1150,9 +1150,9 @@ domi::Status GenerateSingleOp(const std::string& json_file_path) { if (ret != SUCCESS) { DOMI_LOGE("Compile op failed. ge ret = %u, op index = %d", ret, index); ret = domi::FAILED; - break; + } else { + GELOGI("Compile op success. op index = %d, output = %s", index, output_path.c_str()); } - GELOGI("Compile op success. op index = %d, output = %s", index, output_path.c_str()); index += 1; } diff --git a/tests/ut/ge/hybrid/known_node_executor_unittest.cc b/tests/ut/ge/hybrid/known_node_executor_unittest.cc index 98e985f7..a8367130 100644 --- a/tests/ut/ge/hybrid/known_node_executor_unittest.cc +++ b/tests/ut/ge/hybrid/known_node_executor_unittest.cc @@ -27,6 +27,7 @@ #undef protected #include "graph/manager/graph_mem_allocator.h" #include "../graph/passes/graph_builder_utils.h" +#include "../inc/graph/utils/graph_utils.h" using namespace std; using namespace testing; @@ -48,6 +49,34 @@ class KnownNodeTaskMock : public KnownNodeTask { }; } +static ge::OpDescPtr CreateOpDesc(string name = "", string type = "") { + auto op_desc = std::make_shared(name, type); + op_desc->SetStreamId(0); + op_desc->SetId(0); + + op_desc->SetWorkspace({}); + ; + op_desc->SetWorkspaceBytes({}); + op_desc->SetInputOffset({}); + op_desc->SetOutputOffset({}); + + ge::AttrUtils::SetStr(op_desc, ge::TVM_ATTR_NAME_MAGIC, "RT_DEV_BINARY_MAGIC_ELF_AIVEC"); + bool support_dynamic = true; + ge::AttrUtils::GetBool(op_desc, "support_dynamicshape", support_dynamic); + return op_desc; +} + +static ComputeGraphPtr BuildDataDirectConnectGraph() { + const char *kRefIndex = "_parent_node_index"; + ge::ut::GraphBuilder builder("subgraph"); + auto data = builder.AddNode("Data", "Data", 1, 1); + auto netoutput = builder.AddNode("NetOutput", "NetOutput", 1, 1); + (void)AttrUtils::SetInt(netoutput->GetOpDesc()->MutableInputDesc(0), kRefIndex, 0); + + builder.AddDataEdge(data, 0, netoutput, 0); + return builder.GetGraph(); +} + TEST_F(UnknownNodeExecutorTest, test_init_davinci_model) { auto davinci_model = std::make_shared(0, nullptr); davinci_model->SetDeviceId(0); @@ -88,4 +117,30 @@ TEST_F(UnknownNodeExecutorTest, TestParseAttrForAllocatingOutputs) { ASSERT_EQ(node_item.ref_outputs[1], const_node); ASSERT_EQ(node_item.reuse_inputs.size(), 1); ASSERT_EQ(node_item.reuse_inputs[0], 0); -} \ No newline at end of file +} + +TEST_F(UnknownNodeExecutorTest, TestSetGlobalStep) { + OpDescPtr op_desc = CreateOpDesc("PartitionedCall", "PartitionedCall"); + auto root_graph = make_shared("root_graph"); + auto node = root_graph->AddNode(op_desc); + node->SetOwnerComputeGraph(root_graph); + auto sub_graph = BuildDataDirectConnectGraph(); + sub_graph->SetParentGraph(root_graph); + sub_graph->SetParentNode(node); + node->GetOpDesc()->AddSubgraphName("subgraph"); + node->GetOpDesc()->SetSubgraphInstanceName(0, "subgraph"); + root_graph->AddSubgraph("subgraph", sub_graph); + + GeRootModelPtr ge_root_model = make_shared(root_graph); + HybridModel hybrid_model(ge_root_model); + auto *step_id = new int64_t[1]; + step_id[0] = 520; + std::unique_ptr tensor_value; + tensor_value.reset(new(std::nothrow)TensorValue((void*)step_id, sizeof(step_id))); + hybrid_model.variable_tensors_.insert({"ge_global_step", std::move(tensor_value)}); + + KnownNodeExecutor known_node_executor; + std::shared_ptr davinci_model = MakeShared(0, nullptr); + known_node_executor.SettingDaviciModel(hybrid, node, davinci_model); + EXPECT_EQ(davinci_model->global_step_addr_, 520); +} From cdecf866db4f328e73e016aec3dd58b685be71b8 Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 1 Jul 2021 17:54:49 +0800 Subject: [PATCH 02/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- tests/ut/ge/hybrid/known_node_executor_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ut/ge/hybrid/known_node_executor_unittest.cc b/tests/ut/ge/hybrid/known_node_executor_unittest.cc index a8367130..435928ee 100644 --- a/tests/ut/ge/hybrid/known_node_executor_unittest.cc +++ b/tests/ut/ge/hybrid/known_node_executor_unittest.cc @@ -141,6 +141,6 @@ TEST_F(UnknownNodeExecutorTest, TestSetGlobalStep) { KnownNodeExecutor known_node_executor; std::shared_ptr davinci_model = MakeShared(0, nullptr); - known_node_executor.SettingDaviciModel(hybrid, node, davinci_model); + known_node_executor.SettingDaviciModel(hybrid_model, node, davinci_model); EXPECT_EQ(davinci_model->global_step_addr_, 520); } From 47b3762f6e24f1bf4eccfde786c55d27a5538943 Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 1 Jul 2021 21:03:31 +0800 Subject: [PATCH 03/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc | 2 +- tests/ut/ge/hybrid/known_node_executor_unittest.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index ea6e2965..b903f6af 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -190,7 +190,7 @@ void KnownNodeExecutor::SettingDaviciModel(const HybridModel &model, const NodeP davinci_model->SetDumpModelName(model.GetModelName()); davinci_model->SetOmName(model.GetOmName()); TensorValue *global_step_var = model.GetVariable(NODE_NAME_GLOBAL_STEP); - davinci_model->SetKnownShapeGlobalStep(global_step_var->MutableData()); + davinci_model->SetGlobalStep(global_step_var->MutableData()); // set model id as root node's node id davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); } diff --git a/tests/ut/ge/hybrid/known_node_executor_unittest.cc b/tests/ut/ge/hybrid/known_node_executor_unittest.cc index 435928ee..dd2557d1 100644 --- a/tests/ut/ge/hybrid/known_node_executor_unittest.cc +++ b/tests/ut/ge/hybrid/known_node_executor_unittest.cc @@ -142,5 +142,5 @@ TEST_F(UnknownNodeExecutorTest, TestSetGlobalStep) { KnownNodeExecutor known_node_executor; std::shared_ptr davinci_model = MakeShared(0, nullptr); known_node_executor.SettingDaviciModel(hybrid_model, node, davinci_model); - EXPECT_EQ(davinci_model->global_step_addr_, 520); + EXPECT_EQ(*(static_cast(davinci_model->global_step_addr_)), 520); } From 9287ca4c4ca7285882d3a290d5526f1fb0310057 Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 2 Jul 2021 13:05:17 +0800 Subject: [PATCH 04/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/graph/load/model_manager/davinci_model.cc | 2 +- ge/graph/load/model_manager/davinci_model.h | 7 ------- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc | 7 +++---- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index 7d82879f..87e0c6f2 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -4365,7 +4365,7 @@ void DavinciModel::SetDataDumperArgs(const ComputeGraphPtr &graph, const map void *{ diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index daf0c7e6..6cb79804 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -499,10 +499,6 @@ class DavinciModel { return exception_dumper_.DumpExceptionInfo(exception_infos); } - void SetKnownShapeGlobalStep(void *global_step) { - known_shape_global_step_ = global_step; - } - void DumperShrink() { data_dumper_.DumpShrink(); } @@ -1109,9 +1105,6 @@ class DavinciModel { vector output_descs_; vector output_formats_; - // known shape node for dump - void *known_shape_global_step_; - // op name to attrs mapping std::map>> op_name_to_attrs_; }; diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index b903f6af..c8ebd160 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -145,8 +145,6 @@ Status KnownNodeTask::InitDavinciModel(const HybridModel &model, TensorBuffer *w auto dump_properties = DumpManager::GetInstance().GetDumpProperties(model.GetSessionId()); if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { davinci_model_->SetDumpProperties(dump_properties); - void *global_step = model.GetGlobalStep(); - davinci_model_->SetKnownShapeGlobalStep(global_step); } void *weight = nullptr; @@ -182,7 +180,7 @@ Status KnownNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) cons return SUCCESS; } -void KnownNodeExecutor::SettingDaviciModel(const HybridModel &model, const NodePtr &node, +void KnownNodeExecutor::SetDaviciModel(const HybridModel &model, const NodePtr &node, std::shared_ptr &davinci_model) const { // set known node flag as true davinci_model->SetKnownNode(true); @@ -190,6 +188,7 @@ void KnownNodeExecutor::SettingDaviciModel(const HybridModel &model, const NodeP davinci_model->SetDumpModelName(model.GetModelName()); davinci_model->SetOmName(model.GetOmName()); TensorValue *global_step_var = model.GetVariable(NODE_NAME_GLOBAL_STEP); + GE_CHECK_NOTNULL(global_step_var); davinci_model->SetGlobalStep(global_step_var->MutableData()); // set model id as root node's node id davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); @@ -212,7 +211,7 @@ Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node std::shared_ptr davinci_model = MakeShared(0, nullptr); GE_CHECK_NOTNULL(davinci_model); - SettingDaviciModel(model, node, davinci_model); + SetDaviciModel(model, node, davinci_model); GELOGD("KnownNodeExecutor::LoadTask node id %ld.", node->GetOpDesc()->GetId()); GE_CHK_STATUS_RET(davinci_model->Assign(ge_model), diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h index 475feeb1..2d51db58 100644 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h @@ -59,7 +59,7 @@ class KnownNodeExecutor : public NodeExecutor { const NodePtr &node, GeModelPtr &ge_model, ComputeGraphPtr &graph); - void SettingDaviciModel(const HybridModel &model, const NodePtr &node, + void SetDaviciModel(const HybridModel &model, const NodePtr &node, std::shared_ptr &davinci_model) const; }; } // namespace hybrid From 9530a1631f5a2cfb274dac3eeef9cb9770e00222 Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 2 Jul 2021 15:34:00 +0800 Subject: [PATCH 05/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index c8ebd160..29c829be 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -188,7 +188,7 @@ void KnownNodeExecutor::SetDaviciModel(const HybridModel &model, const NodePtr & davinci_model->SetDumpModelName(model.GetModelName()); davinci_model->SetOmName(model.GetOmName()); TensorValue *global_step_var = model.GetVariable(NODE_NAME_GLOBAL_STEP); - GE_CHECK_NOTNULL(global_step_var); + GE_CHK_BOOL_EXEC(global_step_var != nullptr, return); davinci_model->SetGlobalStep(global_step_var->MutableData()); // set model id as root node's node id davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); From d74118080c8989eda1bbf9adfed4969dae6db22d Mon Sep 17 00:00:00 2001 From: lichun Date: Fri, 2 Jul 2021 15:55:23 +0800 Subject: [PATCH 06/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- tests/ut/ge/hybrid/known_node_executor_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ut/ge/hybrid/known_node_executor_unittest.cc b/tests/ut/ge/hybrid/known_node_executor_unittest.cc index dd2557d1..e6a6119e 100644 --- a/tests/ut/ge/hybrid/known_node_executor_unittest.cc +++ b/tests/ut/ge/hybrid/known_node_executor_unittest.cc @@ -141,6 +141,6 @@ TEST_F(UnknownNodeExecutorTest, TestSetGlobalStep) { KnownNodeExecutor known_node_executor; std::shared_ptr davinci_model = MakeShared(0, nullptr); - known_node_executor.SettingDaviciModel(hybrid_model, node, davinci_model); + known_node_executor.SetDaviciModel(hybrid_model, node, davinci_model); EXPECT_EQ(*(static_cast(davinci_model->global_step_addr_)), 520); } From 91d70e5f93df1adea8f8bcdbd1ef9fde3582284f Mon Sep 17 00:00:00 2001 From: lichun Date: Sat, 3 Jul 2021 10:43:42 +0800 Subject: [PATCH 07/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/graph/load/model_manager/davinci_model.cc | 2 +- ge/graph/load/model_manager/davinci_model.h | 7 +++++++ ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index 87e0c6f2..7d82879f 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -4365,7 +4365,7 @@ void DavinciModel::SetDataDumperArgs(const ComputeGraphPtr &graph, const map void *{ diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index 6cb79804..daf0c7e6 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -499,6 +499,10 @@ class DavinciModel { return exception_dumper_.DumpExceptionInfo(exception_infos); } + void SetKnownShapeGlobalStep(void *global_step) { + known_shape_global_step_ = global_step; + } + void DumperShrink() { data_dumper_.DumpShrink(); } @@ -1105,6 +1109,9 @@ class DavinciModel { vector output_descs_; vector output_formats_; + // known shape node for dump + void *known_shape_global_step_; + // op name to attrs mapping std::map>> op_name_to_attrs_; }; diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 29c829be..96392fe1 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -145,6 +145,8 @@ Status KnownNodeTask::InitDavinciModel(const HybridModel &model, TensorBuffer *w auto dump_properties = DumpManager::GetInstance().GetDumpProperties(model.GetSessionId()); if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { davinci_model_->SetDumpProperties(dump_properties); + void *global_step = model.GetGlobalStep(); + davinci_model_->SetKnownShapeGlobalStep(); } void *weight = nullptr; From 988ef307399fc8720f4d03a8ada5af835b9db674 Mon Sep 17 00:00:00 2001 From: lichun Date: Sat, 3 Jul 2021 10:44:40 +0800 Subject: [PATCH 08/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 96392fe1..753cf4ba 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -146,7 +146,7 @@ Status KnownNodeTask::InitDavinciModel(const HybridModel &model, TensorBuffer *w if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { davinci_model_->SetDumpProperties(dump_properties); void *global_step = model.GetGlobalStep(); - davinci_model_->SetKnownShapeGlobalStep(); + davinci_model_->SetKnownShapeGlobalStep(global_step); } void *weight = nullptr; From d488c042a57344e7b0759c335860eeb49a132155 Mon Sep 17 00:00:00 2001 From: lichun Date: Sat, 3 Jul 2021 15:38:36 +0800 Subject: [PATCH 09/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/graph/load/model_manager/davinci_model.cc | 5 +++++ ge/graph/load/model_manager/davinci_model.h | 2 +- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc | 9 +++++---- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index 7d82879f..6bf2c6d5 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -1480,6 +1480,11 @@ Status DavinciModel::GetLabelGotoAddr(uint32_t label_index, rtMemType_t mem_type return SUCCESS; } +void DavinciModel::SetGlobalStep(void *global_step, uint64_t global_step_size) { + global_step_addr_ = global_step; + global_step_size_ = global_step_size; +} + /// @ingroup ge /// @brief LabelSet Op Initialize. /// @param [in] op_desc: LabelSet Op descriptor. diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index daf0c7e6..db53d80f 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -300,7 +300,7 @@ class DavinciModel { return op_list_.at(index); } - void SetGlobalStep(void *global_step) { global_step_addr_ = global_step; } + void SetGlobalStep(void *global_step, uint64_t global_step_size); void *GetGlobalStep() const { return global_step_addr_; } // get task info for profiling diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 753cf4ba..292969b6 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -182,7 +182,7 @@ Status KnownNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) cons return SUCCESS; } -void KnownNodeExecutor::SetDaviciModel(const HybridModel &model, const NodePtr &node, +Status KnownNodeExecutor::SetDaviciModel(const HybridModel &model, const NodePtr &node, std::shared_ptr &davinci_model) const { // set known node flag as true davinci_model->SetKnownNode(true); @@ -190,10 +190,11 @@ void KnownNodeExecutor::SetDaviciModel(const HybridModel &model, const NodePtr & davinci_model->SetDumpModelName(model.GetModelName()); davinci_model->SetOmName(model.GetOmName()); TensorValue *global_step_var = model.GetVariable(NODE_NAME_GLOBAL_STEP); - GE_CHK_BOOL_EXEC(global_step_var != nullptr, return); - davinci_model->SetGlobalStep(global_step_var->MutableData()); + GE_CHECK_NOTNULL(global_step_var); + davinci_model->SetGlobalStep(global_step_var->MutableData(), global_step_var->GetSize()); // set model id as root node's node id davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); + return SUCCESS; } Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, @@ -213,7 +214,7 @@ Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node std::shared_ptr davinci_model = MakeShared(0, nullptr); GE_CHECK_NOTNULL(davinci_model); - SetDaviciModel(model, node, davinci_model); + GE_CHK_STATUS_RET_NOLOG(SetDaviciModel(model, node, davinci_model)); GELOGD("KnownNodeExecutor::LoadTask node id %ld.", node->GetOpDesc()->GetId()); GE_CHK_STATUS_RET(davinci_model->Assign(ge_model), diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h index 2d51db58..37b5a3d8 100644 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h @@ -59,8 +59,8 @@ class KnownNodeExecutor : public NodeExecutor { const NodePtr &node, GeModelPtr &ge_model, ComputeGraphPtr &graph); - void SetDaviciModel(const HybridModel &model, const NodePtr &node, - std::shared_ptr &davinci_model) const; + Status SetDaviciModel(const HybridModel &model, const NodePtr &node, + std::shared_ptr &davinci_model) const; }; } // namespace hybrid } // namespace ge From 6bfd96b5409451eca22d82c60fad9679b167ad47 Mon Sep 17 00:00:00 2001 From: lichun Date: Sat, 3 Jul 2021 17:54:44 +0800 Subject: [PATCH 10/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/graph/load/model_manager/davinci_model.cc | 20 +++++++++++--------- ge/graph/load/model_manager/davinci_model.h | 7 ------- .../compiledsubgraph/known_node_executor.cc | 7 ++----- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index 6bf2c6d5..2306665c 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -1547,14 +1547,16 @@ Status DavinciModel::InitLabelSet(const OpDescPtr &op_desc) { } Status DavinciModel::InitVariable(const OpDescPtr &op_desc, map &variable_by_name) { - if (op_desc->GetName() == NODE_NAME_GLOBAL_STEP) { - const auto output_sizes = ModelUtils::GetOutputSize(op_desc); - if (!output_sizes.empty()) { - global_step_size_ = output_sizes[0]; - } - const auto output_addrs = ModelUtils::GetOutputDataAddrs(runtime_param_, op_desc); - if (!output_addrs.empty()) { - global_step_addr_ = output_addrs[0]; + if (!known_node_) { + if (op_desc->GetName() == NODE_NAME_GLOBAL_STEP) { + const auto output_sizes = ModelUtils::GetOutputSize(op_desc); + if (!output_sizes.empty()) { + global_step_size_ = output_sizes[0]; + } + const auto output_addrs = ModelUtils::GetOutputDataAddrs(runtime_param_, op_desc); + if (!output_addrs.empty()) { + global_step_addr_ = output_addrs[0]; + } } } @@ -4370,7 +4372,7 @@ void DavinciModel::SetDataDumperArgs(const ComputeGraphPtr &graph, const map void *{ diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index db53d80f..4ff36677 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -499,10 +499,6 @@ class DavinciModel { return exception_dumper_.DumpExceptionInfo(exception_infos); } - void SetKnownShapeGlobalStep(void *global_step) { - known_shape_global_step_ = global_step; - } - void DumperShrink() { data_dumper_.DumpShrink(); } @@ -1109,9 +1105,6 @@ class DavinciModel { vector output_descs_; vector output_formats_; - // known shape node for dump - void *known_shape_global_step_; - // op name to attrs mapping std::map>> op_name_to_attrs_; }; diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 292969b6..fd33f8b9 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -145,8 +145,6 @@ Status KnownNodeTask::InitDavinciModel(const HybridModel &model, TensorBuffer *w auto dump_properties = DumpManager::GetInstance().GetDumpProperties(model.GetSessionId()); if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { davinci_model_->SetDumpProperties(dump_properties); - void *global_step = model.GetGlobalStep(); - davinci_model_->SetKnownShapeGlobalStep(global_step); } void *weight = nullptr; @@ -189,9 +187,8 @@ Status KnownNodeExecutor::SetDaviciModel(const HybridModel &model, const NodePtr davinci_model->SetId(model.GetModelId()); davinci_model->SetDumpModelName(model.GetModelName()); davinci_model->SetOmName(model.GetOmName()); - TensorValue *global_step_var = model.GetVariable(NODE_NAME_GLOBAL_STEP); - GE_CHECK_NOTNULL(global_step_var); - davinci_model->SetGlobalStep(global_step_var->MutableData(), global_step_var->GetSize()); + void *global_step = model.GetGlobalStep(); + davinci_model->SetGlobalStep(global_step, sizeof(int64_t)); // set model id as root node's node id davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); return SUCCESS; From 95944c17963c0595091de45486204f0a5e5d9d44 Mon Sep 17 00:00:00 2001 From: lichun Date: Sat, 3 Jul 2021 18:05:43 +0800 Subject: [PATCH 11/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index fd33f8b9..e5663fb8 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -188,6 +188,7 @@ Status KnownNodeExecutor::SetDaviciModel(const HybridModel &model, const NodePtr davinci_model->SetDumpModelName(model.GetModelName()); davinci_model->SetOmName(model.GetOmName()); void *global_step = model.GetGlobalStep(); + GE_CHECK_NOTNULL(global_step); davinci_model->SetGlobalStep(global_step, sizeof(int64_t)); // set model id as root node's node id davinci_model->SetSubModelId(node->GetOpDesc()->GetId()); From dcdfae9453ef209439b14801514a66227524b3d0 Mon Sep 17 00:00:00 2001 From: lichun Date: Sat, 3 Jul 2021 18:14:27 +0800 Subject: [PATCH 12/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- ge/graph/load/model_manager/davinci_model.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index 2306665c..9d86039a 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -4372,7 +4372,7 @@ void DavinciModel::SetDataDumperArgs(const ComputeGraphPtr &graph, const map void *{ From 6314c48f921201de882d64449a49342a782bffeb Mon Sep 17 00:00:00 2001 From: lichun Date: Mon, 5 Jul 2021 10:07:42 +0800 Subject: [PATCH 13/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- tests/ut/ge/hybrid/known_node_executor_unittest.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/ut/ge/hybrid/known_node_executor_unittest.cc b/tests/ut/ge/hybrid/known_node_executor_unittest.cc index e6a6119e..ea499422 100644 --- a/tests/ut/ge/hybrid/known_node_executor_unittest.cc +++ b/tests/ut/ge/hybrid/known_node_executor_unittest.cc @@ -135,10 +135,9 @@ TEST_F(UnknownNodeExecutorTest, TestSetGlobalStep) { HybridModel hybrid_model(ge_root_model); auto *step_id = new int64_t[1]; step_id[0] = 520; - std::unique_ptr tensor_value; - tensor_value.reset(new(std::nothrow)TensorValue((void*)step_id, sizeof(step_id))); - hybrid_model.variable_tensors_.insert({"ge_global_step", std::move(tensor_value)}); - + std::unique_ptr tensor_buf; + tensor_buf = tensor_buf->Create((void *)step_id, sizeof(int64_t)); + hybrid_model.global_step_ = std::move(tensor_buf); KnownNodeExecutor known_node_executor; std::shared_ptr davinci_model = MakeShared(0, nullptr); known_node_executor.SetDaviciModel(hybrid_model, node, davinci_model); From 27dae9195ce46815a0d71f5caa21247937ed9eb4 Mon Sep 17 00:00:00 2001 From: lichun Date: Mon, 5 Jul 2021 10:30:59 +0800 Subject: [PATCH 14/14] add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed --- tests/ut/ge/hybrid/known_node_executor_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ut/ge/hybrid/known_node_executor_unittest.cc b/tests/ut/ge/hybrid/known_node_executor_unittest.cc index ea499422..b6d06f5d 100644 --- a/tests/ut/ge/hybrid/known_node_executor_unittest.cc +++ b/tests/ut/ge/hybrid/known_node_executor_unittest.cc @@ -135,7 +135,7 @@ TEST_F(UnknownNodeExecutorTest, TestSetGlobalStep) { HybridModel hybrid_model(ge_root_model); auto *step_id = new int64_t[1]; step_id[0] = 520; - std::unique_ptr tensor_buf; + std::unique_ptr tensor_buf; tensor_buf = tensor_buf->Create((void *)step_id, sizeof(int64_t)); hybrid_model.global_step_ = std::move(tensor_buf); KnownNodeExecutor known_node_executor;