diff --git a/mindspore/ccsrc/frontend/optimizer/opt.cc b/mindspore/ccsrc/frontend/optimizer/opt.cc index 0a43b53873..db25c9810f 100644 --- a/mindspore/ccsrc/frontend/optimizer/opt.cc +++ b/mindspore/ccsrc/frontend/optimizer/opt.cc @@ -184,6 +184,9 @@ bool SubstitutionList::ApplyIRToSubstitutions(const OptimizerPtr &optimizer, con for (auto &substitution : list_) { auto res = DoTransform(optimizer, node, substitution); if (res != nullptr) { + if (is_once_) { + return true; + } change = true; changes = true; node = res; @@ -229,6 +232,9 @@ bool SubstitutionList::ApplySubstitutionToIR(const OptimizerPtr &optimizer, cons changes = true; node = res; } + if (change && is_once_) { + return true; + } UpdateTransformingList(optimizer, node, &todo, change, seen); }