[coco] Tree-like Conv2D op (#1773)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 8 Oct 2018 05:37:07 +0000 (14:37 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 8 Oct 2018 05:37:07 +0000 (14:37 +0900)
* [coco] Tree-like Conv2D op

This commit introduces 'arg' methods to Conv2D class, which allows
frontend to construct a tree-like structure with Conv2D Op.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
* Fix a typo

contrib/coco/core/include/coco/IR/Conv2D.h
contrib/coco/core/src/IR/Conv2D.cpp
contrib/coco/core/src/IR/Conv2D.test.cpp

index 44334a4..1b6d867 100644 (file)
@@ -18,6 +18,7 @@
 #define __COCO_IR_CONV2D_H__
 
 #include "coco/IR/Op.h"
+#include "coco/IR/Part.h"
 #include "coco/IR/KernelObject.h"
 #include "coco/IR/Padding2D.h"
 #include "coco/IR/Stride2D.h"
@@ -51,6 +52,10 @@ private:
   Use _ker;
 
 public:
+  Op *arg(void) const { return _arg.child(); }
+  void arg(Op *arg) { _arg.child(arg); }
+
+public:
   KernelObject *ker(void) const;
   void ker(KernelObject *ker);
 
@@ -84,6 +89,10 @@ private:
 
   Padding2D _pad;
   Stride2D _stride;
+
+private:
+  // @brief Link to an argument of Conv2D operation (= IFM)
+  Part _arg;
 };
 
 } // namespace coco
index 2912cab..b835dcd 100644 (file)
@@ -21,7 +21,7 @@
 namespace coco
 {
 
-Conv2D::Conv2D() : _ker{this}
+Conv2D::Conv2D() : _ker{this}, _arg{this}
 {
   // DO NOTHING
 }
@@ -35,6 +35,14 @@ std::set<Object *> Conv2D::uses(void) const
     res.insert(ker());
   }
 
+  if (auto ifm = arg())
+  {
+    for (auto obj : ifm->uses())
+    {
+      res.insert(obj);
+    }
+  }
+
   return res;
 }
 
index dfc82a9..920e723 100644 (file)
@@ -56,6 +56,8 @@ TEST_F(Conv2DTest, ctor)
 {
   auto op = allocate();
 
+  // arg() should be initialized as nullptr on construction
+  ASSERT_EQ(op->arg(), nullptr);
   // ker() should be initialized as nullptr on construction
   ASSERT_EQ(op->ker(), nullptr);