[coco] Update Object Link on Object Creation (#1041)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 16 Aug 2018 01:53:32 +0000 (10:53 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 16 Aug 2018 01:53:32 +0000 (10:53 +0900)
This commit revises ObjectManager to update Object Link on object
creation.

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

index fbb51d9..345223c 100644 (file)
@@ -15,13 +15,27 @@ namespace coco
 FeatureObject *ObjectManager::create(const nncc::core::ADT::feature::Shape &shape)
 {
   auto info = make_unique<FeatureObjectInfo>(shape);
-  return take(make_unique<FeatureObject>(std::move(info), _link));
+  auto info_ptr = info.get();
+
+  auto feature = make_unique<FeatureObject>(std::move(info), _link);
+  auto feature_ptr = feature.get();
+
+  _obj_link->set(feature_ptr, info_ptr);
+
+  return take(std::move(feature));
 }
 
 KernelObject *ObjectManager::create(const nncc::core::ADT::kernel::Shape &shape)
 {
   auto info = make_unique<KernelObjectInfo>(shape);
-  return take(make_unique<KernelObject>(std::move(info), _link));
+  auto info_ptr = info.get();
+
+  auto kernel = make_unique<KernelObject>(std::move(info), _link);
+  auto kernel_ptr = kernel.get();
+
+  _obj_link->set(kernel_ptr, info_ptr);
+
+  return take(std::move(kernel));
 }
 
 } // namespace coco
index faa9076..031ee92 100644 (file)
@@ -18,6 +18,7 @@ TEST(IR_OBJECT_MANAGER, create_feature)
   auto o = mgr.create(shape);
 
   ASSERT_EQ(o->shape(), shape);
+  ASSERT_NE(obj_link.find(o), nullptr);
 }
 
 TEST(IR_OBJECT_MANAGER, create_kernel)
@@ -36,4 +37,5 @@ TEST(IR_OBJECT_MANAGER, create_kernel)
   ASSERT_EQ(o->shape().depth(), shape.depth());
   ASSERT_EQ(o->shape().height(), shape.height());
   ASSERT_EQ(o->shape().width(), shape.width());
+  ASSERT_NE(obj_link.find(o), nullptr);
 }