[coco] PadF as a Op tree node (#1817)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 11 Oct 2018 00:43:54 +0000 (09:43 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 11 Oct 2018 00:43:54 +0000 (09:43 +0900)
With this commit, PadF may serve as a node of Op tree.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/PadF.h
contrib/coco/core/src/IR/PadF.cpp
contrib/coco/core/src/IR/PadF.test.cpp

index fb6cf38..4e3229d 100644 (file)
@@ -18,6 +18,7 @@
 #define __COCO_IR_PAD_F_H__
 
 #include "coco/IR/Op.h"
+#include "coco/IR/Part.h"
 #include "coco/IR/Padding2D.h"
 
 namespace coco
@@ -43,10 +44,18 @@ public:
   const PadF *asPadF(void) const override { return this; }
 
 public:
+  Op *arg(void) const { return _arg.child(); }
+  void arg(Op *arg) { _arg.child(arg); }
+
+public:
   Padding2D *pad(void) { return &_pad; }
   const Padding2D *pad(void) const { return &_pad; }
 
 private:
+  // @brief An argument of PadF operation (= IFM)
+  Part _arg;
+
+private:
   Padding2D _pad;
 };
 
index 8604165..2b79b86 100644 (file)
@@ -19,7 +19,7 @@
 namespace coco
 {
 
-PadF::PadF()
+PadF::PadF() : _arg{this}
 {
   // DO NOTHING
 }
@@ -28,6 +28,15 @@ std::set<Object *> PadF::uses(void) const
 {
   // NOTE PadF accesses no object
   std::set<Object *> res;
+
+  if (auto ifm = arg())
+  {
+    for (auto obj : ifm->uses())
+    {
+      res.insert(obj);
+    }
+  }
+
   return res;
 }
 
index 28ffedd..670213c 100644 (file)
@@ -58,6 +58,9 @@ TEST_F(PadFTest, initialization)
   // parent() should be nullptr on construction
   ASSERT_EQ(op->parent(), nullptr);
 
+  // arg() should be nullptr on construction
+  ASSERT_EQ(op->arg(), nullptr);
+
   // pad() should be a valid
   ASSERT_NE(op->pad(), nullptr);
 }