From d962ff7cbcd8e01d9ae1a3061545ef2b33a518b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 3 Sep 2019 19:14:24 +0900 Subject: [PATCH] [loco] Add bool return type for shape infer to() (#7131) This will set boolean return type for ShapeInferenceSession to() method Signed-off-by: SaeHie Park --- compiler/loco/include/loco/Service/ShapeInference.h | 2 +- compiler/loco/src/Service/ShapeInference.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/loco/include/loco/Service/ShapeInference.h b/compiler/loco/include/loco/Service/ShapeInference.h index 405eff7..f7bc5d4 100644 --- a/compiler/loco/include/loco/Service/ShapeInference.h +++ b/compiler/loco/include/loco/Service/ShapeInference.h @@ -42,7 +42,7 @@ public: } public: - void to(Graph *g) const; + bool to(Graph *g) const; private: const ShapeInferenceRule *_rule; diff --git a/compiler/loco/src/Service/ShapeInference.cpp b/compiler/loco/src/Service/ShapeInference.cpp index d8eb545..8b86d48 100644 --- a/compiler/loco/src/Service/ShapeInference.cpp +++ b/compiler/loco/src/Service/ShapeInference.cpp @@ -47,8 +47,10 @@ private: namespace loco { -void ShapeInferenceSession::to(Graph *g) const +bool ShapeInferenceSession::to(Graph *g) const { + bool changed = false; + for (auto node : loco::postorder_traversal(loco::output_nodes(g))) { if (_rule->recognize(node->dialect())) @@ -58,9 +60,12 @@ void ShapeInferenceSession::to(Graph *g) const if (_rule->infer(node, shape)) { node->annot(stdex::make_unique(shape)); + changed = true; } } } + + return changed; } bool ShapeInference::known(const Node *node) { return node->annot() != nullptr; } -- 2.7.4