From a7e84f658f8c1dfaffc3e92706e027fbfc72a06d 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: Thu, 4 Oct 2018 10:06:40 +0900 Subject: [PATCH] [coco] Introduce create method for Generic FeatureLayout (#1731) For consistency, this commit introduces create method for Generic FeatureLayout. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/FeatureLayouts.h | 5 ++++- contrib/coco/core/src/IR/FeatureLayouts.cpp | 6 ++++++ contrib/coco/core/src/IR/FeatureObject.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/contrib/coco/core/include/coco/IR/FeatureLayouts.h b/contrib/coco/core/include/coco/IR/FeatureLayouts.h index d5cb869..8244d25 100644 --- a/contrib/coco/core/include/coco/IR/FeatureLayouts.h +++ b/contrib/coco/core/include/coco/IR/FeatureLayouts.h @@ -90,7 +90,7 @@ public: */ class Generic final : public FeatureLayout { -public: +private: Generic(const FeatureShape &shape); public: @@ -114,6 +114,9 @@ private: private: std::vector _content; + +public: + static std::unique_ptr create(const FeatureShape &shape); }; } // namespace FeatureLayouts diff --git a/contrib/coco/core/src/IR/FeatureLayouts.cpp b/contrib/coco/core/src/IR/FeatureLayouts.cpp index 325dcf5..ffe066d 100644 --- a/contrib/coco/core/src/IR/FeatureLayouts.cpp +++ b/contrib/coco/core/src/IR/FeatureLayouts.cpp @@ -156,5 +156,11 @@ void Generic::reorder(const nncc::core::ADT::feature::Layout &l) } } +std::unique_ptr Generic::create(const nncc::core::ADT::feature::Shape &shape) +{ + // NOTE It is impossible to use make_unique here as the constructor is private + return std::unique_ptr{new Generic{shape}}; +} + } // namespace FeatureLayouts } // namespace coco diff --git a/contrib/coco/core/src/IR/FeatureObject.cpp b/contrib/coco/core/src/IR/FeatureObject.cpp index ca1bf5e..b7f2270 100644 --- a/contrib/coco/core/src/IR/FeatureObject.cpp +++ b/contrib/coco/core/src/IR/FeatureObject.cpp @@ -29,7 +29,7 @@ namespace coco FeatureObject::FeatureObject(const nncc::core::ADT::feature::Shape &shape) { - _layout = make_unique(shape); + _layout = FeatureLayouts::Generic::create(shape); } FeatureObject::~FeatureObject() -- 2.7.4