From e2df840f6ab08a4f8b1de323924098596e5c2d43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 24 Jul 2018 15:00:26 +0900 Subject: [PATCH] [coco] Add 'InstrManager' class (#776) This commit adds 'InstrManager' class which allocates and tracks instances of 'Instr' class. The current implementation is restrictied to 'UnitF'. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/InstrManager.h | 28 ++++++++++++++++++++++++ contrib/coco/core/src/IR/InstrManager.cpp | 15 +++++++++++++ contrib/coco/core/src/IR/InstrManager.test.cpp | 16 ++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 contrib/coco/core/include/coco/IR/InstrManager.h create mode 100644 contrib/coco/core/src/IR/InstrManager.cpp create mode 100644 contrib/coco/core/src/IR/InstrManager.test.cpp diff --git a/contrib/coco/core/include/coco/IR/InstrManager.h b/contrib/coco/core/include/coco/IR/InstrManager.h new file mode 100644 index 0000000..580ae84 --- /dev/null +++ b/contrib/coco/core/include/coco/IR/InstrManager.h @@ -0,0 +1,28 @@ +#ifndef __COCO_IR_INSTR_MANAGER_H__ +#define __COCO_IR_INSTR_MANAGER_H__ + +#include "coco/IR/Instr.h" + +#include "coco/ADT/PtrManager.h" + +namespace coco +{ + +class InstrManager final : public PtrManager +{ +public: + InstrManager(const PtrLink *instr_link) : _instr_link{instr_link} + { + // DO NOTHING + } + +public: + template UnitF *createF(void); + +private: + const PtrLink * const _instr_link; +}; + +} // namespace coco + +#endif // __COCO_IR_INPUT_MANAGER_H__ diff --git a/contrib/coco/core/src/IR/InstrManager.cpp b/contrib/coco/core/src/IR/InstrManager.cpp new file mode 100644 index 0000000..8fe525e --- /dev/null +++ b/contrib/coco/core/src/IR/InstrManager.cpp @@ -0,0 +1,15 @@ +#include "coco/IR/InstrManager.h" + +#include "coco/IR/Op.h" + +#include + +namespace coco +{ + +template<> UnitF *InstrManager::createF() +{ + return take(nncc::foundation::make_unique>(_instr_link)); +} + +} // namespace coco diff --git a/contrib/coco/core/src/IR/InstrManager.test.cpp b/contrib/coco/core/src/IR/InstrManager.test.cpp new file mode 100644 index 0000000..03f9e53 --- /dev/null +++ b/contrib/coco/core/src/IR/InstrManager.test.cpp @@ -0,0 +1,16 @@ +#include "coco/IR/InstrManager.h" +#include "coco/IR/Op.h" + +#include + +TEST(IR_INSTR_MANAGER, create_UnitF) +{ + coco::PtrLink link; + coco::InstrManager mgr{&link}; + + // Conv2D + { + auto ins = mgr.createF(); + ASSERT_NE(ins, nullptr); + } +} -- 2.7.4