unify save_graphs_path

This commit is contained in:
huanghui 2020-10-14 19:18:20 +08:00
parent 60da54651b
commit b7519b7418
14 changed files with 74 additions and 175 deletions

View File

@ -257,14 +257,9 @@ void AscendBackendIRFusionOptimization(const std::shared_ptr<session::KernelGrap
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<GraphOptimizer>();
@ -300,9 +295,8 @@ void AscendBackendIRFusionOptimization(const std::shared_ptr<session::KernelGrap
(void)optimizer->Optimize(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_ptr<session::Kerne
return;
}
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<GraphOptimizer>();
auto ir_fusion_pm = std::make_shared<PassManager>("ir_fusion_pm");
@ -336,8 +325,7 @@ void RunOpAscendBackendIRFusionOptimization(const std::shared_ptr<session::Kerne
(void)optimizer->Optimize(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<session::KernelGraph> &kern
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<session::KernelGraph> &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<session::KernelGraph> &ke
return;
}
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<void>(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<session::KernelGraph> &kern
return;
}
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<void>(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<session::KernelGraph> &ke
return;
}
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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_ptr<session::KernelGrap
return;
}
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<FusionIdAllocator>();
MS_EXCEPTION_IF_NULL(fusion_id_allocator);
@ -525,9 +484,8 @@ void AscendBackendUBFusionOptimization(const std::shared_ptr<session::KernelGrap
(void)optimizer->Optimize(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

View File

@ -34,14 +34,9 @@ void BackendCommonOptimization(const std::shared_ptr<session::KernelGraph> &kern
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<GraphOptimizer>();
auto common_pm = std::make_shared<PassManager>("common_pm");
@ -55,9 +50,8 @@ void BackendCommonOptimization(const std::shared_ptr<session::KernelGraph> &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

View File

@ -41,10 +41,6 @@ bool PassManager::Run(const FuncGraphPtr &func_graph, const std::vector<PassPtr>
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<PassPtr>
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++;
}

View File

@ -370,13 +370,9 @@ void AscendControlParser::ExecutorValidate(NotNull<KernelGraphPtr> root_graph) {
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
auto save_graphs_path = context_ptr->get_param<std::string>(MS_CTX_SAVE_GRAPHS_PATH);
if (save_graphs_path.empty()) {
save_graphs_path = ".";
}
if (context_ptr->get_param<bool>(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());
}
}

View File

@ -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<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<KernelGraph> &kernel_grap
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<KernelGraphPtr> &all_graphs)
if (!save_graphs) {
return;
}
auto save_graphs_path = context_ptr->get_param<std::string>(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<KernelGraphPtr> graph, NotNull<st
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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<KernelGraphPtr> graph,
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG);
auto save_graphs_path = context_ptr->get_param<std::string>(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();
}

View File

@ -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;

View File

@ -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<TaggedGraph> &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 &) {

View File

@ -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 &) {

View File

@ -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<std::string>(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;

View File

@ -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) {

View File

@ -85,15 +85,7 @@ std::unordered_map<abstract::AbstractBasePtrList, int, abstract::AbstractBasePtr
namespace {
std::string GetBaseNameForIR(int stage_idx, const std::string &action_name) {
std::ostringstream oss;
auto ms_context = MsContext::GetInstance();
if (ms_context == nullptr) {
MS_LOG(EXCEPTION) << "ms_context is nullptr";
}
auto save_graphs_path = ms_context->get_param<std::string>(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<bool>(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";
}

View File

@ -215,9 +215,9 @@ bool AddDFGraph(const std::map<std::string, ExecutorInfoPtr> &info, const py::di
}
if (MsContext::GetInstance()->get_param<bool>(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<std::string, ExecutorInfoPtr> &info, co
FuncGraphPtr anf_graph = info.at(phase)->func_graph;
if (MsContext::GetInstance()->get_param<bool>(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)) {

View File

@ -434,7 +434,7 @@ TEST_F(TestStepParallel, ForwardCommunication1) {
PrimitivePtr prim = cnode->input(0)->cast<ValueNodePtr>()->value()->cast<PrimitivePtr>();
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();

View File

@ -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<opt::GraphOptimizer>();
auto pm = std::make_shared<opt::PassManager>();
@ -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<opt::GraphOptimizer>();
auto pm = std::make_shared<opt::PassManager>();
@ -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));
}