class Head
{
public:
- // TODO _link is no longer used
- Head(Parent *parent, PtrLink<Child, Parent> *link) : _parent{parent}
+ Head(Parent *parent) : _parent{parent}
{
_head = nullptr;
_tail = nullptr;
class Block final : public DLinkedList<Block, Module>::Node
{
public:
- // TODO Update constructor
- Block(const PtrLink<Block, Module> *, PtrLink<Instr, Block> *instr_link)
- : _instr{this, instr_link}
+ Block() : _instr{this}
{
// DO NOTHING
}
class BlockManager final : public PtrManager<Block>
{
public:
- BlockManager(const PtrLink<Block, Module> *block_link, PtrLink<Instr, Block> *instr_link)
- : _block_link{block_link}, _instr_link{instr_link}
- {
- // DO NOTHING
- }
-
-private:
- const PtrLink<Block, Module> *const _block_link;
- PtrLink<Instr, Block> *const _instr_link;
-
-public:
Block *create(void);
public:
class InstrManager final : public PtrManager<Instr>
{
public:
- InstrManager(PtrLink<Op, Instr> *op_link, const PtrLink<Instr, Block> *instr_link,
- const PtrLink<Object, ObjectInfo> *obj_link)
- : _op_link{op_link}, _instr_link{instr_link}, _obj_link{obj_link}
+ InstrManager(PtrLink<Op, Instr> *op_link, const PtrLink<Object, ObjectInfo> *obj_link)
+ : _op_link{op_link}, _obj_link{obj_link}
{
// DO NOTHING
}
private:
PtrLink<Op, Instr> *const _op_link;
- const PtrLink<Instr, Block> *const _instr_link;
const PtrLink<Object, ObjectInfo> *const _obj_link;
};
class Shuffle final : public Instr, public Bag::Reader, public Bag::Updater
{
public:
- // TODO Update constructor interface
- Shuffle(const PtrLink<Instr, Block> *) : _from{this}, _into{this}
+ Shuffle() : _from{this}, _into{this}
{
// DO NOTHING
}
{
public:
// TODO Update constructor
- UnitF(PtrLink<Op, Instr> *op_link, const PtrLink<Instr, Block> *,
- const PtrLink<Object, ObjectInfo> *obj_link)
+ UnitF(PtrLink<Op, Instr> *op_link, const PtrLink<Object, ObjectInfo> *obj_link)
: FeatureInstr{obj_link}, _op_link{op_link}
{
_step.instr(this);
class Parent
{
public:
- Parent(coco::PtrLink<Child, Parent> *link) : _list{this, link}
+ Parent() : _list{this}
{
// DO NOTHING
}
class Child final : public coco::DLinkedList<Child, Parent>::Node
{
-public:
- // TODO Update constructor
- Child(const coco::PtrLink<Child, Parent> *)
- {
- // DO NOTHING
- }
+ // DO NOTHING
};
} // namespace
TEST(ADT_DLINKED_LINK, insert_two_elements)
{
- auto link = new coco::PtrLink<::Child, ::Parent>{};
- auto parent = new ::Parent{link};
+ auto parent = new ::Parent;
ASSERT_EQ(parent->children()->head(), nullptr);
ASSERT_EQ(parent->children()->tail(), nullptr);
- auto child_1 = new ::Child{link};
+ auto child_1 = new ::Child;
ASSERT_EQ(child_1->parent(), nullptr);
ASSERT_EQ(child_1->prev(), nullptr);
ASSERT_EQ(parent->children()->head(), child_1);
ASSERT_EQ(parent->children()->tail(), child_1);
- auto child_2 = new ::Child{link};
+ auto child_2 = new ::Child;
ASSERT_EQ(child_2->parent(), nullptr);
ASSERT_EQ(child_2->prev(), nullptr);
delete child_2;
delete child_1;
delete parent;
- delete link;
}
TEST(ADT_DLINKED_LINK, insertBefore)
{
- auto link = new coco::PtrLink<::Child, ::Parent>{};
- auto parent = new ::Parent{link};
+ auto parent = new ::Parent;
- auto child_1 = new ::Child{link};
- auto child_2 = new ::Child{link};
+ auto child_1 = new ::Child;
+ auto child_2 = new ::Child;
parent->children()->append(child_1);
child_2->insertBefore(child_1);
delete child_2;
delete child_1;
delete parent;
- delete link;
}
TEST(ADT_DLINKED_LINK, prepend_after_append)
{
- auto link = new coco::PtrLink<::Child, ::Parent>{};
- auto parent = new ::Parent{link};
+ auto parent = new ::Parent;
- auto child_1 = new ::Child{link};
- auto child_2 = new ::Child{link};
+ auto child_1 = new ::Child;
+ auto child_2 = new ::Child;
parent->children()->append(child_1);
parent->children()->prepend(child_2);
delete child_2;
delete child_1;
delete parent;
- delete link;
}
TEST(ADT_DLINKED_LINK, detach)
{
- auto link = new coco::PtrLink<::Child, ::Parent>{};
- auto parent = new ::Parent{link};
+ auto parent = new ::Parent;
- auto child_1 = new ::Child{link};
- auto child_2 = new ::Child{link};
+ auto child_1 = new ::Child;
+ auto child_2 = new ::Child;
parent->children()->append(child_1);
parent->children()->append(child_2);
delete child_2;
delete child_1;
delete parent;
- delete link;
}
TEST(ADT_DLINKED_LINK, node_destructor)
{
- auto link = new coco::PtrLink<::Child, ::Parent>{};
- auto parent = new ::Parent{link};
+ auto parent = new ::Parent;
- auto child_1 = new ::Child{link};
- auto child_2 = new ::Child{link};
+ auto child_1 = new ::Child;
+ auto child_2 = new ::Child;
parent->children()->append(child_1);
parent->children()->append(child_2);
ASSERT_EQ(parent->children()->tail(), nullptr);
delete parent;
- delete link;
}
TEST(IR_BLOCK, default_block_has_empty_instr_list)
{
- coco::PtrLink<coco::Block, coco::Module> block_link;
- coco::PtrLink<coco::Instr, coco::Block> instr_link;
- coco::Block blk{&block_link, &instr_link};
+ coco::Block blk;
ASSERT_TRUE(blk.instr()->empty());
ASSERT_EQ(blk.instr()->head(), nullptr);
namespace coco
{
-Block *BlockManager::create(void)
-{
- return take(nncc::foundation::make_unique<Block>(_block_link, _instr_link));
-}
+Block *BlockManager::create(void) { return take(nncc::foundation::make_unique<Block>()); }
void BlockManager::destroy(Block *blk)
{
// Create a coco::BlockManager for testing
coco::BlockManager *allocate(void)
{
- auto p = new coco::BlockManager{&_block_link, &_instr_link};
+ auto p = new coco::BlockManager;
_allocated.emplace_back(p);
return p;
}
private:
- coco::PtrLink<coco::Block, coco::Module> _block_link;
- coco::PtrLink<coco::Instr, coco::Block> _instr_link;
-
-private:
std::vector<std::unique_ptr<coco::BlockManager>> _allocated;
};
} // namespace
coco::PtrLink<coco::Object, coco::ObjectInfo> obj_link;
coco::PtrLink<coco::Op, coco::Instr> op_link;
- // TODO Rename link as instr_link
- coco::PtrLink<coco::Instr, coco::Block> link;
coco::ObjectManager obj_mgr{&obj_link};
coco::OpManager op_mgr{&op_link, &obj_link};
protected:
coco::UnitF *allocate(void)
{
- auto ins = new coco::UnitF{&op_link, &link, &obj_link};
+ auto ins = new coco::UnitF{&op_link, &obj_link};
_allocated.emplace_back(ins);
return ins;
}
template <> UnitF *InstrManager::create(void)
{
- return take(nncc::foundation::make_unique<UnitF>(_op_link, _instr_link, _obj_link));
+ return take(nncc::foundation::make_unique<UnitF>(_op_link, _obj_link));
}
template <> Shuffle *InstrManager::create(void)
{
- return take(nncc::foundation::make_unique<Shuffle>(_instr_link));
+ return take(nncc::foundation::make_unique<Shuffle>());
}
void InstrManager::destroy(Instr *ins)
protected:
coco::PtrLink<coco::Op, coco::Instr> op_link;
- coco::PtrLink<coco::Instr, coco::Block> ins_link;
coco::PtrLink<coco::Object, coco::ObjectInfo> obj_link;
- coco::InstrManager mgr{&op_link, &ins_link, &obj_link};
+ coco::InstrManager mgr{&op_link, &obj_link};
};
} // namespace
TEST(IR_INSTR_MANAGER, create_UnitF)
{
coco::PtrLink<coco::Op, coco::Instr> op_link;
- coco::PtrLink<coco::Instr, coco::Block> link;
coco::PtrLink<coco::Object, coco::ObjectInfo> obj_link;
- coco::InstrManager mgr{&op_link, &link, &obj_link};
+ coco::InstrManager mgr{&op_link, &obj_link};
// Conv2D
{
public:
std::unique_ptr<coco::PtrLink<coco::Object, coco::ObjectInfo>> _obj_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;
public:
coco::EntityManager *entity(void) override { return _entity.get(); }
{
auto obj_link = make_unique<coco::PtrLink<Object, ObjectInfo>>();
auto op_link = make_unique<coco::PtrLink<Op, Instr>>();
- auto ins_link = make_unique<coco::PtrLink<Instr, Block>>();
- auto blk_link = make_unique<coco::PtrLink<Block, Module>>();
auto m = make_unique<::ModuleImpl>();
mgr->_bag = make_unique<coco::BagManager>();
mgr->_object = make_unique<coco::ObjectManager>(obj_link.get());
mgr->_op = make_unique<coco::OpManager>(op_link.get(), obj_link.get());
- mgr->_instr = make_unique<coco::InstrManager>(op_link.get(), ins_link.get(), obj_link.get());
- mgr->_block = make_unique<coco::BlockManager>(blk_link.get(), ins_link.get());
+ mgr->_instr = make_unique<coco::InstrManager>(op_link.get(), obj_link.get());
+ mgr->_block = make_unique<coco::BlockManager>();
mgr->_input = make_unique<coco::InputManager>();
mgr->_output = make_unique<coco::OutputManager>();
}
m->_entity = std::move(mgr);
- // NOTE BlockManager and BlockList SHOULD share 'blk_link'
- m->_block = make_unique<coco::BlockList>(m.get(), blk_link.get());
+ m->_block = make_unique<coco::BlockList>(m.get());
m->_input = make_unique<coco::InputList>();
m->_output = make_unique<coco::OutputList>();
m->_obj_link = std::move(obj_link);
m->_op_link = std::move(op_link);
- m->_instr_link = std::move(ins_link);
- m->_block_link = std::move(blk_link);
return std::move(m);
}
protected:
coco::Shuffle *allocate(void)
{
- auto ins = new coco::Shuffle{&instr_link};
+ auto ins = new coco::Shuffle;
_allocated.emplace_back(ins);
return ins;
}
protected:
coco::PtrLink<coco::Bag, coco::BagInfo> bag_link;
- coco::PtrLink<coco::Instr, coco::Block> instr_link;
private:
std::vector<std::unique_ptr<coco::Instr>> _allocated;