!47757 Adjust the pass for Ascend 310

Merge pull request !47757 from hanhuifeng/310_pass_modify
This commit is contained in:
i-robot 2023-01-11 08:46:21 +00:00 committed by Gitee
commit 3d56f8459d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 31 additions and 1 deletions

View File

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

View File

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

View File

@ -20,6 +20,7 @@
namespace mindspore {
namespace opt {
void GeOptimization(const FuncGraphPtr &func_graph);
void ReduceOptimization(const FuncGraphPtr &func_graph);
} // namespace opt
} // namespace mindspore