From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 6 Sep 2018 01:32:33 +0000 (+0900) Subject: [coco] Introduce divisor-related members in AvgPool2D (#1371) X-Git-Tag: nncc_backup~1916 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5e14213ab25ec472edcd42bb4ac1840b03fb1c3;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] Introduce divisor-related members in AvgPool2D (#1371) This commit extends AvgPool2D with divisor-related members to allow frontend to deliver diviosr-related information to backend. Signed-off-by: Jonghyun Park --- diff --git a/contrib/coco/core/include/coco/IR/AvgPool2D.h b/contrib/coco/core/include/coco/IR/AvgPool2D.h index 10f0087..7d0192b 100644 --- a/contrib/coco/core/include/coco/IR/AvgPool2D.h +++ b/contrib/coco/core/include/coco/IR/AvgPool2D.h @@ -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 *); 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 *const _op_link; private: + Divisor _divisor = Divisor::Unknown; + Window2D _window; Stride2D _stride; Padding2D _pad; diff --git a/contrib/coco/core/src/IR/AvgPool2D.test.cpp b/contrib/coco/core/src/IR/AvgPool2D.test.cpp index 2417920..c4c2b51 100644 --- a/contrib/coco/core/src/IR/AvgPool2D.test.cpp +++ b/contrib/coco/core/src/IR/AvgPool2D.test.cpp @@ -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); +}