From 2056c484b3cf5f9f8631957aed187622f3578746 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: Fri, 28 Sep 2018 16:03:07 +0900 Subject: [PATCH] [coco] Construct FeatureObject empty layout (#1668) This commit revises ObjectManager to allow users to construct FeatureObject with empty layout. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/FeatureObject.h | 1 + contrib/coco/core/include/coco/IR/ObjectManager.h | 2 ++ contrib/coco/core/src/IR/ObjectManager.cpp | 7 +++++++ contrib/coco/core/src/IR/ObjectManager.test.cpp | 9 +++++++++ 4 files changed, 19 insertions(+) diff --git a/contrib/coco/core/include/coco/IR/FeatureObject.h b/contrib/coco/core/include/coco/IR/FeatureObject.h index a6f2633..fdedad0 100644 --- a/contrib/coco/core/include/coco/IR/FeatureObject.h +++ b/contrib/coco/core/include/coco/IR/FeatureObject.h @@ -37,6 +37,7 @@ namespace coco class FeatureObject final : public Object { public: + FeatureObject() = default; explicit FeatureObject(std::unique_ptr &&info); public: diff --git a/contrib/coco/core/include/coco/IR/ObjectManager.h b/contrib/coco/core/include/coco/IR/ObjectManager.h index c204ed6..3cf8912 100644 --- a/contrib/coco/core/include/coco/IR/ObjectManager.h +++ b/contrib/coco/core/include/coco/IR/ObjectManager.h @@ -39,6 +39,8 @@ public: public: FeatureObject *create(const nncc::core::ADT::feature::Shape &shape); KernelObject *create(const nncc::core::ADT::kernel::Shape &shape); + + template T *create(void); }; } // namespace coco diff --git a/contrib/coco/core/src/IR/ObjectManager.cpp b/contrib/coco/core/src/IR/ObjectManager.cpp index cf6c740..34d9ac1 100644 --- a/contrib/coco/core/src/IR/ObjectManager.cpp +++ b/contrib/coco/core/src/IR/ObjectManager.cpp @@ -28,6 +28,13 @@ using nncc::foundation::make_unique; namespace coco { +template <> FeatureObject *ObjectManager::create(void) +{ + auto feature = make_unique(); + modulize(feature.get()); + return take(std::move(feature)); +} + FeatureObject *ObjectManager::create(const nncc::core::ADT::feature::Shape &shape) { auto info = make_unique(shape); diff --git a/contrib/coco/core/src/IR/ObjectManager.test.cpp b/contrib/coco/core/src/IR/ObjectManager.test.cpp index f927a6a..206807c 100644 --- a/contrib/coco/core/src/IR/ObjectManager.test.cpp +++ b/contrib/coco/core/src/IR/ObjectManager.test.cpp @@ -49,3 +49,12 @@ TEST(IR_OBJECT_MANAGER, create_kernel) ASSERT_EQ(o->shape().height(), shape.height()); ASSERT_EQ(o->shape().width(), shape.width()); } + +TEST(IR_OBJECT_MANAGER, create_feature_with_template) +{ + coco::ObjectManager mgr; + + auto feature = mgr.create(); + + ASSERT_EQ(feature->layout(), nullptr); +} -- 2.7.4