diff --git a/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc b/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc index 0457eab8b3..88934d6844 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc +++ b/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc @@ -257,14 +257,9 @@ void AscendBackendIRFusionOptimization(const std::shared_ptrget_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_d_ir_fusion_before" + "_graph_" + - std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_d_ir_fusion_before_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); DumpIRProto(kernel_graph, "before_hwopt_" + std::to_string(kernel_graph->graph_id())); } auto optimizer = std::make_shared(); @@ -300,9 +295,8 @@ void AscendBackendIRFusionOptimization(const std::shared_ptrOptimize(kernel_graph); kernel_graph->SetExecOrderByDefault(); if (save_graphs) { - std::string file_path = - save_graphs_path + "/" + "hwopt_d_ir_fusion_after" + "_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_d_ir_fusion_after_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } } @@ -314,13 +308,8 @@ void RunOpAscendBackendIRFusionOptimization(const std::shared_ptrget_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_d_ir_fusion_before.ir"; - DumpIR(file_path, kernel_graph); + DumpIR("hwopt_d_ir_fusion_before.ir", kernel_graph); } auto optimizer = std::make_shared(); auto ir_fusion_pm = std::make_shared("ir_fusion_pm"); @@ -336,8 +325,7 @@ void RunOpAscendBackendIRFusionOptimization(const std::shared_ptrOptimize(kernel_graph); kernel_graph->SetExecOrderByDefault(); if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_d_ir_fusion_after.ir"; - DumpIR(file_path, kernel_graph); + DumpIR("hwopt_d_ir_fusion_after.ir", kernel_graph); } } @@ -345,14 +333,9 @@ void AscendBackendOptimization(const std::shared_ptr &kern auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = - save_graphs_path + "/" + "hwopt_d_before" + "_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_d_before_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } // data layout optimization AscendDataLayout(kernel_graph); @@ -390,9 +373,8 @@ void AscendBackendOptimization(const std::shared_ptr &kern kernel_graph->SetExecOrderByDefault(); if (save_graphs) { - std::string file_path = - save_graphs_path + "/" + "hwopt_d_end" + "_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph, true); + std::string file_name = "hwopt_d_end_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph, true); DumpIRProto(kernel_graph, "after_hwopt_" + std::to_string(kernel_graph->graph_id())); kernel_graph->DumpFuncGraph("hwopt_d_end"); } @@ -406,25 +388,19 @@ void AscendBackendGraphKernelOpt(const std::shared_ptr &ke return; } bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_d_graph_kernel_opt_before_graph_" + - std::to_string(!is_before_kernel_select) + "_" + std::to_string(kernel_graph->graph_id()) + - ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_d_graph_kernel_opt_before_graph_" + std::to_string(!is_before_kernel_select) + "_" + + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } // Fuse graph kernels with basic ops static_cast(FuseCompositeOps(kernel_graph, is_before_kernel_select)); if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_d_graph_kernel_opt_end_graph_" + - std::to_string(!is_before_kernel_select) + "_" + std::to_string(kernel_graph->graph_id()) + - ".ir"; - DumpIR(file_path, kernel_graph, true); + std::string file_name = "hwopt_d_graph_kernel_opt_end_graph_" + std::to_string(!is_before_kernel_select) + "_" + + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph, true); } } @@ -436,25 +412,19 @@ void AscendBackendFuseBasicOpt(const std::shared_ptr &kern return; } bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_fuse_basic_opt_before_graph_" + - std::to_string(!is_before_kernel_select) + "_" + std::to_string(kernel_graph->graph_id()) + - ".ir"; - DumpIR(file_path, kernel_graph, true); + std::string file_name = "hwopt_fuse_basic_opt_before_graph_" + std::to_string(!is_before_kernel_select) + "_" + + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph, true); } // Fuse basic ops with basic ops static_cast(FuseBasicOps(kernel_graph, is_before_kernel_select)); if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_fuse_basic_opt_end_graph_" + - std::to_string(!is_before_kernel_select) + "_" + std::to_string(kernel_graph->graph_id()) + - ".ir"; - DumpIR(file_path, kernel_graph, true); + std::string file_name = "hwopt_fuse_basic_opt_end_graph_" + std::to_string(!is_before_kernel_select) + "_" + + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph, true); } } @@ -465,22 +435,16 @@ void AscendBackendAddAtomicClean(const std::shared_ptr &ke return; } bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "hwopt_d_add_atomic_clean_before" + "_graph_" + - std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_d_add_atomic_clean_before_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } AddAtomicClean(kernel_graph); if (save_graphs) { - std::string file_path = - save_graphs_path + "/" + "hwopt_d_end" + "_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph, true); + std::string file_name = "hwopt_d_end_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph, true); } } @@ -492,14 +456,9 @@ void AscendBackendUBFusionOptimization(const std::shared_ptrget_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = - save_graphs_path + "/hwopt_d_ub_fusion_before_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_d_ub_fusion_before_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } auto fusion_id_allocator = std::make_shared(); MS_EXCEPTION_IF_NULL(fusion_id_allocator); @@ -525,9 +484,8 @@ void AscendBackendUBFusionOptimization(const std::shared_ptrOptimize(kernel_graph); kernel_graph->SetExecOrderByDefault(); if (save_graphs) { - std::string file_path = - save_graphs_path + "/hwopt_d_ub_fusion_after_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_d_ub_fusion_after_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } } } // namespace opt diff --git a/mindspore/ccsrc/backend/optimizer/common/common_backend_optimization.cc b/mindspore/ccsrc/backend/optimizer/common/common_backend_optimization.cc index e8f51b6b30..56949c93fa 100644 --- a/mindspore/ccsrc/backend/optimizer/common/common_backend_optimization.cc +++ b/mindspore/ccsrc/backend/optimizer/common/common_backend_optimization.cc @@ -34,14 +34,9 @@ void BackendCommonOptimization(const std::shared_ptr &kern auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = - save_graphs_path + "/hwopt_common_before_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_common_before_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } auto optimizer = std::make_shared(); auto common_pm = std::make_shared("common_pm"); @@ -55,9 +50,8 @@ void BackendCommonOptimization(const std::shared_ptr &kern (void)optimizer->Optimize(kernel_graph); kernel_graph->SetExecOrderByDefault(); if (save_graphs) { - std::string file_path = - save_graphs_path + "/hwopt_common_after_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; - DumpIR(file_path, kernel_graph); + std::string file_name = "hwopt_common_after_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir"; + DumpIR(file_name, kernel_graph); } } } // namespace opt diff --git a/mindspore/ccsrc/backend/optimizer/common/pass_manager.cc b/mindspore/ccsrc/backend/optimizer/common/pass_manager.cc index 2a455b7a73..809441e992 100644 --- a/mindspore/ccsrc/backend/optimizer/common/pass_manager.cc +++ b/mindspore/ccsrc/backend/optimizer/common/pass_manager.cc @@ -41,10 +41,6 @@ bool PassManager::Run(const FuncGraphPtr &func_graph, const std::vector auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } bool changed = false; size_t num = 0; for (const auto &pass : passes) { @@ -71,9 +67,8 @@ bool PassManager::Run(const FuncGraphPtr &func_graph, const std::vector MS_LOG(INFO) << "Run pass hwopt_" + name() + "_" << num << "_" + pass->name() + " in " << cost << " us"; #endif if (save_graphs) { - auto dump_file_path = - save_graphs_path + "/" + "hwopt_" + name() + "_" + std::to_string(num) + "_" + pass->name() + ".ir"; - DumpIR(dump_file_path, func_graph, true); + auto file_name = "hwopt_" + name() + "_" + std::to_string(num) + "_" + pass->name() + ".ir"; + DumpIR(file_name, func_graph, true); } num++; } diff --git a/mindspore/ccsrc/backend/session/ascend_control_parser.cc b/mindspore/ccsrc/backend/session/ascend_control_parser.cc index 07a2e9b7d0..b44262b597 100644 --- a/mindspore/ccsrc/backend/session/ascend_control_parser.cc +++ b/mindspore/ccsrc/backend/session/ascend_control_parser.cc @@ -370,13 +370,9 @@ void AscendControlParser::ExecutorValidate(NotNull root_graph) { auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG)) { - std::string file_path = save_graphs_path + "/after_erase_label_and_parameter.ir"; - DumpIR(file_path, root_graph.get()); + std::string file_name = "after_erase_label_and_parameter.ir"; + DumpIR(file_name, root_graph.get()); } } diff --git a/mindspore/ccsrc/backend/session/ascend_session.cc b/mindspore/ccsrc/backend/session/ascend_session.cc index 8d64272178..f90db100e0 100644 --- a/mindspore/ccsrc/backend/session/ascend_session.cc +++ b/mindspore/ccsrc/backend/session/ascend_session.cc @@ -280,21 +280,15 @@ void AscendSession::CompileChildGraph(const KernelGraphPtr &child_graph) { auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = - save_graphs_path + "/" + "select_kernel_before" + "_graph_" + std::to_string(child_graph->graph_id()) + ".ir"; - DumpIR(file_path, child_graph); + std::string file_name = "select_kernel_before_graph_" + std::to_string(child_graph->graph_id()) + ".ir"; + DumpIR(file_name, child_graph); } // select kernel build info SelectKernel(*child_graph); if (save_graphs) { - std::string file_path = - save_graphs_path + "/" + "select_kernel_after" + "_graph_" + std::to_string(child_graph->graph_id()) + ".ir"; - DumpIR(file_path, child_graph); + std::string file_name = "select_kernel_after_graph_" + std::to_string(child_graph->graph_id()) + ".ir"; + DumpIR(file_name, child_graph); } // optimize graph HardwareOptimize(child_graph); @@ -469,13 +463,8 @@ void AscendSession::AdjustKernel(const std::shared_ptr &kernel_grap auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } if (save_graphs) { - std::string file_path = save_graphs_path + "/" + "after_adjust_kernel.ir"; - DumpIR(file_path, kernel_graph); + DumpIR("after_adjust_kernel.ir", kernel_graph); } MS_LOG(INFO) << "Finish!"; } @@ -589,14 +578,10 @@ void AscendSession::DumpAllGraphs(const std::vector &all_graphs) if (!save_graphs) { return; } - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } 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); + std::string file_name = "graph_build_" + std::to_string(graph->graph_id()) + ".ir"; + DumpIR(file_name, graph, true); DumpIRProto(graph, "vm_build_" + std::to_string(graph->graph_id())); } #endif @@ -910,14 +895,9 @@ void AscendSession::IrFusionPass(const NotNull graph, NotNullget_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); if (save_graphs) { - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } - std::string file_path = - save_graphs_path + "/" + "select_kernel_before" + "_graph_" + std::to_string(graph->graph_id()) + ".ir"; - DumpIR(file_path, graph.get()); + std::string file_name = "select_kernel_before_graph_" + std::to_string(graph->graph_id()) + ".ir"; + DumpIR(file_name, graph.get()); } for (auto &child_graph : graph->child_graph_order()) { @@ -982,14 +962,9 @@ void AscendSession::RecurseSelectKernelInfo(NotNull graph, auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); bool save_graphs = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG); - auto save_graphs_path = context_ptr->get_param(MS_CTX_SAVE_GRAPHS_PATH); if (save_graphs) { - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } - std::string file_path = - save_graphs_path + "/" + "select_kernel_after" + "_graph_" + std::to_string(graph->graph_id()) + ".ir"; - DumpIR(file_path, graph.get()); + std::string file_name = "select_kernel_after_graph_" + std::to_string(graph->graph_id()) + ".ir"; + DumpIR(file_name, graph.get()); } MS_LOG(INFO) << "Finish selecting kernel info in graph: " << graph->graph_id(); } diff --git a/mindspore/ccsrc/debug/anf_ir_dump.cc b/mindspore/ccsrc/debug/anf_ir_dump.cc index 21b6899f6e..02dd73735c 100644 --- a/mindspore/ccsrc/debug/anf_ir_dump.cc +++ b/mindspore/ccsrc/debug/anf_ir_dump.cc @@ -27,6 +27,7 @@ #include "ir/graph_utils.h" #include "backend/session/anf_runtime_algorithm.h" #include "frontend/parallel/ops_info/operator_info.h" +#include "pipeline/jit/base.h" namespace mindspore { const std::string ToShortString(const TypeId &typeId) { @@ -482,7 +483,7 @@ void DumpIR(const std::string &filename, const FuncGraphPtr &graph, bool dump_fu if (graph == nullptr) { return; } - auto real_filename = AddGlobalId(filename); + auto real_filename = pipeline::GetSaveGraphsPathName(AddGlobalId(filename)); if (real_filename.size() > PATH_MAX) { MS_LOG(ERROR) << "File path " << real_filename << " is too long."; return; diff --git a/mindspore/ccsrc/debug/anf_ir_utils.cc b/mindspore/ccsrc/debug/anf_ir_utils.cc index d4b0f82668..f39b933f5a 100644 --- a/mindspore/ccsrc/debug/anf_ir_utils.cc +++ b/mindspore/ccsrc/debug/anf_ir_utils.cc @@ -37,6 +37,7 @@ #include "utils/label.h" #include "utils/ms_context.h" #include "frontend/operator/ops.h" +#include "pipeline/jit/base.h" using mindspore::tensor::TensorPy; @@ -690,19 +691,21 @@ void ExportIR(const std::string &filename, const std::string &id, const FuncGrap return; } + auto real_filename = pipeline::GetSaveGraphsPathName(filename); AnfExporter exporter(id); - ChangeFileMode(filename, S_IRWXU); - exporter.ExportFuncGraph(filename, func_graph); + ChangeFileMode(real_filename, S_IRWXU); + exporter.ExportFuncGraph(real_filename, func_graph); // set file mode to read only by user - ChangeFileMode(filename, S_IRUSR); + ChangeFileMode(real_filename, S_IRUSR); } void ExportIR(const std::string &filename, const std::vector &graphs) { + auto real_filename = pipeline::GetSaveGraphsPathName(filename); AnfExporter exporter("", false); - ChangeFileMode(filename, S_IRWXU); - exporter.ExportFuncGraph(filename, graphs); + ChangeFileMode(real_filename, S_IRWXU); + exporter.ExportFuncGraph(real_filename, graphs); // set file mode to read only by user - ChangeFileMode(filename, S_IRUSR); + ChangeFileMode(real_filename, S_IRUSR); } #else void ExportIR(const std::string &, const std::string &, const FuncGraphPtr &) { diff --git a/mindspore/ccsrc/debug/draw.cc b/mindspore/ccsrc/debug/draw.cc index ff2fc7a441..ecae932e53 100644 --- a/mindspore/ccsrc/debug/draw.cc +++ b/mindspore/ccsrc/debug/draw.cc @@ -29,6 +29,7 @@ #include "frontend/operator/composite/composite.h" #include "pipeline/jit/parse/resolve.h" #include "ir/tensor.h" +#include "pipeline/jit/base.h" namespace mindspore { @@ -189,11 +190,11 @@ void Draw(const std::string &filename, const FuncGraphPtr &func_graph) { const std::string dot_suffix = ".dot"; std::string filename_with_suffix = (filename.rfind(dot_suffix) != (filename.size() - dot_suffix.size())) ? (filename + dot_suffix) : filename; - DrawByOpt(filename_with_suffix, func_graph, false); + DrawByOpt(pipeline::GetSaveGraphsPathName(filename_with_suffix), func_graph, false); } void DrawUserFuncGraph(const std::string &filename, const FuncGraphPtr &func_graph) { - DrawByOpt(filename, func_graph, true); + DrawByOpt(pipeline::GetSaveGraphsPathName(filename), func_graph, true); } #else void Draw(const std::string &, const FuncGraphPtr &) { diff --git a/mindspore/ccsrc/debug/dump_proto.cc b/mindspore/ccsrc/debug/dump_proto.cc index 0c8d912118..a6c4ca8767 100644 --- a/mindspore/ccsrc/debug/dump_proto.cc +++ b/mindspore/ccsrc/debug/dump_proto.cc @@ -27,6 +27,7 @@ #include "utils/ms_context.h" #include "utils/symbolic.h" #include "utils/utils.h" +#include "pipeline/jit/base.h" namespace mindspore { class ProtoExporter { @@ -525,16 +526,7 @@ void DumpIRProto(const FuncGraphPtr &func_graph, const std::string &suffix) { MS_LOG(ERROR) << "Func graph is nullptr"; return; } - auto ms_context = MsContext::GetInstance(); - if (ms_context == nullptr) { - MS_LOG(ERROR) << "ms_context is nullptr"; - return; - } - auto save_graphs_path = ms_context->get_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } - std::string file_path = save_graphs_path + "/" + "ms_output_" + suffix + ".pb"; + std::string file_path = pipeline::GetSaveGraphsPathName("ms_output_" + suffix + ".pb"); if (file_path.size() > PATH_MAX) { MS_LOG(ERROR) << "File path " << file_path << " is too long."; return; diff --git a/mindspore/ccsrc/pipeline/jit/base.h b/mindspore/ccsrc/pipeline/jit/base.h index 38cdcd19a6..33a410d661 100644 --- a/mindspore/ccsrc/pipeline/jit/base.h +++ b/mindspore/ccsrc/pipeline/jit/base.h @@ -43,7 +43,7 @@ inline std::string GetPhasePrefix(const std::string &phase) { return phase.substr(0, pos); } -inline std::string GetFilePathName(const std::string &file_name) { +inline std::string GetSaveGraphsPathName(const std::string &file_name) { std::ostringstream oss; auto ms_context = MsContext::GetInstance(); if (ms_context == nullptr) { diff --git a/mindspore/ccsrc/pipeline/jit/pipeline.cc b/mindspore/ccsrc/pipeline/jit/pipeline.cc index 8b0a002eba..d47b41d7a1 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline.cc @@ -85,15 +85,7 @@ std::unordered_mapget_param(MS_CTX_SAVE_GRAPHS_PATH); - if (save_graphs_path.empty()) { - save_graphs_path = "."; - } - oss << save_graphs_path << "/" << stage_idx << "_" << action_name; + oss << stage_idx << "_" << action_name; return oss.str(); } } // namespace @@ -690,9 +682,7 @@ void Pipeline::Run() { #endif if (MsContext::GetInstance()->get_param(MS_CTX_SAVE_GRAPHS_FLAG) && (user_graph != nullptr)) { - std::string user_graph_file = GetFilePathName("ModelDigraph.dot"); - MS_LOG(DEBUG) << "Save user graph to: " << user_graph_file; - draw::DrawUserFuncGraph(user_graph_file, user_graph); + draw::DrawUserFuncGraph("ModelDigraph.dot", user_graph); } MS_LOG(INFO) << "End"; } diff --git a/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc b/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc index bde634fd84..9ab6074c12 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc @@ -215,9 +215,9 @@ bool AddDFGraph(const std::map &info, const py::di } if (MsContext::GetInstance()->get_param(MS_CTX_SAVE_GRAPHS_FLAG)) { - convertor.DrawComputeGraph(GetFilePathName("ge_graph.dot")); // for debug - convertor.DrawInitGraph(GetFilePathName("init_graph.dot")); // for debug - convertor.DrawSaveCheckpointGraph(GetFilePathName("save_checkpoint_graph.dot")); // for debug + convertor.DrawComputeGraph(GetSaveGraphsPathName("ge_graph.dot")); // for debug + convertor.DrawInitGraph(GetSaveGraphsPathName("init_graph.dot")); // for debug + convertor.DrawSaveCheckpointGraph(GetSaveGraphsPathName("save_checkpoint_graph.dot")); // for debug } std::string init_graph = "init_subgraph." + net_id; std::string checkpoint_name = "save." + net_id; @@ -245,8 +245,8 @@ FuncGraphPtr BuildDFGraph(const std::map &info, co FuncGraphPtr anf_graph = info.at(phase)->func_graph; if (MsContext::GetInstance()->get_param(MS_CTX_SAVE_GRAPHS_FLAG)) { - draw::Draw(GetFilePathName("anf_graph.dot"), anf_graph); // for debug - DumpIR(GetFilePathName("anf_graph.ir"), anf_graph, true); + draw::Draw("anf_graph.dot", anf_graph); // for debug + DumpIR("anf_graph.ir", anf_graph, true); } if (!AddDFGraph(info, init_params, phase, broadcast_params)) { diff --git a/tests/ut/cpp/parallel/step_parallel_test.cc b/tests/ut/cpp/parallel/step_parallel_test.cc index 0c1ff2e84f..8a3de310ed 100644 --- a/tests/ut/cpp/parallel/step_parallel_test.cc +++ b/tests/ut/cpp/parallel/step_parallel_test.cc @@ -434,7 +434,7 @@ TEST_F(TestStepParallel, ForwardCommunication1) { PrimitivePtr prim = cnode->input(0)->cast()->value()->cast(); if (prim->name() == "MatMul") { ForwardCommunication(op_list, cnode); - draw::Draw("./forwardcommunication.dot", func_graph); + draw::Draw("forwardcommunication.dot", func_graph); } } AnfNodeSet after_nodes = manager->all_nodes(); diff --git a/tests/ut/cpp/pre_activate/ascend/ir_fusion/lamb_next_mv_with_decay_rule_test.cc b/tests/ut/cpp/pre_activate/ascend/ir_fusion/lamb_next_mv_with_decay_rule_test.cc index 776ce625b7..21643bee42 100644 --- a/tests/ut/cpp/pre_activate/ascend/ir_fusion/lamb_next_mv_with_decay_rule_test.cc +++ b/tests/ut/cpp/pre_activate/ascend/ir_fusion/lamb_next_mv_with_decay_rule_test.cc @@ -304,7 +304,6 @@ TEST_F(TestHWLambNextMVWithDecayRule, test_lamb_next_mv_with_decay_rule_cond2) { args_spec_list.push_back(x_abstract); } auto fg = GetKernelGraph(g, args_spec_list); - DumpIR("fg.ir", fg, true); auto optimizer = std::make_shared(); auto pm = std::make_shared(); @@ -313,8 +312,6 @@ TEST_F(TestHWLambNextMVWithDecayRule, test_lamb_next_mv_with_decay_rule_cond2) { FuncGraphPtr new_graph = optimizer->Optimize(fg); FuncGraphPtr g_after = get_py_fun_.CallAndParseRet("test_lamb_next_mv_with_decay_rule_cond2", "after"); - DumpIR("g_after.ir", g_after, true); - DumpIR("new_graph.ir", new_graph, true); EXPECT_TRUE(CheckEqualGraph(g_after, new_graph)); } @@ -348,7 +345,6 @@ TEST_F(TestHWLambNextMVWithDecayRule, test_lamb_next_mv_with_decay_rule_cond3) { args_spec_list.push_back(x_abstract); } auto fg = GetKernelGraph(g, args_spec_list); - DumpIR("fg.ir", fg, true); auto optimizer = std::make_shared(); auto pm = std::make_shared(); @@ -357,8 +353,6 @@ TEST_F(TestHWLambNextMVWithDecayRule, test_lamb_next_mv_with_decay_rule_cond3) { FuncGraphPtr new_graph = optimizer->Optimize(fg); FuncGraphPtr g_after = get_py_fun_.CallAndParseRet("test_lamb_next_mv_with_decay_rule_cond3", "after"); - DumpIR("g_after.ir", g_after, true); - DumpIR("new_graph.ir", new_graph, true); EXPECT_TRUE(CheckEqualGraph(g_after, new_graph)); }