| @@ -21,7 +21,6 @@ | |||||
| #include <string> | #include <string> | ||||
| #include "session/anf_runtime_algorithm.h" | #include "session/anf_runtime_algorithm.h" | ||||
| #include "common/utils.h" | |||||
| #include "utils/utils.h" | #include "utils/utils.h" | ||||
| #include "operator/ops.h" | #include "operator/ops.h" | ||||
| #include "pre_activate/common/helper.h" | #include "pre_activate/common/helper.h" | ||||
| @@ -51,7 +50,7 @@ CNodePtr GenerateSquareSumV1(const FuncGraphPtr &graph, const CNodePtr &square, | |||||
| square_sumv1->set_scope(sum->scope()); | square_sumv1->set_scope(sum->scope()); | ||||
| AnfAlgo::CopyNodeAttr(kAttrAxis, sum, square_sumv1); | AnfAlgo::CopyNodeAttr(kAttrAxis, sum, square_sumv1); | ||||
| AnfAlgo::CopyNodeAttr(kAttrKeepDims, sum, square_sumv1); | AnfAlgo::CopyNodeAttr(kAttrKeepDims, sum, square_sumv1); | ||||
| auto names = MakeValue<std::vector<std::string>>({prim::kPrimSquare->name(), prim::kPrimReduceSum->name()}); | |||||
| auto names = MakeValue<std::vector<std::string>>({square->fullname_with_scope(), sum->fullname_with_scope()}); | |||||
| AnfAlgo::SetNodeAttr(kAttrDatadumpOriginalNames, names, square_sumv1); | AnfAlgo::SetNodeAttr(kAttrDatadumpOriginalNames, names, square_sumv1); | ||||
| return square_sumv1; | return square_sumv1; | ||||
| } | } | ||||
| @@ -74,7 +73,7 @@ CNodePtr GenerateSquareSumV2(const FuncGraphPtr &graph, const CNodePtr &square, | |||||
| square_sumv2->set_scope(sum->scope()); | square_sumv2->set_scope(sum->scope()); | ||||
| AnfAlgo::CopyNodeAttr(kAttrAxis, sum, square_sumv2); | AnfAlgo::CopyNodeAttr(kAttrAxis, sum, square_sumv2); | ||||
| AnfAlgo::CopyNodeAttr(kAttrKeepDims, sum, square_sumv2); | AnfAlgo::CopyNodeAttr(kAttrKeepDims, sum, square_sumv2); | ||||
| auto names = MakeValue<std::vector<std::string>>({prim::kPrimSquare->name(), prim::kPrimReduceSum->name()}); | |||||
| auto names = MakeValue<std::vector<std::string>>({square->fullname_with_scope(), sum->fullname_with_scope()}); | |||||
| AnfAlgo::SetNodeAttr(kAttrDatadumpOriginalNames, names, square_sumv2); | AnfAlgo::SetNodeAttr(kAttrDatadumpOriginalNames, names, square_sumv2); | ||||
| return square_sumv2; | return square_sumv2; | ||||
| } | } | ||||
| @@ -337,6 +337,7 @@ GraphId AscendSession::CompileGraph(NotNull<FuncGraphPtr> func_graph) { | |||||
| GenerateTaskInfo(root_graph); | GenerateTaskInfo(root_graph); | ||||
| // load task into device | // load task into device | ||||
| LoadTask(root_graph); | LoadTask(root_graph); | ||||
| DumpAllGraphs(all_graphs); | |||||
| // return the root_graph id to backend | // return the root_graph id to backend | ||||
| auto graph_id = root_graph->graph_id(); | auto graph_id = root_graph->graph_id(); | ||||
| return graph_id; | return graph_id; | ||||
| @@ -418,7 +419,7 @@ void AscendSession::BuildGraph(GraphId graph_id) { | |||||
| } | } | ||||
| // sync the inital const tensor to device | // sync the inital const tensor to device | ||||
| SyncInitialTenosrToDevice(); | SyncInitialTenosrToDevice(); | ||||
| ExportChildGraphs(graph_id); | |||||
| DumpAllGraphs({graph}); | |||||
| MS_LOG(INFO) << "End"; | MS_LOG(INFO) << "End"; | ||||
| } | } | ||||
| @@ -762,7 +763,7 @@ void AscendSession::Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const | |||||
| MS_LOG(INFO) << "Finish!"; | MS_LOG(INFO) << "Finish!"; | ||||
| } | } | ||||
| void AscendSession::ExportChildGraphs(const GraphId graph_id) { | |||||
| void AscendSession::DumpAllGraphs(const std::vector<KernelGraphPtr> &all_graphs) { | |||||
| #ifdef ENABLE_DUMP_IR | #ifdef ENABLE_DUMP_IR | ||||
| auto context_ptr = MsContext::GetInstance(); | auto context_ptr = MsContext::GetInstance(); | ||||
| MS_EXCEPTION_IF_NULL(context_ptr); | MS_EXCEPTION_IF_NULL(context_ptr); | ||||
| @@ -774,21 +775,11 @@ void AscendSession::ExportChildGraphs(const GraphId graph_id) { | |||||
| if (save_graphs_path.empty()) { | if (save_graphs_path.empty()) { | ||||
| save_graphs_path = "."; | save_graphs_path = "."; | ||||
| } | } | ||||
| if (graph_id == final_graph_id_) { | |||||
| const auto &graph_order = GetGraphOrder(final_graph_id_); | |||||
| const 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; | |||||
| } | |||||
| const auto child_graph = GetGraph(graph_order[i]); | |||||
| MS_LOG(DEBUG) << "Start export child graph " << graph_order[i]; | |||||
| MS_EXCEPTION_IF_NULL(child_graph); | |||||
| 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]; | |||||
| } | |||||
| for (auto &graph : all_graphs) { | |||||
| MS_EXCEPTION_IF_NULL(graph); | |||||
| std::string file_path = save_graphs_path + "/graph_build_" + std::to_string(graph->graph_id()) + ".ir"; | |||||
| DumpIR(file_path, graph, true); | |||||
| DumpIRProto(graph, "vm_build_" + std::to_string(graph->graph_id())); | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -85,7 +85,7 @@ class AscendSession : public SessionBasic { | |||||
| void LoadTask(const std::shared_ptr<KernelGraph> &kernel_graph) const; | void LoadTask(const std::shared_ptr<KernelGraph> &kernel_graph) const; | ||||
| void ExecTask(const std::shared_ptr<KernelGraph> &kernel_graph) const; | void ExecTask(const std::shared_ptr<KernelGraph> &kernel_graph) const; | ||||
| void Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const; | void Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const; | ||||
| void ExportChildGraphs(const GraphId graph_id); | |||||
| void DumpAllGraphs(const std::vector<KernelGraphPtr> &all_graphs); | |||||
| void LoadTensor(const std::shared_ptr<KernelGraph> &kernel_graph) const; | void LoadTensor(const std::shared_ptr<KernelGraph> &kernel_graph) const; | ||||
| // below functions are used for run op | // below functions are used for run op | ||||
| void RunOpHardwareOptimize(const std::shared_ptr<session::KernelGraph> &kernel_graph) const; | void RunOpHardwareOptimize(const std::shared_ptr<session::KernelGraph> &kernel_graph) const; | ||||