[coco] Introduce FeatureShape alias (#1727)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 2 Oct 2018 10:03:15 +0000 (19:03 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 2 Oct 2018 10:03:15 +0000 (19:03 +0900)
This commit introduces FeatureShape type in coco (which is an alias of
nncc::core::ADT::feature::Shape) for ease of use.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/FeatureLayout.h
contrib/coco/core/include/coco/IR/FeatureLayouts.h
contrib/coco/core/include/coco/IR/FeatureObject.h
contrib/coco/core/include/coco/IR/FeatureShape.h [new file with mode: 0644]
contrib/coco/core/include/coco/IR/ObjectManager.h

index c8544a0..a24fe0c 100644 (file)
@@ -18,8 +18,7 @@
 #define __COCO_IR_FEATURE_LAYOUT_H__
 
 #include "coco/IR/ElemID.h"
-
-#include <nncc/core/ADT/feature/Shape.h>
+#include "coco/IR/FeatureShape.h"
 
 namespace coco
 {
@@ -41,7 +40,7 @@ struct FeatureLayout
   virtual const ID *id(void) const = 0;
 
   virtual uint32_t batch(void) const = 0;
-  virtual const nncc::core::ADT::feature::Shape &shape(void) const = 0;
+  virtual const FeatureShape &shape(void) const = 0;
 
   virtual ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const = 0;
 };
index 54f7ad7..d5cb869 100644 (file)
@@ -35,7 +35,7 @@ namespace FeatureLayouts
 class BCHW final : public FeatureLayout
 {
 private:
-  BCHW(uint32_t batch, const nncc::core::ADT::feature::Shape &shape) : _batch{batch}, _shape{shape}
+  BCHW(uint32_t batch, const FeatureShape &shape) : _batch{batch}, _shape{shape}
   {
     // DO NOTHING
   }
@@ -45,16 +45,16 @@ public:
   const FeatureLayout::ID *id(void) const override { return uid(); }
 
   uint32_t batch(void) const override { return _batch; }
-  const nncc::core::ADT::feature::Shape &shape(void) const override { return _shape; }
+  const FeatureShape &shape(void) const override { return _shape; }
 
   ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const override;
 
 private:
   uint32_t _batch;
-  nncc::core::ADT::feature::Shape _shape;
+  FeatureShape _shape;
 
 public:
-  static std::unique_ptr<BCHW> create(const nncc::core::ADT::feature::Shape &shape);
+  static std::unique_ptr<BCHW> create(const FeatureShape &shape);
 };
 
 /**
@@ -63,7 +63,7 @@ public:
 class BHWC : public coco::FeatureLayout
 {
 private:
-  BHWC(uint32_t batch, const nncc::core::ADT::feature::Shape &shape) : _batch{batch}, _shape{shape}
+  BHWC(uint32_t batch, const FeatureShape &shape) : _batch{batch}, _shape{shape}
   {
     // DO NOTHING
   }
@@ -73,16 +73,16 @@ public:
   const FeatureLayout::ID *id(void) const override { return uid(); }
 
   uint32_t batch(void) const override { return _batch; }
-  const nncc::core::ADT::feature::Shape &shape(void) const override { return _shape; }
+  const FeatureShape &shape(void) const override { return _shape; }
 
   coco::ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const override;
 
 private:
   uint32_t _batch;
-  nncc::core::ADT::feature::Shape _shape;
+  FeatureShape _shape;
 
 public:
-  static std::unique_ptr<BHWC> create(const nncc::core::ADT::feature::Shape &shape);
+  static std::unique_ptr<BHWC> create(const FeatureShape &shape);
 };
 
 /**
@@ -91,14 +91,14 @@ public:
 class Generic final : public FeatureLayout
 {
 public:
-  Generic(const nncc::core::ADT::feature::Shape &shape);
+  Generic(const FeatureShape &shape);
 
 public:
   static const FeatureLayout::ID *uid(void);
   const FeatureLayout::ID *id(void) const override { return uid(); }
 
   uint32_t batch(void) const override { return _batch; }
-  const nncc::core::ADT::feature::Shape &shape(void) const override { return _shape; }
+  const FeatureShape &shape(void) const override { return _shape; }
 
   ElemID &at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col);
   ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const override;
@@ -110,7 +110,7 @@ private:
 
 private:
   uint32_t _batch;
-  nncc::core::ADT::feature::Shape _shape;
+  FeatureShape _shape;
 
 private:
   std::vector<ElemID> _content;
index e618526..62cf42c 100644 (file)
 #define __COCO_IR_FEATURE_OBJECT_H__
 
 #include "coco/IR/Object.h"
+#include "coco/IR/FeatureShape.h"
 #include "coco/IR/FeatureLayout.h"
 #include "coco/IR/ElemID.h"
 
-#include <nncc/core/ADT/feature/Shape.h>
 #include <nncc/core/ADT/feature/Layout.h>
 
 #include <vector>
@@ -36,7 +36,7 @@ class FeatureObject final : public Object
 {
 public:
   FeatureObject() = default;
-  explicit FeatureObject(const nncc::core::ADT::feature::Shape &shape);
+  explicit FeatureObject(const FeatureShape &shape);
 
 public:
   ~FeatureObject();
@@ -49,7 +49,7 @@ public:
   const FeatureObject *asFeature(void) const override { return this; }
 
 public:
-  const nncc::core::ADT::feature::Shape &shape(void) const;
+  const FeatureShape &shape(void) const;
 
 public:
   ElemID at(uint32_t ch, uint32_t row, uint32_t col) const;
diff --git a/contrib/coco/core/include/coco/IR/FeatureShape.h b/contrib/coco/core/include/coco/IR/FeatureShape.h
new file mode 100644 (file)
index 0000000..6ef5dc1
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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_FEATURE_SHAPE_H__
+#define __COCO_IR_FEATURE_SHAPE_H__
+
+#include <nncc/core/ADT/feature/Shape.h>
+
+namespace coco
+{
+
+using FeatureShape = nncc::core::ADT::feature::Shape;
+
+} // namespace coco
+
+#endif // __COCO_IR_FEATURE_SHAPE_H__
index 585ca03..e23abbb 100644 (file)
@@ -18,6 +18,7 @@
 #define __COCO_IR_OBJECT_MANAGER_H__
 
 #include "coco/IR/Object.h"
+#include "coco/IR/FeatureShape.h"
 #include "coco/IR/FeatureObject.forward.h"
 #include "coco/IR/KernelObject.forward.h"
 #include "coco/IR/EntityBuilder.h"
@@ -25,7 +26,6 @@
 #include "coco/ADT/PtrManager.h"
 #include "coco/ADT/PtrLink.h"
 
-#include <nncc/core/ADT/feature/Shape.h>
 #include <nncc/core/ADT/kernel/Shape.h>
 
 namespace coco
@@ -37,7 +37,7 @@ public:
   ObjectManager(Module *m = nullptr) { module(m); }
 
 public:
-  FeatureObject *create(const nncc::core::ADT::feature::Shape &shape);
+  FeatureObject *create(const FeatureShape &shape);
   KernelObject *create(const nncc::core::ADT::kernel::Shape &shape);
 
   template <typename T> T *create(void);