|
|
|
@ -263,6 +263,7 @@ void AscendSession::BuildGraph(GraphId graph_id) {
|
|
|
|
|
}
|
|
|
|
|
// sync the inital const tensor to device
|
|
|
|
|
SyncInitialTenosrToDevice();
|
|
|
|
|
ExportChildGraphs(graph_id);
|
|
|
|
|
MS_LOG(INFO) << "end";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -558,6 +559,36 @@ void AscendSession::Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const
|
|
|
|
|
MS_LOG(INFO) << "Finish!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AscendSession::ExportChildGraphs(const GraphId graph_id) {
|
|
|
|
|
#ifdef ENABLE_DUMP_IR
|
|
|
|
|
auto context_ptr = MsContext::GetInstance();
|
|
|
|
|
MS_EXCEPTION_IF_NULL(context_ptr);
|
|
|
|
|
bool save_graphs = context_ptr->save_graphs_flag();
|
|
|
|
|
if (!save_graphs) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
auto save_graphs_path = context_ptr->save_graphs_path();
|
|
|
|
|
if (save_graphs_path.empty()) {
|
|
|
|
|
save_graphs_path = ".";
|
|
|
|
|
}
|
|
|
|
|
if (graph_id == final_graph_id_) {
|
|
|
|
|
auto &graph_order = GetGraphOrder(final_graph_id_);
|
|
|
|
|
auto &graph_type = GetGraphOrderType(final_graph_id_);
|
|
|
|
|
for (size_t i = 0; i < graph_order.size(); i++) {
|
|
|
|
|
if (graph_type[i] == BRANCH_END || graph_type[i] == BRANCH_START) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
auto child_graph = GetGraph(graph_order[i]);
|
|
|
|
|
MS_LOG(DEBUG) << "Start export child graph " << graph_order[i];
|
|
|
|
|
std::string file_path = save_graphs_path + "/graph_build_" + std::to_string(child_graph->graph_id()) + ".ir";
|
|
|
|
|
DumpIR(file_path, child_graph, true);
|
|
|
|
|
DumpIRProto(child_graph, "vm_build_" + std::to_string(child_graph->graph_id()));
|
|
|
|
|
MS_LOG(DEBUG) << "End export child graph " << graph_order[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GraphId AscendSession::SetFinalGraphInput(const std::vector<AnfNodePtr> &args) {
|
|
|
|
|
MS_LOG(INFO) << "Start! Args size " << args.size();
|
|
|
|
|
auto final_graph = NewKernelGraph();
|
|
|
|
|