[exo-tflite] Renaming DefaultLayout to FeatureLayout (#8046)
author윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 <hyunsik.yoon@samsung.com>
Fri, 11 Oct 2019 06:53:55 +0000 (15:53 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 11 Oct 2019 06:53:55 +0000 (15:53 +0900)
* [exo-tflite] Renaming DefaultLayout to FeatureLayout

DefaultLayout is renamed to to FeatureLayout.

Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
* fix comment

compiler/exo-tflite/src/Conversion/AvgPool2DConverter.cpp
compiler/exo-tflite/src/Conversion/Conv2DConverter.cpp
compiler/exo-tflite/src/Conversion/EltwiseBinaryConverter.h
compiler/exo-tflite/src/Conversion/FeatureBiasAddConverter.cpp
compiler/exo-tflite/src/Conversion/MaxPool2DConverter.cpp
compiler/exo-tflite/src/Conversion/ReluConverter.cpp
compiler/exo-tflite/src/Conversion/ReluConverter.test.cpp
compiler/exo-tflite/src/GraphBlock.cpp
compiler/exo-tflite/src/GraphBlock.h
compiler/exo-tflite/src/TFLExporterImpl.test.cpp
compiler/exo-tflite/src/TestGraph.h

index 0bb8a54..b7449f4 100644 (file)
@@ -48,7 +48,7 @@ bool AvgPool2DConverter::convert(loco::AvgPool2D *origin)
 {
   auto *graph = origin->graph();
 
-  auto dec = make_feature_decode<DefaultLayout::NHWC>(origin->ifm());
+  auto dec = make_feature_decode<FeatureLayout::NHWC>(origin->ifm());
   auto tfl_average = graph->nodes()->create<locoex::TFLAveragePool2D>();
   {
     tfl_average->value(dec);
@@ -68,7 +68,7 @@ bool AvgPool2DConverter::convert(loco::AvgPool2D *origin)
 
     tfl_average->fusedActivationFunction(locoex::FusedActFunc::NONE);
   }
-  auto enc = make_feature_encode<DefaultLayout::NHWC>(tfl_average);
+  auto enc = make_feature_encode<FeatureLayout::NHWC>(tfl_average);
 
   // replace canonical node
   loco::replace(origin).with(enc);
index 579f553..6682f32 100644 (file)
@@ -60,7 +60,7 @@ bool Conv2DConverter::convert(loco::Conv2D *origin)
   // let's create a new graph connection with tfl_conv2d
   {
     // input
-    auto feature_dec = make_feature_decode<DefaultLayout::NHWC>(origin->ifm());
+    auto feature_dec = make_feature_decode<FeatureLayout::NHWC>(origin->ifm());
     tfl_conv2d->input(feature_dec);
 
     // filter
@@ -85,7 +85,7 @@ bool Conv2DConverter::convert(loco::Conv2D *origin)
     tfl_conv2d->bias(zero_const);
 
     // output
-    auto feature_enc = make_feature_encode<DefaultLayout::NHWC>(tfl_conv2d);
+    auto feature_enc = make_feature_encode<FeatureLayout::NHWC>(tfl_conv2d);
 
     // replace canonical node
     loco::replace(origin).with(feature_enc);
index e83dfc6..aea564d 100644 (file)
@@ -63,14 +63,14 @@ template <class ELTWISEBIN, class TFLBIN> bool EltwiseBinaryConvert(ELTWISEBIN *
                       loco::EltwiseBin (dead node)
     */
     auto graph = origin->graph();
-    auto dec_l = make_feature_decode<DefaultLayout::NHWC>(origin->lhs());
-    auto dec_r = make_feature_decode<DefaultLayout::NHWC>(origin->rhs());
+    auto dec_l = make_feature_decode<FeatureLayout::NHWC>(origin->lhs());
+    auto dec_r = make_feature_decode<FeatureLayout::NHWC>(origin->rhs());
     auto tfl_new = graph->nodes()->template create<TFLBIN>();
     {
       tfl_new->x(dec_l);
       tfl_new->y(dec_r);
     }
-    auto enc = make_feature_encode<DefaultLayout::NHWC>(tfl_new);
+    auto enc = make_feature_encode<FeatureLayout::NHWC>(tfl_new);
 
     loco::replace(origin).with(enc);
     origin->lhs(nullptr);
index 1163f0e..07d93ed 100644 (file)
@@ -55,7 +55,7 @@ bool FeatureBiasAddConverter::convert(loco::FeatureBiasAdd *origin)
   // handling input x
   assert(loco::shape_get(origin->value()).domain() == loco::Domain::Feature);
 
-  auto fea_dec = make_feature_decode<DefaultLayout::NHWC>(origin->value());
+  auto fea_dec = make_feature_decode<FeatureLayout::NHWC>(origin->value());
   tfl_add->x(fea_dec);
 
   // handling input y
@@ -67,7 +67,7 @@ bool FeatureBiasAddConverter::convert(loco::FeatureBiasAdd *origin)
   tfl_add->y(bias_dec);
 
   // handling output
-  auto fea_enc = make_feature_encode<DefaultLayout::NHWC>(tfl_add);
+  auto fea_enc = make_feature_encode<FeatureLayout::NHWC>(tfl_add);
 
   loco::replace(origin).with(fea_enc);
   origin->value(nullptr);
index 7b7fdfc..158ca1f 100644 (file)
@@ -36,7 +36,7 @@ bool MaxPool2DConverter::convert(loco::MaxPool2D *origin)
 {
   auto *graph = origin->graph();
 
-  auto dec = make_feature_decode<DefaultLayout::NHWC>(origin->ifm());
+  auto dec = make_feature_decode<FeatureLayout::NHWC>(origin->ifm());
   auto tfl_max = graph->nodes()->create<locoex::TFLMaxPool2D>();
   {
     tfl_max->value(dec);
@@ -57,7 +57,7 @@ bool MaxPool2DConverter::convert(loco::MaxPool2D *origin)
     tfl_max->fusedActivationFunction(locoex::FusedActFunc::NONE);
   }
 
-  auto enc = make_feature_encode<DefaultLayout::NHWC>(tfl_max);
+  auto enc = make_feature_encode<FeatureLayout::NHWC>(tfl_max);
 
   loco::replace(origin).with(enc);
   origin->ifm(nullptr);
index a0ac1f7..e226ec4 100644 (file)
@@ -57,12 +57,12 @@ bool ReluConverter::convert(loco::ReLU *origin)
                       loco::ReLU (dead node)
     */
     auto graph = origin->graph();
-    auto dec = make_feature_decode<DefaultLayout::NHWC>(origin->input());
+    auto dec = make_feature_decode<FeatureLayout::NHWC>(origin->input());
     auto tfl_relu = graph->nodes()->create<locoex::TFLRelu>();
     {
       tfl_relu->features(dec);
     }
-    auto enc = make_feature_encode<DefaultLayout::NHWC>(tfl_relu);
+    auto enc = make_feature_encode<FeatureLayout::NHWC>(tfl_relu);
 
     loco::replace(origin).with(enc);
     origin->input(nullptr);
index f2523bd..f53d656 100644 (file)
@@ -60,9 +60,9 @@ TEST(ReluConverterTest, relu_feature_inout)
   // g = Pull - FeatureEncode - Relu - FeatureDecode - Push
   exo::test::TestGraph graph;
   {
-    auto enc = exo::make_feature_encode<exo::DefaultLayout::NHWC>(graph.pull);
+    auto enc = exo::make_feature_encode<exo::FeatureLayout::NHWC>(graph.pull);
     auto relu = graph.append<loco::ReLU>(enc);
-    auto dec = exo::make_feature_decode<exo::DefaultLayout::NHWC>(relu);
+    auto dec = exo::make_feature_decode<exo::FeatureLayout::NHWC>(relu);
     graph.complete(dec);
   }
 
index df511e0..ede07e4 100644 (file)
@@ -24,9 +24,9 @@
 namespace
 {
 
-template <exo::DefaultLayout T> loco::Permutation<loco::Domain::Feature> perm();
+template <exo::FeatureLayout T> loco::Permutation<loco::Domain::Feature> perm();
 
-template <> loco::Permutation<loco::Domain::Feature> perm<exo::DefaultLayout::NHWC>()
+template <> loco::Permutation<loco::Domain::Feature> perm<exo::FeatureLayout::NHWC>()
 {
   // Make NHWC permutation for encoder and decoder
   loco::Permutation<loco::Domain::Feature> NHWC;
@@ -72,7 +72,7 @@ template <> loco::Permutation<loco::Domain::Filter> perm<exo::FilterLayout::OHWI
 namespace exo
 {
 
-template <DefaultLayout T> loco::FeatureEncode *make_feature_encode(loco::Node *input_for_encode)
+template <FeatureLayout T> loco::FeatureEncode *make_feature_encode(loco::Node *input_for_encode)
 {
   EXO_ASSERT(input_for_encode != nullptr, "input should not be nullptr");
   loco::Graph *g = input_for_encode->graph();
@@ -88,7 +88,7 @@ template <DefaultLayout T> loco::FeatureEncode *make_feature_encode(loco::Node *
   return enc;
 }
 
-template <DefaultLayout T> loco::FeatureDecode *make_feature_decode(loco::Node *input_for_decode)
+template <FeatureLayout T> loco::FeatureDecode *make_feature_decode(loco::Node *input_for_decode)
 {
   EXO_ASSERT(input_for_decode != nullptr, "input should not be nullptr");
   loco::Graph *g = input_for_decode->graph();
@@ -138,10 +138,10 @@ template <FilterLayout T> loco::FilterDecode *make_filter_decode(loco::Node *inp
 
 // template instantiation
 template loco::FeatureEncode *
-make_feature_encode<DefaultLayout::NHWC>(loco::Node *input_for_encode);
+make_feature_encode<FeatureLayout::NHWC>(loco::Node *input_for_encode);
 
 template loco::FeatureDecode *
-make_feature_decode<DefaultLayout::NHWC>(loco::Node *input_for_encode);
+make_feature_decode<FeatureLayout::NHWC>(loco::Node *input_for_encode);
 
 template loco::FilterEncode *make_filter_encode<FilterLayout::HWIO>(loco::Node *input_for_encode);
 template loco::FilterDecode *make_filter_decode<FilterLayout::OHWI>(loco::Node *input_for_decode);
index a40ba40..a1d16fe 100644 (file)
 namespace exo
 {
 
-/// @brief default layout of TFLITE file
-enum class DefaultLayout
+/// @brief feature layout of TFLITE file
+enum class FeatureLayout
 {
   NHWC,
 };
 
-/// @brief Creates a loco::FeatureEncode of default layout (NHWC for tflite) and add it to graph.
-template <DefaultLayout T> loco::FeatureEncode *make_feature_encode(loco::Node *input_for_encode);
+/// @brief Creates a loco::FeatureEncode with T layout (NHWC for tflite) and add it to graph.
+template <FeatureLayout T> loco::FeatureEncode *make_feature_encode(loco::Node *input_for_encode);
 
-/// @brief Create a loco::FeatureDecode of default layout (NHWC for tflite) and add it to graph.
-template <DefaultLayout T> loco::FeatureDecode *make_feature_decode(loco::Node *input_for_decode);
+/// @brief Creates a loco::FeatureDecode with T layout (NHWC for tflite) and add it to graph.
+template <FeatureLayout T> loco::FeatureDecode *make_feature_decode(loco::Node *input_for_decode);
 
 enum class FilterLayout
 {
index e1d339e..14224b3 100644 (file)
@@ -156,9 +156,9 @@ TEST_F(TFLExporterImplTests, Regression_0000)
     pull->shape({1, 8, 8, 3});
   }
   auto relu = make_node<loco::ReLU>();
-  auto encode = exo::make_feature_encode<exo::DefaultLayout::NHWC>(pull);
+  auto encode = exo::make_feature_encode<exo::FeatureLayout::NHWC>(pull);
   auto maxpool = make_node<loco::MaxPool2D>();
-  auto decode = exo::make_feature_decode<exo::DefaultLayout::NHWC>(relu);
+  auto decode = exo::make_feature_decode<exo::FeatureLayout::NHWC>(relu);
   auto push = make_node<loco::Push>();
 
   ASSERT_EQ(maxpool->window()->vertical(), 1);
index 9bcc914..7afc9e9 100644 (file)
@@ -184,11 +184,11 @@ public:
 
   void build()
   {
-    fea_enc = exo::make_feature_encode<exo::DefaultLayout::NHWC>(pull);
+    fea_enc = exo::make_feature_encode<exo::FeatureLayout::NHWC>(pull);
     constgen = append<loco::ConstGen>();
     bias_enc = append<loco::BiasEncode>(constgen);
     fea_bias_add = append<loco::FeatureBiasAdd>(fea_enc, bias_enc);
-    fea_dec = exo::make_feature_decode<exo::DefaultLayout::NHWC>(fea_bias_add);
+    fea_dec = exo::make_feature_decode<exo::FeatureLayout::NHWC>(fea_bias_add);
     complete(fea_dec);
   }
 };