forked from mindspore-Ecosystem/mindspore
!13329 [MS][RDR] optimize saving FuncGraph to using same params with save_graphs
From: @louie5 Reviewed-by: @zh_qh Signed-off-by:
This commit is contained in:
commit
0da0f72c6c
|
@ -66,6 +66,7 @@
|
|||
#ifdef ENABLE_DUMP_IR
|
||||
#include "debug/rdr/running_data_recorder.h"
|
||||
#include "debug/rdr/recorder_manager.h"
|
||||
#include "debug/rdr/graph_recorder.h"
|
||||
#include "runtime/device/ascend/ascend_bucket.h"
|
||||
#endif
|
||||
#if ENABLE_CPU && ENABLE_D
|
||||
|
@ -1011,7 +1012,8 @@ void AscendSession::DumpAllGraphs(const std::vector<KernelGraphPtr> &all_graphs)
|
|||
for (auto &graph : all_graphs) {
|
||||
MS_EXCEPTION_IF_NULL(graph);
|
||||
std::string name = "graph_build." + std::to_string(graph->graph_id());
|
||||
mindspore::RDR::RecordAnfGraph(SUBMODULE_ID, name, graph, true, ".ir;.pb");
|
||||
DumpGraphParams dump_params = {true, static_cast<int>(kWholeStack)};
|
||||
mindspore::RDR::RecordAnfGraph(SUBMODULE_ID, name, graph, dump_params, ".ir;.pb");
|
||||
if (save_graphs) {
|
||||
std::string file_name = "graph_build_" + std::to_string(graph->graph_id()) + ".ir";
|
||||
DumpIR(file_name, graph, true, kWholeStack);
|
||||
|
|
|
@ -374,7 +374,8 @@ GraphId GPUSession::CompileGraphImpl(KernelGraphPtr graph) {
|
|||
BuildKernel(graph);
|
||||
#ifdef ENABLE_DUMP_IR
|
||||
std::string name = "graph_build";
|
||||
mindspore::RDR::RecordAnfGraph(SubModuleId::SM_SESSION, name, graph, false, ".ir,.pb");
|
||||
DumpGraphParams dump_params = {true, static_cast<int>(kWholeStack)};
|
||||
mindspore::RDR::RecordAnfGraph(SubModuleId::SM_SESSION, name, graph, dump_params, ".ir,.pb");
|
||||
#endif
|
||||
// Get summary nodes.
|
||||
SetSummaryNodes(graph.get());
|
||||
|
|
|
@ -74,10 +74,13 @@ void GraphRecorder::Export() {
|
|||
if (graph_type_.find(".ir") != std::string::npos) {
|
||||
save_flag = true;
|
||||
std::string realpath_ir = realpath + ".ir";
|
||||
if (full_name_) {
|
||||
DumpIRForRDR(realpath_ir, func_graph_, true, kTopStack);
|
||||
if (dump_graph_info_.dump_mode <= static_cast<int>(kWholeStack) &&
|
||||
dump_graph_info_.dump_mode >= static_cast<int>(kOff)) {
|
||||
LocDumpMode dump_mode = LocDumpMode(dump_graph_info_.dump_mode);
|
||||
DumpIRForRDR(realpath_ir, func_graph_, dump_graph_info_.dump_full_name, dump_mode);
|
||||
} else {
|
||||
DumpIRForRDR(realpath_ir, func_graph_, false, kWholeStack);
|
||||
MS_LOG(WARNING) << "Unknown save graph LocDumoMode: " << dump_graph_info_.dump_mode
|
||||
<< ", it must be in the range [0,2].";
|
||||
}
|
||||
}
|
||||
if (graph_type_.find(".pb") != std::string::npos) {
|
||||
|
|
|
@ -19,9 +19,13 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "debug/anf_ir_utils.h"
|
||||
#include "debug/rdr/base_recorder.h"
|
||||
|
||||
namespace mindspore {
|
||||
struct DumpGraphParams {
|
||||
bool dump_full_name;
|
||||
int dump_mode;
|
||||
};
|
||||
class FuncGraph;
|
||||
using FuncGraphPtr = std::shared_ptr<FuncGraph>;
|
||||
class GraphRecorder : public BaseRecorder {
|
||||
|
@ -33,14 +37,14 @@ class GraphRecorder : public BaseRecorder {
|
|||
~GraphRecorder() {}
|
||||
void SetGraphType(const std::string &file_type) { graph_type_ = file_type; }
|
||||
void SetFuncGraph(const FuncGraphPtr &func_graph) { func_graph_ = func_graph; }
|
||||
void SetDumpFlag(bool full_name) { full_name_ = full_name; }
|
||||
void SetDumpFlag(DumpGraphParams info) { dump_graph_info_ = info; }
|
||||
|
||||
virtual void Export();
|
||||
|
||||
private:
|
||||
FuncGraphPtr func_graph_;
|
||||
std::string graph_type_;
|
||||
bool full_name_{false};
|
||||
DumpGraphParams dump_graph_info_;
|
||||
};
|
||||
using GraphRecorderPtr = std::shared_ptr<GraphRecorder>;
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#include "debug/rdr/running_data_recorder.h"
|
||||
#include <utility>
|
||||
#include "debug/rdr/graph_recorder.h"
|
||||
|
||||
#include "debug/rdr/graph_exec_order_recorder.h"
|
||||
#include "debug/rdr/recorder_manager.h"
|
||||
#include "debug/rdr/string_recorder.h"
|
||||
|
@ -78,14 +78,14 @@ bool RecordTaskDebugInfo(SubModuleId module, const std::string &name,
|
|||
}
|
||||
#endif // ENABLE_D
|
||||
|
||||
bool RecordAnfGraph(const SubModuleId module, const std::string &name, const FuncGraphPtr &graph, bool full_name,
|
||||
const std::string &file_type) {
|
||||
bool RecordAnfGraph(const SubModuleId module, const std::string &name, const FuncGraphPtr &graph,
|
||||
const DumpGraphParams &info, const std::string &file_type) {
|
||||
if (!mindspore::RecorderManager::Instance().RdrEnable()) {
|
||||
return false;
|
||||
}
|
||||
std::string submodule_name = std::string(GetSubModuleName(module));
|
||||
GraphRecorderPtr graph_recorder = std::make_shared<GraphRecorder>(submodule_name, name, graph, file_type);
|
||||
graph_recorder->SetDumpFlag(full_name);
|
||||
graph_recorder->SetDumpFlag(info);
|
||||
bool ans = mindspore::RecorderManager::Instance().RecordObject(std::move(graph_recorder));
|
||||
return ans;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <memory>
|
||||
|
||||
#include "mindspore/core/utils/log_adapter.h"
|
||||
#include "debug/rdr/graph_recorder.h"
|
||||
|
||||
namespace mindspore {
|
||||
class FuncGraph;
|
||||
class CNode;
|
||||
|
@ -44,8 +46,8 @@ using TaskDebugInfoPtr = std::shared_ptr<device::ascend::tasksink::TaskDebugInfo
|
|||
#endif // ENABLE_D
|
||||
|
||||
namespace RDR {
|
||||
bool RecordAnfGraph(const SubModuleId module, const std::string &name, const FuncGraphPtr &graph, bool full_name,
|
||||
const std::string &file_type = ".ir;.pb;.dat");
|
||||
bool RecordAnfGraph(const SubModuleId module, const std::string &name, const FuncGraphPtr &graph,
|
||||
const DumpGraphParams &info, const std::string &file_type = ".ir;.pb;.dat");
|
||||
bool RecordGraphExecOrder(const SubModuleId module, const std::string &name,
|
||||
const std::vector<CNodePtr> &final_exec_order);
|
||||
bool RecordString(SubModuleId module, const std::string &name, const std::string &data);
|
||||
|
|
|
@ -741,7 +741,11 @@ void Pipeline::Run() {
|
|||
if (graph != nullptr) {
|
||||
auto graph_clone = BasicClone(graph);
|
||||
if (graph_clone != nullptr) {
|
||||
mindspore::RDR::RecordAnfGraph(SUBMODULE_ID, name, graph_clone, false, ".ir");
|
||||
DumpGraphParams dump_params = {false, static_cast<int>(kTopStack)};
|
||||
if (i == actions_.size()) {
|
||||
dump_params.dump_mode = static_cast<int>(kWholeStack);
|
||||
}
|
||||
mindspore::RDR::RecordAnfGraph(SUBMODULE_ID, name, graph_clone, dump_params, ".ir");
|
||||
} else {
|
||||
MS_LOG(WARNING) << "Clone FuncGraph failed in pipeline, no FuncGraph recording in RDR.";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue