[coco] Construct FeatureObject empty layout (#1668)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 28 Sep 2018 07:03:07 +0000 (16:03 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 28 Sep 2018 07:03:07 +0000 (16:03 +0900)
This commit revises ObjectManager to allow users to construct FeatureObject
with empty layout.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/FeatureObject.h
contrib/coco/core/include/coco/IR/ObjectManager.h
contrib/coco/core/src/IR/ObjectManager.cpp
contrib/coco/core/src/IR/ObjectManager.test.cpp

index a6f2633..fdedad0 100644 (file)
@@ -37,6 +37,7 @@ namespace coco
 class FeatureObject final : public Object
 {
 public:
+  FeatureObject() = default;
   explicit FeatureObject(std::unique_ptr<FeatureObjectInfo> &&info);
 
 public:
index c204ed6..3cf8912 100644 (file)
@@ -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 <typename T> T *create(void);
 };
 
 } // namespace coco
index cf6c740..34d9ac1 100644 (file)
@@ -28,6 +28,13 @@ using nncc::foundation::make_unique;
 namespace coco
 {
 
+template <> FeatureObject *ObjectManager::create(void)
+{
+  auto feature = make_unique<FeatureObject>();
+  modulize(feature.get());
+  return take(std::move(feature));
+}
+
 FeatureObject *ObjectManager::create(const nncc::core::ADT::feature::Shape &shape)
 {
   auto info = make_unique<FeatureObjectInfo>(shape);
index f927a6a..206807c 100644 (file)
@@ -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<coco::FeatureObject>();
+
+  ASSERT_EQ(feature->layout(), nullptr);
+}