diff --git a/mindspore/ccsrc/cxx_api/model/acl/model_converter.cc b/mindspore/ccsrc/cxx_api/model/acl/model_converter.cc index e01fe675abe..4c821b4c601 100644 --- a/mindspore/ccsrc/cxx_api/model/acl/model_converter.cc +++ b/mindspore/ccsrc/cxx_api/model/acl/model_converter.cc @@ -84,7 +84,7 @@ bool CreateSessionAndGraphRunner() { transform::DfGraphPtr ModelConverter::ConvertFuncGraphToAIR(const FuncGraphPtr &anf_graph) const { MS_EXCEPTION_IF_NULL(anf_graph); #ifndef BUILD_LITE - opt::GeOptimization(anf_graph); + opt::ReduceOptimization(anf_graph); #endif auto converter = transform::NewConverter(anf_graph); std::string net_id = "0"; diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.cc b/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.cc index eb53e0fc64f..f02fe7a17ac 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.cc +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.cc @@ -85,5 +85,34 @@ void GeOptimization(const FuncGraphPtr &func_graph) { MS_LOG(INFO) << "GE optimization end."; } + +void ReduceOptimization(const FuncGraphPtr &func_graph) { + MS_LOG(INFO) << "Reduce optimization start, graph: " << func_graph->ToString() << "."; + +#ifdef ENABLE_DUMP_IR + auto context = MsContext::GetInstance(); + MS_EXCEPTION_IF_NULL(context); + if (context->CanDump(advanced)) { + std::string file_name = "hwopt_d_before_reduce_optimization_graph_" + func_graph->ToString() + ".ir"; + DumpIR(file_name, func_graph); + } +#endif + + auto optimizer = std::make_shared(); + auto pm = std::make_shared("reduce_optimization_pm"); + pm->AddPass(std::make_shared()); + optimizer->AddPassManager(pm); + + (void)optimizer->Optimize(func_graph); + +#ifdef ENABLE_DUMP_IR + if (context->CanDump(advanced)) { + std::string file_name = "hwopt_d_after_reduce_optimization_graph_" + func_graph->ToString() + ".ir"; + DumpIR(file_name, func_graph); + } +#endif + + MS_LOG(INFO) << "Reduce optimization end."; +} } // namespace opt } // namespace mindspore diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.h b/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.h index 2c36534731d..fc86983395b 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.h +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/ge_optimization.h @@ -20,6 +20,7 @@ namespace mindspore { namespace opt { void GeOptimization(const FuncGraphPtr &func_graph); +void ReduceOptimization(const FuncGraphPtr &func_graph); } // namespace opt } // namespace mindspore