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>
#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
{
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
}
template <typename Ins> Ins *create(void);
private:
+ PtrLink<Op, Instr> *const _op_link;
const PtrLink<Instr, Block> *const _instr_link;
};
#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
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
{
{
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;
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>>();
{
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());
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);
namespace coco
{
+OpManager::OpManager(const PtrLink<Op, Instr> *op_link) : _op_link{op_link}
+{
+ // DO NOTHING
+}
+
Conv2D *OpManager::create(const Conv2D::Param ¶m) { return take(make_unique<Conv2D>(param)); }
} // namespace coco
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);