[coco] Introduce divisor-related members in AvgPool2D (#1371)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 6 Sep 2018 01:32:33 +0000 (10:32 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 6 Sep 2018 01:32:33 +0000 (10:32 +0900)
This commit extends AvgPool2D with divisor-related members to allow
frontend to deliver diviosr-related information to backend.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/AvgPool2D.h
contrib/coco/core/src/IR/AvgPool2D.test.cpp

index 10f0087..7d0192b 100644 (file)
@@ -15,6 +15,16 @@ namespace coco
 class AvgPool2D : public Op
 {
 public:
+  enum class Divisor
+  {
+    Unknown,
+    // Use the number of elements in each receptive field as a divisor
+    Static,
+    // Use the number of valid (non-padding) elements in each receptive field as a divisor
+    PaddingExcluded
+  };
+
+public:
   explicit AvgPool2D(const PtrLink<Op, Instr> *);
 
 public:
@@ -32,6 +42,10 @@ public:
   const AvgPool2D *asAvgPool2D(void) const override { return this; }
 
 public:
+  Divisor divisor(void) const { return _divisor; }
+  void divisor(const Divisor &divisor) { _divisor = divisor; }
+
+public:
   Window2D *window(void) { return &_window; }
   const Window2D *window(void) const { return &_window; }
 
@@ -50,6 +64,8 @@ private:
   const PtrLink<Op, Instr> *const _op_link;
 
 private:
+  Divisor _divisor = Divisor::Unknown;
+
   Window2D _window;
   Stride2D _stride;
   Padding2D _pad;
index 2417920..c4c2b51 100644 (file)
@@ -48,6 +48,9 @@ TEST_F(AvgPool2DTest, initialization)
   // parent() should be nullptr on construction
   ASSERT_EQ(op->parent(), nullptr);
 
+  // divisor() SHOULD be unknow on construction
+  ASSERT_EQ(immutable_ptr->divisor(), coco::AvgPool2D::Divisor::Unknown);
+
   // window() SHOULD return a valid pointer
   ASSERT_NE(mutable_ptr->window(), nullptr);
   ASSERT_EQ(mutable_ptr->window(), immutable_ptr->window());
@@ -83,3 +86,12 @@ TEST_F(AvgPool2DTest, accept)
   ASSERT_TRUE(mutable_ptr->accept(IsAvgPool2D{}));
   ASSERT_TRUE(immutable_ptr->accept(IsAvgPool2D{}));
 }
+
+TEST_F(AvgPool2DTest, disivor)
+{
+  auto op = allocate();
+
+  op->divisor(coco::AvgPool2D::Divisor::Static);
+
+  ASSERT_EQ(op->divisor(), coco::AvgPool2D::Divisor::Static);
+}