[loco] Add bool return type for shape infer to() (#7131)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 3 Sep 2019 10:14:24 +0000 (19:14 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 3 Sep 2019 10:14:24 +0000 (19:14 +0900)
This will set boolean return type for ShapeInferenceSession to() method

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
compiler/loco/include/loco/Service/ShapeInference.h
compiler/loco/src/Service/ShapeInference.cpp

index 405eff7..f7bc5d4 100644 (file)
@@ -42,7 +42,7 @@ public:
   }
 
 public:
-  void to(Graph *g) const;
+  bool to(Graph *g) const;
 
 private:
   const ShapeInferenceRule *_rule;
index d8eb545..8b86d48 100644 (file)
@@ -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<ShapeAnnotation>(shape));
+        changed = true;
       }
     }
   }
+
+  return changed;
 }
 
 bool ShapeInference::known(const Node *node) { return node->annot<ShapeAnnotation>() != nullptr; }