|
|
|
@@ -54,6 +54,7 @@ |
|
|
|
#include "register/scope/scope_pass_registry_impl.h" |
|
|
|
#include "parser/common/auto_mapping_subgraph_io_index_func.h" |
|
|
|
#include "graph/def_types.h" |
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
using ge::OpParserFactory; |
|
|
|
using ge::Pb2Json; |
|
|
|
@@ -231,6 +232,9 @@ Status GenSubgraphParseTasks(const ge::ComputeGraphPtr &parent_graph, std::deque |
|
|
|
|
|
|
|
// A function may be referenced multiple times in TF, change the graph name to ensure it is unique in GE |
|
|
|
auto unique_name = node->GetName() + std::to_string(i) + subgraph_iname; |
|
|
|
std::cout << "linyanfeng GenSubgraphParseTasks unique_name, node:"<<node->GetName().c_str() |
|
|
|
<< ", index:" << i |
|
|
|
<< ", computGraph:" << subgraph_iname.c_str() << std::endl; |
|
|
|
auto subgraph = ge::parser::MakeShared<ge::ComputeGraph>(unique_name); |
|
|
|
if (subgraph == nullptr) { |
|
|
|
REPORT_CALL_ERROR("E19999", "New ComputeGraph failed when create subgraph:%s", subgraph_iname.c_str()); |
|
|
|
@@ -245,7 +249,7 @@ Status GenSubgraphParseTasks(const ge::ComputeGraphPtr &parent_graph, std::deque |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
GELOGD("Add subgraph parse task to the queue, node %s, index %u, subgraph instance name %s", |
|
|
|
GELOGI("Add subgraph parse task to the queue, node %s, index %u, subgraph instance name %s", |
|
|
|
node->GetName().c_str(), i, subgraph_iname.c_str()); |
|
|
|
args.push_back({nullptr, subgraph_iname, node, subgraph_name_to_index.first, subgraph}); |
|
|
|
} |
|
|
|
@@ -271,8 +275,10 @@ Status PostOpProcessForSubgraph(const ParseArg &arg) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
GELOGD("Post process for subgraph %s node %s type %s subgraph name %s", arg.function_name.c_str(), |
|
|
|
arg.parent_node->GetName().c_str(), arg.parent_node->GetType().c_str(), arg.subgraph_name.c_str()); |
|
|
|
std::cout << "Post process for subgraph:" << arg.function_name |
|
|
|
<< " ,node:"<< arg.parent_node->GetName() |
|
|
|
<<" ,type:" << arg.parent_node->GetType() |
|
|
|
<<" ,subgraph name:" << arg.subgraph_name << std::endl; |
|
|
|
|
|
|
|
// refresh node_name in subgraph |
|
|
|
for (const ge::NodePtr &node : arg.graph->GetDirectNode()) { |
|
|
|
@@ -280,6 +286,24 @@ Status PostOpProcessForSubgraph(const ParseArg &arg) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
node->GetOpDesc()->SetName(node->GetOwnerComputeGraph()->GetName() + "/" + node->GetName()); |
|
|
|
std::vector<std::string> original_names; |
|
|
|
(void)ge::AttrUtils::GetListStr(op_desc, ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_names); |
|
|
|
if (original_names.empty()) { |
|
|
|
original_names.push_back(arg.parent_node->GetName()); |
|
|
|
auto parend_desc = arg.parent_node->GetOpDesc(); |
|
|
|
if (!ge::AttrUtils::SetListStr(parend_desc, ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_names)) { |
|
|
|
GELOGW("Set %s to %s fail.", ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES.c_str(), parend_desc->GetName().c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
original_names.push_back(node->GetName()); |
|
|
|
if (!ge::AttrUtils::SetListStr(node->GetOpDesc(), ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_names)) { |
|
|
|
GELOGW("Set %s to %s fail.", ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES.c_str(), node->GetOpDesc().c_str()); |
|
|
|
} |
|
|
|
|
|
|
|
std::cout << "linyanfeng PostOpProcessForSubgraph set name: " << node->GetOpDesc()->GetName() |
|
|
|
<<", computGraph:" << node->GetOwnerComputeGraph()->GetName() |
|
|
|
<<", node:" << node->GetName() << std::endl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
auto graph = ge::GraphUtils::CreateGraphFromComputeGraph(arg.graph); |
|
|
|
@@ -2357,6 +2381,9 @@ Status TensorFlowModelParser::ParseProtoWithSubgraph(const google::protobuf::Mes |
|
|
|
std::deque<ParseArg> tasks; |
|
|
|
tasks.push_back({root_proto, "root", nullptr, "", root_graph}); |
|
|
|
|
|
|
|
GELOGE(OUT_OF_MEMORY, "linyanfeng 1"); |
|
|
|
|
|
|
|
std::cout << "lin ParseProtoWithSubgraph" << std::endl; |
|
|
|
while (!tasks.empty()) { |
|
|
|
auto arg = tasks.front(); |
|
|
|
tasks.pop_front(); |
|
|
|
@@ -2426,40 +2453,50 @@ Status TensorFlowModelParser::ParseProtoWithSubgraph(const std::string &root_pro |
|
|
|
std::deque<ParseArg> tasks; |
|
|
|
tasks.push_back({nullptr, "root", nullptr, "", root_graph}); |
|
|
|
bool root_parsed = false; |
|
|
|
|
|
|
|
std::cout << "linyanfeng 1" << std::endl; |
|
|
|
|
|
|
|
while (!tasks.empty()) { |
|
|
|
auto arg = tasks.front(); |
|
|
|
tasks.pop_front(); |
|
|
|
|
|
|
|
std::cout << "linyanfeng 2" << std::endl; |
|
|
|
auto model_parser = domi::ModelParserFactory::Instance()->CreateModelParser(domi::FrameworkType::TENSORFLOW); |
|
|
|
|
|
|
|
Status ret = SUCCESS; |
|
|
|
if (root_parsed) { |
|
|
|
std::cout << "linyanfeng 3" << std::endl; |
|
|
|
GELOGI("Begin to parse serialized proto of sub graph %s", arg.function_name.c_str()); |
|
|
|
ret = model_parser->ParseProto(callback(arg.function_name), arg.graph); |
|
|
|
} else { |
|
|
|
std::cout << "linyanfeng 4" << std::endl; |
|
|
|
GELOGI("Begin to parse serialized proto of root graph"); |
|
|
|
ret = model_parser->ParseProto(root_proto, arg.graph); |
|
|
|
root_parsed = true; |
|
|
|
} |
|
|
|
|
|
|
|
std::cout << "linyanfeng 5" << std::endl; |
|
|
|
if (ret != SUCCESS) { |
|
|
|
std::cout << "linyanfeng 6" << std::endl; |
|
|
|
GELOGE(ret, "Failed to parse graph %s, instance name %s", arg.function_name.c_str(), |
|
|
|
arg.graph->GetName().c_str()); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
std::cout << "linyanfeng 7" << std::endl; |
|
|
|
|
|
|
|
ret = PostOpProcessForSubgraph(arg); |
|
|
|
if (ret != SUCCESS) { |
|
|
|
std::cout << "linyanfeng 8" << std::endl; |
|
|
|
return ret; // the error log has been printed inner the function |
|
|
|
} |
|
|
|
|
|
|
|
std::cout << "linyanfeng 9" << std::endl; |
|
|
|
ret = GenSubgraphParseTasks(arg.graph, tasks); |
|
|
|
if (ret != SUCCESS) { |
|
|
|
std::cout << "linyanfeng 110" << std::endl; |
|
|
|
GELOGE(ret, "Failed to gen tasks for sub graph of graph %s", arg.graph->GetName().c_str()); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
std::cout << "linyanfeng 11" << std::endl; |
|
|
|
} |
|
|
|
std::cout << "linyanfeng 12" << std::endl; |
|
|
|
auto add_ret = AddExternalGraph(root_graph); |
|
|
|
if (add_ret != SUCCESS) { |
|
|
|
GELOGE(add_ret, "Failed to add external graph for root graph %s.", root_graph->GetName().c_str()); |
|
|
|
|