From ce516890b2d15e32dd70a262c4319d08412a95f9 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 19:01:28 +0900 Subject: [PATCH] [coco] Remove KernelObjectInfo (#1675) 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 --- contrib/coco/core/include/coco/IR/KernelObject.h | 6 ++-- .../include/coco/IR/KernelObjectInfo.forward.h | 27 -------------- .../coco/core/include/coco/IR/KernelObjectInfo.h | 42 ---------------------- contrib/coco/core/src/IR/KernelObject.cpp | 7 ++-- contrib/coco/core/src/IR/KernelObject.test.cpp | 4 +-- contrib/coco/core/src/IR/ObjectManager.cpp | 6 +--- 6 files changed, 7 insertions(+), 85 deletions(-) delete mode 100644 contrib/coco/core/include/coco/IR/KernelObjectInfo.forward.h delete mode 100644 contrib/coco/core/include/coco/IR/KernelObjectInfo.h diff --git a/contrib/coco/core/include/coco/IR/KernelObject.h b/contrib/coco/core/include/coco/IR/KernelObject.h index 32151a2..50f5821 100644 --- a/contrib/coco/core/include/coco/IR/KernelObject.h +++ b/contrib/coco/core/include/coco/IR/KernelObject.h @@ -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 @@ -35,7 +34,7 @@ namespace coco class KernelObject final : public Object { public: - explicit KernelObject(std::unique_ptr &&info); + explicit KernelObject(const nncc::core::ADT::kernel::Shape &shape); public: virtual ~KernelObject(); @@ -56,8 +55,7 @@ public: template void reorder(void) { reorder(LayoutImpl{}); } private: - std::unique_ptr _info; - + nncc::core::ADT::kernel::Shape _shape; std::vector _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 index 3b7bc22..0000000 --- a/contrib/coco/core/include/coco/IR/KernelObjectInfo.forward.h +++ /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 index 73a09c9..0000000 --- a/contrib/coco/core/include/coco/IR/KernelObjectInfo.h +++ /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 - -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__ diff --git a/contrib/coco/core/src/IR/KernelObject.cpp b/contrib/coco/core/src/IR/KernelObject.cpp index 5ef36a9..a24c903 100644 --- a/contrib/coco/core/src/IR/KernelObject.cpp +++ b/contrib/coco/core/src/IR/KernelObject.cpp @@ -15,7 +15,6 @@ */ #include "coco/IR/KernelObject.h" -#include "coco/IR/KernelObjectInfo.h" #include @@ -29,9 +28,9 @@ static nncc::core::ADT::kernel::NCHWLayout l{}; namespace coco { -KernelObject::KernelObject(std::unique_ptr &&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) { diff --git a/contrib/coco/core/src/IR/KernelObject.test.cpp b/contrib/coco/core/src/IR/KernelObject.test.cpp index 2a18eae..e3a6bcc 100644 --- a/contrib/coco/core/src/IR/KernelObject.test.cpp +++ b/contrib/coco/core/src/IR/KernelObject.test.cpp @@ -15,7 +15,6 @@ */ #include "coco/IR/KernelObject.h" -#include "coco/IR/KernelObjectInfo.h" #include @@ -34,8 +33,7 @@ class KernelObjectTest : public ::testing::Test protected: coco::KernelObject *allocate(const kernel::Shape &shape) { - auto info = make_unique(shape); - auto o = new coco::KernelObject{std::move(info)}; + auto o = new coco::KernelObject{shape}; _allocated.emplace_back(o); return o; } diff --git a/contrib/coco/core/src/IR/ObjectManager.cpp b/contrib/coco/core/src/IR/ObjectManager.cpp index 34d9ac1..6936892 100644 --- a/contrib/coco/core/src/IR/ObjectManager.cpp +++ b/contrib/coco/core/src/IR/ObjectManager.cpp @@ -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 @@ -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(shape); - auto info_ptr = info.get(); - - auto kernel = make_unique(std::move(info)); + auto kernel = make_unique(shape); auto kernel_ptr = kernel.get(); modulize(kernel_ptr); -- 2.7.4