From b1838c0ccce5d695ad1e470981f0140e344b06f0 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: Thu, 16 Aug 2018 19:20:17 +0900 Subject: [PATCH] [coco] Remove Conv2D::Param struct (#1054) This commit removes Conv2D::Param struct, and revises OpManager::create method similarly as InstrManager::create method. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Op.h | 11 +---------- contrib/coco/core/include/coco/IR/OpManager.h | 2 +- contrib/coco/core/src/IR.test.cpp | 2 +- contrib/coco/core/src/IR/Instr.test.cpp | 2 +- contrib/coco/core/src/IR/Op.cpp | 5 ++--- contrib/coco/core/src/IR/Op.test.cpp | 12 ++++++------ contrib/coco/core/src/IR/OpManager.cpp | 4 ++-- contrib/coco/core/src/IR/OpManager.test.cpp | 3 +-- 8 files changed, 15 insertions(+), 26 deletions(-) diff --git a/contrib/coco/core/include/coco/IR/Op.h b/contrib/coco/core/include/coco/IR/Op.h index f56e35f..bad67f9 100644 --- a/contrib/coco/core/include/coco/IR/Op.h +++ b/contrib/coco/core/include/coco/IR/Op.h @@ -95,16 +95,7 @@ namespace coco class Conv2D : public Op, public Object::Use { public: - struct Param - { - Param() = default; - - // TODO Add 'Stride' configuration - // TODO Add 'Padding' configuration - }; - -public: - explicit Conv2D(const PtrLink *, const PtrLink *, const Param &); + explicit Conv2D(const PtrLink *, const PtrLink *); public: std::set uses(void) const override; diff --git a/contrib/coco/core/include/coco/IR/OpManager.h b/contrib/coco/core/include/coco/IR/OpManager.h index 2f6921e..a1415b5 100644 --- a/contrib/coco/core/include/coco/IR/OpManager.h +++ b/contrib/coco/core/include/coco/IR/OpManager.h @@ -19,7 +19,7 @@ public: OpManager(const PtrLink *op_link, const PtrLink *obj_link); public: - Conv2D *create(const Conv2D::Param &); + template T *create(void); private: const PtrLink *const _op_link; diff --git a/contrib/coco/core/src/IR.test.cpp b/contrib/coco/core/src/IR.test.cpp index 45a9e79..c368b5c 100644 --- a/contrib/coco/core/src/IR.test.cpp +++ b/contrib/coco/core/src/IR.test.cpp @@ -130,7 +130,7 @@ TEST(IR, caffe_conv) // Create Conv2D operation // // NOTE Conv2D op in coco IR does not perform BiasAdd - auto op = m->entity()->op()->create(coco::Conv2D::Param{}); + auto op = m->entity()->op()->create(); op->ker(ker_obj); diff --git a/contrib/coco/core/src/IR/Instr.test.cpp b/contrib/coco/core/src/IR/Instr.test.cpp index cbad40c..e39ebbe 100644 --- a/contrib/coco/core/src/IR/Instr.test.cpp +++ b/contrib/coco/core/src/IR/Instr.test.cpp @@ -156,7 +156,7 @@ TEST_F(UnitFTest, asUnitF) TEST_F(UnitFTest, op_update) { // Prepare an Op for UnitF test - auto op = op_mgr.create(coco::Conv2D::Param{}); + auto op = op_mgr.create(); // Test UnitF auto ins = allocate(); diff --git a/contrib/coco/core/src/IR/Op.cpp b/contrib/coco/core/src/IR/Op.cpp index 2364163..8d1e6a6 100644 --- a/contrib/coco/core/src/IR/Op.cpp +++ b/contrib/coco/core/src/IR/Op.cpp @@ -22,11 +22,10 @@ Instr *Op::parent(void) const namespace coco { -Conv2D::Conv2D(const PtrLink *op_link, const PtrLink *obj_link, - const Param &) +Conv2D::Conv2D(const PtrLink *op_link, const PtrLink *obj_link) : _op_link{op_link}, _ker{obj_link, this} { - // NOTE Currently, Param class is just a placeholder + // DO NOTHING } std::set Conv2D::uses(void) const diff --git a/contrib/coco/core/src/IR/Op.test.cpp b/contrib/coco/core/src/IR/Op.test.cpp index b45b71f..f50de5b 100644 --- a/contrib/coco/core/src/IR/Op.test.cpp +++ b/contrib/coco/core/src/IR/Op.test.cpp @@ -17,9 +17,9 @@ public: } protected: - coco::Conv2D *allocate(const coco::Conv2D::Param ¶m) + coco::Conv2D *allocate(void) { - auto op = new coco::Conv2D{&op_link, &obj_link, param}; + auto op = new coco::Conv2D{&op_link, &obj_link}; _allocated.emplace_back(op); return op; } @@ -39,7 +39,7 @@ private: TEST_F(Conv2DTest, ctor) { - auto op = allocate(coco::Conv2D::Param{}); + auto op = allocate(); // ker() should be initialized as nullptr on construction ASSERT_EQ(op->ker(), nullptr); @@ -52,7 +52,7 @@ TEST_F(Conv2DTest, ctor) TEST_F(Conv2DTest, asConv2D) { - auto op = allocate(coco::Conv2D::Param{}); + auto op = allocate(); coco::Op *mutable_base = op; const coco::Op *immutable_base = op; @@ -78,7 +78,7 @@ TEST_F(Conv2DTest, ker_update) auto obj = obj_mgr.create(nncc::core::ADT::kernel::Shape{1, 1, 3, 3}); // Test 'Conv2D' class - auto op = allocate(coco::Conv2D::Param{}); + auto op = allocate(); op->ker(obj); ASSERT_EQ(op->ker(), obj); @@ -98,7 +98,7 @@ TEST_F(Conv2DTest, ker_update) TEST_F(Conv2DTest, accept) { // Test 'Conv2D' class - auto op = allocate(coco::Conv2D::Param{}); + auto op = allocate(); coco::Conv2D *mutable_ptr = op; const coco::Conv2D *immutable_ptr = op; diff --git a/contrib/coco/core/src/IR/OpManager.cpp b/contrib/coco/core/src/IR/OpManager.cpp index d67c1dc..7d5cc71 100644 --- a/contrib/coco/core/src/IR/OpManager.cpp +++ b/contrib/coco/core/src/IR/OpManager.cpp @@ -13,9 +13,9 @@ OpManager::OpManager(const PtrLink *op_link, const PtrLink Conv2D *OpManager::create(void) { - return take(make_unique(_op_link, _obj_link, param)); + return take(make_unique(_op_link, _obj_link)); } } // namespace coco diff --git a/contrib/coco/core/src/IR/OpManager.test.cpp b/contrib/coco/core/src/IR/OpManager.test.cpp index bc5874f..8bc5876 100644 --- a/contrib/coco/core/src/IR/OpManager.test.cpp +++ b/contrib/coco/core/src/IR/OpManager.test.cpp @@ -8,8 +8,7 @@ TEST(IR_OP_MANAGER, create_Conv2D) coco::PtrLink obj_link; coco::OpManager mgr{&op_link, &obj_link}; - coco::Conv2D::Param param; - auto obj = mgr.create(param); + auto obj = mgr.create(); ASSERT_NE(obj, nullptr); } -- 2.7.4