From: 박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Mon, 19 Aug 2019 05:05:22 +0000 (+0900) Subject: [moco-tf] Introduce Restart PhaseRunner (#6667) X-Git-Tag: accepted/tizen/unified/20190903.052428~340 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4472cff2cd027e1ecd2689a97c01854e20290a06;p=platform%2Fcore%2Fml%2Fnnfw.git [moco-tf] Introduce Restart PhaseRunner (#6667) This will introduce Restart type PhaseRunner that restarts from the beginning when there is any change in the transformation list Signed-off-by: SaeHie Park --- diff --git a/compiler/moco-tf/src/Phase.cpp b/compiler/moco-tf/src/Phase.cpp index 2f4d0ad..6764691 100644 --- a/compiler/moco-tf/src/Phase.cpp +++ b/compiler/moco-tf/src/Phase.cpp @@ -66,5 +66,42 @@ void PhaseRunner::run(const Phase &phase) const INFO(l) << "PhaseRunner - done"; } +void PhaseRunner::run(const Phase &phase) const +{ + LOGGER(l); + + INFO(l) << "=============================================================="; + INFO(l) << "PhaseRunner"; + + INFO(l) << "Initial graph"; + INFO(l) << fmt(_graph); + + for (bool changed = true; changed;) + { + changed = false; + + for (auto &tr : phase) + { + INFO(l) << "--------------------------------------------------------------"; + INFO(l) << "Before " << transform_name(tr.get()); + + if (tr->run(_graph)) + { + changed = true; + } + + INFO(l) << "After " << transform_name(tr.get()) << " (changed: " << to_char(changed) << ")"; + INFO(l) << fmt(_graph); + + if (changed) + { + break; + } + } + } + + INFO(l) << "PhaseRunner - done"; +} + } // namespace tf } // namespace moco diff --git a/compiler/moco-tf/src/Phase.h b/compiler/moco-tf/src/Phase.h index 509eb68..cb1854b 100644 --- a/compiler/moco-tf/src/Phase.h +++ b/compiler/moco-tf/src/Phase.h @@ -36,6 +36,8 @@ enum class PhaseStrategy { // Run all the transforms until there is no transform that makes a change Saturate, + // Same as Saturate but will restart from the first when there is a change + Restart, }; template class PhaseRunner; @@ -55,6 +57,21 @@ private: loco::Graph *_graph; }; +template <> class PhaseRunner +{ +public: + PhaseRunner(loco::Graph *graph) : _graph{graph} + { + // DO NOTHING + } + +public: + void run(const Phase &) const; + +private: + loco::Graph *_graph; +}; + } // namespace tf } // namespace moco