[coco] Remove KernelObjectInfo (#1675)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 28 Sep 2018 10:01:28 +0000 (19:01 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 28 Sep 2018 10:01:28 +0000 (19:01 +0900)
This commit removes KernelObjectInfo class. This class was introduced as
a mean to avoid the use of friend declaration, but this design is no
longer valid.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/KernelObject.h
contrib/coco/core/include/coco/IR/KernelObjectInfo.forward.h [deleted file]
contrib/coco/core/include/coco/IR/KernelObjectInfo.h [deleted file]
contrib/coco/core/src/IR/KernelObject.cpp
contrib/coco/core/src/IR/KernelObject.test.cpp
contrib/coco/core/src/IR/ObjectManager.cpp

index 32151a2..50f5821 100644 (file)
@@ -18,7 +18,6 @@
 #define __COCO_IR_KERNEL_OBJECT_H__
 
 #include "coco/IR/Object.h"
-#include "coco/IR/KernelObjectInfo.forward.h"
 #include "coco/IR/ElemID.h"
 
 #include <nncc/core/ADT/kernel/Shape.h>
@@ -35,7 +34,7 @@ namespace coco
 class KernelObject final : public Object
 {
 public:
-  explicit KernelObject(std::unique_ptr<KernelObjectInfo> &&info);
+  explicit KernelObject(const nncc::core::ADT::kernel::Shape &shape);
 
 public:
   virtual ~KernelObject();
@@ -56,8 +55,7 @@ public:
   template <typename LayoutImpl> void reorder(void) { reorder(LayoutImpl{}); }
 
 private:
-  std::unique_ptr<KernelObjectInfo> _info;
-
+  nncc::core::ADT::kernel::Shape _shape;
   std::vector<ElemID> _map;
 };
 
diff --git a/contrib/coco/core/include/coco/IR/KernelObjectInfo.forward.h b/contrib/coco/core/include/coco/IR/KernelObjectInfo.forward.h
deleted file mode 100644 (file)
index 3b7bc22..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __COCO_IR_KERNEL_OBJECT_INFO_FORWARD_H__
-#define __COCO_IR_KERNEL_OBJECT_INFO_FORWARD_H__
-
-namespace coco
-{
-
-class KernelObjectInfo;
-
-} // namespace coco
-
-#endif // __COCO_IR_KERNEL_OBJECT_INFO_FORWARD_H__
diff --git a/contrib/coco/core/include/coco/IR/KernelObjectInfo.h b/contrib/coco/core/include/coco/IR/KernelObjectInfo.h
deleted file mode 100644 (file)
index 73a09c9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __COCO_IR_KERNEL_OBJECT_INFO_H__
-#define __COCO_IR_KERNEL_OBJECT_INFO_H__
-
-#include <nncc/core/ADT/kernel/Shape.h>
-
-namespace coco
-{
-
-class KernelObjectInfo final
-{
-public:
-  KernelObjectInfo(const nncc::core::ADT::kernel::Shape &shape) : _shape{shape}
-  {
-    // DO NOTHING
-  }
-
-public:
-  const nncc::core::ADT::kernel::Shape &shape(void) const { return _shape; }
-
-private:
-  nncc::core::ADT::kernel::Shape const _shape;
-};
-
-} // namespace coco
-
-#endif // __COCO_IR_KERNEL_OBJECT_INFO_H__
index 5ef36a9..a24c903 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include "coco/IR/KernelObject.h"
-#include "coco/IR/KernelObjectInfo.h"
 
 #include <nncc/core/ADT/kernel/NCHWLayout.h>
 
@@ -29,9 +28,9 @@ static nncc::core::ADT::kernel::NCHWLayout l{};
 namespace coco
 {
 
-KernelObject::KernelObject(std::unique_ptr<KernelObjectInfo> &&info) : _info{std::move(info)}
+KernelObject::KernelObject(const nncc::core::ADT::kernel::Shape &shape) : _shape{shape}
 {
-  _map.resize(nncc::core::ADT::kernel::num_elements(shape()));
+  _map.resize(nncc::core::ADT::kernel::num_elements(shape));
 }
 
 KernelObject::~KernelObject()
@@ -39,7 +38,7 @@ KernelObject::~KernelObject()
   // DO NOTHING
 }
 
-const nncc::core::ADT::kernel::Shape &KernelObject::shape(void) const { return _info->shape(); }
+const nncc::core::ADT::kernel::Shape &KernelObject::shape(void) const { return _shape; }
 
 ElemID &KernelObject::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col)
 {
index 2a18eae..e3a6bcc 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include "coco/IR/KernelObject.h"
-#include "coco/IR/KernelObjectInfo.h"
 
 #include <nncc/foundation/Memory.h>
 
@@ -34,8 +33,7 @@ class KernelObjectTest : public ::testing::Test
 protected:
   coco::KernelObject *allocate(const kernel::Shape &shape)
   {
-    auto info = make_unique<coco::KernelObjectInfo>(shape);
-    auto o = new coco::KernelObject{std::move(info)};
+    auto o = new coco::KernelObject{shape};
     _allocated.emplace_back(o);
     return o;
   }
index 34d9ac1..6936892 100644 (file)
@@ -19,7 +19,6 @@
 #include "coco/IR/FeatureObject.h"
 #include "coco/IR/FeatureObjectInfo.h"
 #include "coco/IR/KernelObject.h"
-#include "coco/IR/KernelObjectInfo.h"
 
 #include <nncc/foundation/Memory.h>
 
@@ -50,10 +49,7 @@ FeatureObject *ObjectManager::create(const nncc::core::ADT::feature::Shape &shap
 
 KernelObject *ObjectManager::create(const nncc::core::ADT::kernel::Shape &shape)
 {
-  auto info = make_unique<KernelObjectInfo>(shape);
-  auto info_ptr = info.get();
-
-  auto kernel = make_unique<KernelObject>(std::move(info));
+  auto kernel = make_unique<KernelObject>(shape);
   auto kernel_ptr = kernel.get();
 
   modulize(kernel_ptr);