Browse Source

add global step info for known subgraph in unknown model and generate om for remained cases when some single op cases run atc failed

tags/v1.5.1
lichun 3 years ago
parent
commit
81d226b36b
5 changed files with 75 additions and 10 deletions
  1. +1
    -0
      ge/graph/load/model_manager/davinci_model.h
  2. +14
    -7
      ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc
  3. +2
    -0
      ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h
  4. +2
    -2
      ge/offline/main.cc
  5. +56
    -1
      tests/ut/ge/hybrid/known_node_executor_unittest.cc

+ 1
- 0
ge/graph/load/model_manager/davinci_model.h View File

@@ -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


+ 14
- 7
ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc View File

@@ -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<DavinciModel> &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<NodeTask> &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<DavinciModel> davinci_model = MakeShared<DavinciModel>(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),


+ 2
- 0
ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h View File

@@ -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<DavinciModel> &davinci_model) const;
};
} // namespace hybrid
} // namespace ge


+ 2
- 2
ge/offline/main.cc View File

@@ -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;
}



+ 56
- 1
tests/ut/ge/hybrid/known_node_executor_unittest.cc View File

@@ -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<ge::OpDesc>(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<DavinciModel>(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);
}
}

TEST_F(UnknownNodeExecutorTest, TestSetGlobalStep) {
OpDescPtr op_desc = CreateOpDesc("PartitionedCall", "PartitionedCall");
auto root_graph = make_shared<ComputeGraph>("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<GeRootModel>(root_graph);
HybridModel hybrid_model(ge_root_model);
auto *step_id = new int64_t[1];
step_id[0] = 520;
std::unique_ptr<TensorValue> 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<DavinciModel> davinci_model = MakeShared<DavinciModel>(0, nullptr);
known_node_executor.SettingDaviciModel(hybrid, node, davinci_model);
EXPECT_EQ(davinci_model->global_step_addr_, 520);
}

Loading…
Cancel
Save