[enco] Do NOT use GenericFeatureLayout in NNAPI backend (#1612)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 21 Sep 2018 01:26:56 +0000 (10:26 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 21 Sep 2018 01:26:56 +0000 (10:26 +0900)
This commit replaces all the use of GenericFeatureLayout inside NNAPI
backend implementation with optimized BHWC layout.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/Transforms/Normalize.cpp
contrib/enco/core/src/Transforms/Rewrite.cpp

index ee1d080..cb7a0cf 100644 (file)
@@ -1,5 +1,7 @@
 #include "Normalize.h"
 
+#include <coco/IR/FeatureLayouts.h>
+
 #include <nncc/core/ADT/feature/Layout.h>
 #include <nncc/core/ADT/kernel/Layout.h>
 
@@ -88,12 +90,9 @@ coco::FeatureObject *ShuffleGen::clone(const coco::FeatureObject *oldobj) const
 
   auto newbag = _module->entity()->bag()->create(oldbag->size());
   auto newobj = _module->entity()->object()->create(oldobj->shape());
-  auto new_layout = make_unique<coco::GenericFeatureLayout>(oldobj->shape());
-
-  new_layout->reorder(nncc::core::ADT::feature::HWCLayout{});
 
   newobj->bag(newbag);
-  newobj->layout(std::move(new_layout));
+  newobj->layout(coco::FeatureLayouts::BHWC::create(oldobj->shape()));
 
   return newobj;
 }
index d059fd5..5222075 100644 (file)
@@ -1,5 +1,7 @@
 #include "Rewrite.h"
 
+#include <coco/IR/FeatureLayouts.h>
+
 #include <nncc/core/ADT/feature/Shape.h>
 #include <nncc/core/ADT/feature/HWCLayout.h>
 
@@ -89,12 +91,9 @@ void AvgPoolRewritePass::runOnModule(coco::Module *m) const
               auto pad_shape = shape_xform(avgpool->pad()).forward(ifm_obj->shape());
               auto pad_bag = m->entity()->bag()->create(num_elements(pad_shape));
               auto pad_obj = m->entity()->object()->create(pad_shape);
-              auto pad_layout = make_unique<coco::GenericFeatureLayout>(pad_shape);
-
-              pad_layout->reorder(feature::HWCLayout{});
 
               pad_obj->bag(pad_bag);
-              pad_obj->layout(std::move(pad_layout));
+              pad_obj->layout(coco::FeatureLayouts::BHWC::create(pad_shape));
 
               auto pad_op = m->entity()->op()->create<coco::PadF>();