From 91e78e91e9340679235dde3ff46f5cab200c5f99 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, 12 Oct 2018 16:55:52 +0900 Subject: [PATCH] [coco] Remove unused FeatureInstr (#1851) This commit removes codes related with FeatureInstr from coco. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Instr.h | 38 +---------- contrib/coco/core/src/IR/Instr.cpp | 39 ------------ contrib/coco/core/src/IR/Instr.test.cpp | 102 ------------------------------ 3 files changed, 1 insertion(+), 178 deletions(-) delete mode 100644 contrib/coco/core/src/IR/Instr.test.cpp diff --git a/contrib/coco/core/include/coco/IR/Instr.h b/contrib/coco/core/include/coco/IR/Instr.h index 1e56676..8cdf3b8 100644 --- a/contrib/coco/core/include/coco/IR/Instr.h +++ b/contrib/coco/core/include/coco/IR/Instr.h @@ -193,45 +193,9 @@ private: } // namespace coco +// TODO Remove #include below #include "coco/IR/FeatureObject.h" #include "coco/IR/Use.h" #include "coco/IR/Def.h" -/** - * @brief Explicit computation step that emits a feature map from another feature map - * - * TODO Decide source code layout policy and extract this class if necessary - */ -namespace coco -{ - -class FeatureInstr : public Instr, public Object::Producer, public Object::Consumer -{ -public: - FeatureInstr(); - -public: - FeatureInstr(const FeatureInstr &) = delete; - FeatureInstr(FeatureInstr &&) = delete; - -public: - virtual ~FeatureInstr() = default; - -private: - Use _ifm; - -public: - FeatureObject *ifm(void) const; - void ifm(FeatureObject *ifm); - -private: - Def _ofm; - -public: - FeatureObject *ofm(void) const; - void ofm(FeatureObject *ofm); -}; - -} // namespace coco - #endif // __COCO_IR_INSTR_H__ diff --git a/contrib/coco/core/src/IR/Instr.cpp b/contrib/coco/core/src/IR/Instr.cpp index 2e94c2a..9f000ba 100644 --- a/contrib/coco/core/src/IR/Instr.cpp +++ b/contrib/coco/core/src/IR/Instr.cpp @@ -54,42 +54,3 @@ template <> void DLinkedList::leaving(Block *, Instr *curr_ins) template <> InstrList *DLinkedList::head(Block *b) { return b->instr(); } } // namespace coco - -// -// FeatureInstr -// -namespace coco -{ - -FeatureInstr::FeatureInstr() : _ifm{this}, _ofm{this} -{ - // DO NOTHING -} - -void FeatureInstr::ifm(FeatureObject *ifm) { _ifm.value(ifm); } - -FeatureObject *FeatureInstr::ifm(void) const -{ - if (auto obj = _ifm.value()) - { - assert(obj->asFeature() != nullptr); - return obj->asFeature(); - } - - return nullptr; -} - -void FeatureInstr::ofm(FeatureObject *ofm) { _ofm.value(ofm); } - -FeatureObject *FeatureInstr::ofm(void) const -{ - if (auto obj = _ofm.value()) - { - assert(obj->asFeature() != nullptr); - return obj->asFeature(); - } - - return nullptr; -} - -} // namespace coco diff --git a/contrib/coco/core/src/IR/Instr.test.cpp b/contrib/coco/core/src/IR/Instr.test.cpp deleted file mode 100644 index 955c2da..0000000 --- a/contrib/coco/core/src/IR/Instr.test.cpp +++ /dev/null @@ -1,102 +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. - */ - -#include "coco/IR/Instr.h" -#include "coco/IR/ObjectManager.h" -#include "coco/IR/OpManager.h" - -#include - -namespace -{ -class InstrTest : public ::testing::Test -{ -public: - virtual ~InstrTest() = default; - -protected: - coco::ObjectManager obj_mgr; - coco::OpManager op_mgr; -}; -} // namespace - -namespace -{ -class FeatureInstrTest : public InstrTest -{ -public: - virtual ~FeatureInstrTest() = default; -}; -} // namespace - -namespace -{ -namespace mock -{ -struct FeatureInstr : public coco::FeatureInstr -{ -public: - std::set reads(void) const override { return std::set(); } - std::set updates(void) const override { return std::set(); } - -public: - coco::Instr *loc(void) override { return this; } -}; -} // namespace mock -} // namespace - -TEST_F(FeatureInstrTest, ctor) -{ - ::mock::FeatureInstr ins; - - // IFM and OFM should be initialized as nullptr - ASSERT_EQ(ins.ifm(), nullptr); - ASSERT_EQ(ins.ofm(), nullptr); -} - -TEST_F(FeatureInstrTest, ifm_update) -{ - // Prepare a feature object for testing - auto obj = obj_mgr.create(nncc::core::ADT::feature::Shape{1, 3, 3}); - - // Test 'FeatureInstr' class - ::mock::FeatureInstr ins; - - // 'ifm(FeatureObject *)' method should affect 'ifm()' method - ins.ifm(obj); - ASSERT_EQ(ins.ifm(), obj); - - { - auto consumers = coco::consumers(obj); - ASSERT_EQ(consumers.size(), 1); - ASSERT_NE(consumers.find(&ins), consumers.end()); - } -} - -TEST_F(FeatureInstrTest, ofm_update) -{ - // Prepare a feature object for testing - auto obj = obj_mgr.create(nncc::core::ADT::feature::Shape{1, 3, 3}); - - // Test 'FeatureInstr' class - ::mock::FeatureInstr ins; - - // 'ofm(FeatureObject *)' method should affect 'ofm()' method - ins.ofm(obj); - ASSERT_EQ(ins.ofm(), obj); - - ASSERT_EQ(coco::producer(obj), &ins); -} -- 2.7.4