[enco] Do NOT use reorder (in NNAPI backend) (#1589)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 20 Sep 2018 01:09:18 +0000 (10:09 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 20 Sep 2018 01:09:18 +0000 (10:09 +0900)
This commit eliminates the use of reorder method (in FeatureObject) from
NNAPI backend implementation.

This change is prerequisite for coco IR design revision.

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

index 14e88d2..ee1d080 100644 (file)
@@ -6,6 +6,10 @@
 #include <nncc/core/ADT/feature/HWCLayout.h>
 #include <nncc/core/ADT/kernel/NHWCLayout.h>
 
+#include <nncc/foundation/Memory.h>
+
+using nncc::foundation::make_unique;
+
 namespace
 {
 bool aligned(const coco::FeatureObject *o, const nncc::core::ADT::feature::Layout &l)
@@ -84,9 +88,12 @@ 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->reorder<nncc::core::ADT::feature::HWCLayout>();
+  newobj->layout(std::move(new_layout));
 
   return newobj;
 }
index 69383d2..d059fd5 100644 (file)
@@ -3,11 +3,15 @@
 #include <nncc/core/ADT/feature/Shape.h>
 #include <nncc/core/ADT/feature/HWCLayout.h>
 
+#include <nncc/foundation/Memory.h>
+
 #include <cassert>
 
 using namespace nncc::core::ADT;
 using nncc::core::ADT::feature::num_elements;
 
+using nncc::foundation::make_unique;
+
 namespace
 {
 
@@ -85,9 +89,12 @@ 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->reorder<feature::HWCLayout>();
+              pad_obj->layout(std::move(pad_layout));
 
               auto pad_op = m->entity()->op()->create<coco::PadF>();