[coco] Pass OpLink to Op/Instr Manager (#935)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 8 Aug 2018 08:32:58 +0000 (17:32 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 8 Aug 2018 08:32:58 +0000 (17:32 +0900)
This commit revises Op/Instr Manager to take OpLink on construction.

Note that OpLink passed ot Op/Instr Managers is not used, yet.

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

index 1efafb7..50d2a84 100644 (file)
@@ -2,8 +2,10 @@
 #define __COCO_IR_INSTR_MANAGER_H__
 
 #include "coco/IR/Instr.h"
+#include "coco/IR/Op.forward.h"
 
 #include "coco/ADT/PtrManager.h"
+#include "coco/ADT/PtrLink.h"
 
 namespace coco
 {
@@ -11,7 +13,8 @@ namespace coco
 class InstrManager final : public PtrManager<Instr>
 {
 public:
-  InstrManager(const PtrLink<Instr, Block> *instr_link) : _instr_link{instr_link}
+  InstrManager(PtrLink<Op, Instr> *op_link, const PtrLink<Instr, Block> *instr_link)
+      : _op_link{op_link}, _instr_link{instr_link}
   {
     // DO NOTHING
   }
@@ -20,6 +23,7 @@ public:
   template <typename Ins> Ins *create(void);
 
 private:
+  PtrLink<Op, Instr> *const _op_link;
   const PtrLink<Instr, Block> *const _instr_link;
 };
 
index d430398..bd6f1b4 100644 (file)
@@ -2,15 +2,24 @@
 #define __COCO_IR_OP_MANAGER_H__
 
 #include "coco/IR/Op.h"
+#include "coco/IR/Instr.forward.h"
 
 #include "coco/ADT/PtrManager.h"
+#include "coco/ADT/PtrLink.h"
 
 namespace coco
 {
 
 struct OpManager : public PtrManager<Op>
 {
+public:
+  OpManager(const PtrLink<Op, Instr> *op_link);
+
+public:
   Conv2D *create(const Conv2D::Param &);
+
+private:
+  const PtrLink<Op, Instr> *const _op_link;
 };
 
 } // namespace coco
index 70968c2..63befd0 100644 (file)
@@ -5,8 +5,9 @@
 
 TEST(IR_INSTR_MANAGER, create_UnitF)
 {
+  coco::PtrLink<coco::Op, coco::Instr> op_link;
   coco::PtrLink<coco::Instr, coco::Block> link;
-  coco::InstrManager mgr{&link};
+  coco::InstrManager mgr{&op_link, &link};
 
   // Conv2D
   {
index 742e455..b486549 100644 (file)
@@ -66,6 +66,7 @@ class ModuleImpl final : public coco::Module
 {
 public:
   std::unique_ptr<coco::PtrLink<coco::Bag, coco::BagInfo>> _bag_link;
+  std::unique_ptr<coco::PtrLink<coco::Op, coco::Instr>> _op_link;
   std::unique_ptr<coco::PtrLink<coco::Instr, coco::Block>> _instr_link;
   std::unique_ptr<coco::PtrLink<coco::Block, coco::Module>> _block_link;
 
@@ -106,6 +107,7 @@ namespace coco
 std::unique_ptr<Module> Module::create(void)
 {
   auto bag_link = nncc::foundation::make_unique<coco::PtrLink<Bag, BagInfo>>();
+  auto op_link = nncc::foundation::make_unique<coco::PtrLink<Op, Instr>>();
   auto ins_link = nncc::foundation::make_unique<coco::PtrLink<Instr, Block>>();
   auto blk_link = nncc::foundation::make_unique<coco::PtrLink<Block, Module>>();
 
@@ -115,8 +117,8 @@ std::unique_ptr<Module> Module::create(void)
   {
     mgr->_bag = nncc::foundation::make_unique<coco::BagManager>(bag_link.get());
     mgr->_object = nncc::foundation::make_unique<coco::ObjectManager>(bag_link.get());
-    mgr->_op = nncc::foundation::make_unique<coco::OpManager>();
-    mgr->_instr = nncc::foundation::make_unique<coco::InstrManager>(ins_link.get());
+    mgr->_op = nncc::foundation::make_unique<coco::OpManager>(op_link.get());
+    mgr->_instr = nncc::foundation::make_unique<coco::InstrManager>(op_link.get(), ins_link.get());
     mgr->_block = nncc::foundation::make_unique<coco::BlockManager>(blk_link.get(), ins_link.get());
     mgr->_input = nncc::foundation::make_unique<coco::InputManager>(bag_link.get());
     mgr->_output = nncc::foundation::make_unique<coco::OutputManager>(bag_link.get());
@@ -129,6 +131,7 @@ std::unique_ptr<Module> Module::create(void)
   m->_output = nncc::foundation::make_unique<coco::OutputList>();
 
   m->_bag_link = std::move(bag_link);
+  m->_op_link = std::move(op_link);
   m->_instr_link = std::move(ins_link);
   m->_block_link = std::move(blk_link);
 
index 8f19fb2..6c3b02c 100644 (file)
@@ -7,6 +7,11 @@ using nncc::foundation::make_unique;
 namespace coco
 {
 
+OpManager::OpManager(const PtrLink<Op, Instr> *op_link) : _op_link{op_link}
+{
+  // DO NOTHING
+}
+
 Conv2D *OpManager::create(const Conv2D::Param &param) { return take(make_unique<Conv2D>(param)); }
 
 } // namespace coco
index 9d4316b..74c14bd 100644 (file)
@@ -4,7 +4,8 @@
 
 TEST(IR_OP_MANAGER, create_Conv2D)
 {
-  coco::OpManager mgr;
+  coco::PtrLink<coco::Op, coco::Instr> op_link;
+  coco::OpManager mgr{&op_link};
 
   coco::Conv2D::Param param;
   auto obj = mgr.create(param);