[exo-tflite] Rewriting a test using exo::test::TestGraph (#7924)
author윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 <hyunsik.yoon@samsung.com>
Mon, 7 Oct 2019 05:45:23 +0000 (14:45 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 7 Oct 2019 05:45:23 +0000 (14:45 +0900)
Test was re-written using exo::test::TestGraph and was simplified.

Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
compiler/exo-tflite/src/Dialect/Service/TFLShapeInferenceRule.test.cpp

index 0b174d0..35c8f0b 100644 (file)
 TEST(TFLShapeInferenceRuleTest, minimal_with_TFLRelu)
 {
   // Create a simple network
-  auto g = loco::make_graph();
-
-  auto pull_node = g->nodes()->create<loco::Pull>();
-  {
-    pull_node->rank(2);
-    pull_node->dim(0) = 3;
-    pull_node->dim(1) = 4;
-  }
-
-  auto tfl_node = g->nodes()->create<locoex::TFLRelu>();
-  tfl_node->features(pull_node);
-
-  auto push_node = g->nodes()->create<loco::Push>();
-  push_node->from(tfl_node);
+  exo::test::TestGraph graph;
+  auto tfl_node = graph.append<locoex::TFLRelu>(graph.pull);
+  graph.complete(tfl_node);
 
-  auto input = g->inputs()->create();
+  // set shape
   {
-    input->name("input");
-    loco::link(input, pull_node);
-  }
-  auto output = g->outputs()->create();
-  {
-    output->name("output");
-    loco::link(output, push_node);
+    graph.pull->rank(2);
+    graph.pull->dim(0) = 3;
+    graph.pull->dim(1) = 4;
   }
 
   // pre-check
@@ -70,7 +55,7 @@ TEST(TFLShapeInferenceRuleTest, minimal_with_TFLRelu)
   rules.bind(loco::CanonicalDialect::get(), &canonical_rule)
       .bind(locoex::TFLDialect::get(), &tfl_rule);
 
-  loco::apply(&rules).to(g.get());
+  loco::apply(&rules).to(graph.g.get());
 
   // Verify
   {