Browse Source

fix-backend-dump-vm-build-pb

tags/v0.6.0-beta
huanghui 5 years ago
parent
commit
af4a7e1317
3 changed files with 11 additions and 21 deletions
  1. +2
    -3
      mindspore/ccsrc/pre_activate/ascend/ir_fusion/square_sum_fusion.cc
  2. +8
    -17
      mindspore/ccsrc/session/ascend_session.cc
  3. +1
    -1
      mindspore/ccsrc/session/ascend_session.h

+ 2
- 3
mindspore/ccsrc/pre_activate/ascend/ir_fusion/square_sum_fusion.cc View File

@@ -21,7 +21,6 @@
#include <string>

#include "session/anf_runtime_algorithm.h"
#include "common/utils.h"
#include "utils/utils.h"
#include "operator/ops.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());
AnfAlgo::CopyNodeAttr(kAttrAxis, 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);
return square_sumv1;
}
@@ -74,7 +73,7 @@ CNodePtr GenerateSquareSumV2(const FuncGraphPtr &graph, const CNodePtr &square,
square_sumv2->set_scope(sum->scope());
AnfAlgo::CopyNodeAttr(kAttrAxis, 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);
return square_sumv2;
}


+ 8
- 17
mindspore/ccsrc/session/ascend_session.cc View File

@@ -337,6 +337,7 @@ GraphId AscendSession::CompileGraph(NotNull<FuncGraphPtr> func_graph) {
GenerateTaskInfo(root_graph);
// load task into device
LoadTask(root_graph);
DumpAllGraphs(all_graphs);
// return the root_graph id to backend
auto graph_id = root_graph->graph_id();
return graph_id;
@@ -418,7 +419,7 @@ void AscendSession::BuildGraph(GraphId graph_id) {
}
// sync the inital const tensor to device
SyncInitialTenosrToDevice();
ExportChildGraphs(graph_id);
DumpAllGraphs({graph});
MS_LOG(INFO) << "End";
}

@@ -762,7 +763,7 @@ void AscendSession::Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const
MS_LOG(INFO) << "Finish!";
}

void AscendSession::ExportChildGraphs(const GraphId graph_id) {
void AscendSession::DumpAllGraphs(const std::vector<KernelGraphPtr> &all_graphs) {
#ifdef ENABLE_DUMP_IR
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
@@ -774,21 +775,11 @@ void AscendSession::ExportChildGraphs(const GraphId graph_id) {
if (save_graphs_path.empty()) {
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
}


+ 1
- 1
mindspore/ccsrc/session/ascend_session.h View File

@@ -85,7 +85,7 @@ class AscendSession : public SessionBasic {
void LoadTask(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 ExportChildGraphs(const GraphId graph_id);
void DumpAllGraphs(const std::vector<KernelGraphPtr> &all_graphs);
void LoadTensor(const std::shared_ptr<KernelGraph> &kernel_graph) const;
// below functions are used for run op
void RunOpHardwareOptimize(const std::shared_ptr<session::KernelGraph> &kernel_graph) const;


Loading…
Cancel
Save