Browse Source

Pre Merge pull request !282 from 张晓昆/development

pull/282/MERGE
张晓昆 Gitee 4 years ago
parent
commit
d6c9527399
2 changed files with 23 additions and 12 deletions
  1. +21
    -10
      ge/graph/build/label_allocator.cc
  2. +2
    -2
      ge/graph/build/model_builder.cc

+ 21
- 10
ge/graph/build/label_allocator.cc View File

@@ -32,11 +32,6 @@ Status LabelAllocator::AssignFunctionalLabels() {
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


if (compute_graph_->GetGraphUnknownFlag()) {
GELOGD("Graph[%s] is unknown graph, skip label allocator.", compute_graph_->GetName().c_str());
return SUCCESS;
}

// Add label task for sub graph. // Add label task for sub graph.
GELOGI("AssignFunctionalLabels start: %s.", compute_graph_->GetName().c_str()); GELOGI("AssignFunctionalLabels start: %s.", compute_graph_->GetName().c_str());
std::set<NodePtr> functional_nodes; std::set<NodePtr> functional_nodes;
@@ -62,7 +57,7 @@ Status LabelAllocator::AssignFunctionalLabels() {
} }


(void)AttrUtils::SetInt(*compute_graph_, ATTR_MODEL_LABEL_NUM, label_index); (void)AttrUtils::SetInt(*compute_graph_, ATTR_MODEL_LABEL_NUM, label_index);
GELOGI("AssignFunctionalLabels success.");
GELOGI("AssignFunctionalLabels success, Num: %u.", label_index);
return SUCCESS; return SUCCESS;
} }


@@ -72,13 +67,29 @@ bool LabelAllocator::CollectFunctionalNode(ComputeGraphPtr &graph, std::set<Node
return false; return false;
} }


NodePtr parent = graph->GetParentNode();
if (parent == nullptr) {
GELOGE(INTERNAL_ERROR, "ComputeGraph owner not set: %s.", graph->GetName().c_str());
if (graph->GetGraphUnknownFlag()) {
GELOGD("Graph[%s] is unknown graph, skip label allocator.", graph->GetName().c_str());
return true;
}

NodePtr func_node = graph->GetParentNode();
if (func_node == nullptr) {
GELOGE(INTERNAL_ERROR, "Parent functional node not set: %s.", graph->GetName().c_str());
return false; return false;
} }


(void)functional_nodes.insert(parent); // unique functional node.
ComputeGraphPtr owner_graph = func_node->GetOwnerComputeGraph();
if (owner_graph == nullptr) {
GELOGE(INTERNAL_ERROR, "ComputeGraph owner not set: %s.", func_node->GetName().c_str());
return false;
}

if (owner_graph->GetGraphUnknownFlag()) {
GELOGD("Graph[%s] is unknown graph, skip label allocator.", owner_graph->GetName().c_str());
return true;
}

(void)functional_nodes.insert(func_node); // unique functional node.
return true; return true;
} }
} // namespace ge } // namespace ge

+ 2
- 2
ge/graph/build/model_builder.cc View File

@@ -690,8 +690,8 @@ Status ModelBuilder::BuildModelForGetTask(ge::Model &model) {
GE_TIMESTAMP_END(AssignLogicalStreams, "GraphBuilder::AssignLogicalStreams"); GE_TIMESTAMP_END(AssignLogicalStreams, "GraphBuilder::AssignLogicalStreams");


// Assign functional op labels. // Assign functional op labels.
label_num_ = 0;
(void)AttrUtils::GetInt(*compute_graph_, ATTR_MODEL_LABEL_NUM, label_num_);
auto root_graph = GraphUtils::FindRootGraph(compute_graph_);
(void)AttrUtils::GetInt(*root_graph, ATTR_MODEL_LABEL_NUM, label_num_);


GE_TIMESTAMP_START(AssignMemory); GE_TIMESTAMP_START(AssignMemory);
MemoryAssigner mem_assigner(compute_graph_); MemoryAssigner mem_assigner(compute_graph_);


Loading…
Cancel
Save