[enco] Build ANN IR from ANNDepthConcatF instruction (#2521)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 6 Dec 2018 05:38:07 +0000 (14:38 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 6 Dec 2018 05:38:07 +0000 (14:38 +0900)
ANN IRGen Pass now generates ANN IR from ANNDepthConcatF instruction.

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

index c233547..9f3d26a 100644 (file)
@@ -17,6 +17,7 @@
 #include "Split.h"
 #include "Usage.h"
 #include "Session.h"
+#include "coex/IR.h"
 
 #include <coco/IR.h>
 
@@ -827,6 +828,30 @@ public:
 namespace
 {
 
+std::unique_ptr<ANNOpAppender> make_appender(coco::Instr *ins)
+{
+  ANNOpBuilder op_builder;
+
+  if (auto eval = coco::safe_cast<coco::Eval>(ins))
+  {
+    return eval->accept(op_builder);
+  }
+
+  if (auto depth_concat = coco::safe_cast<ANNDepthConcatF>(ins))
+  {
+    auto app = make_unique<ANNConcatAppender>();
+
+    app->out(depth_concat->out()->asFeature());
+
+    app->left(depth_concat->fst()->asFeature());
+    app->right(depth_concat->snd()->asFeature());
+
+    return std::move(app);
+  }
+
+  return nullptr;
+}
+
 enum Compatibility
 {
   COMPATIBLE,
@@ -867,8 +892,6 @@ void ANNGroupBuilder::build(enco::Code *code) const
   auto m = code->module();
   auto d = code->data();
 
-  ANNOpBuilder op_builder;
-
   // ANNGroupBuilder will construct a sequence of blocks from the original block sequence, and
   // a destination block (that dst_blk points to) is the tail of the generated sequence.
   coco::Block *dst_blk = nullptr;
@@ -907,7 +930,7 @@ void ANNGroupBuilder::build(enco::Code *code) const
       ins = cur_ins->next();
       cur_ins->detach();
 
-      auto cur_append = cur_ins->accept(op_builder);
+      auto cur_append = make_appender(cur_ins);
 
       // Create a new compatible block and use it as a destination block if the current
       // destination block is absent or incompatible with the instruction of intereset.