From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 11 Oct 2018 00:43:54 +0000 (+0900) Subject: [coco] PadF as a Op tree node (#1817) X-Git-Tag: nncc_backup~1566 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f12024b34808eb5f5b11461936ab3270dcb07630;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] PadF as a Op tree node (#1817) With this commit, PadF may serve as a node of Op tree. Signed-off-by: Jonghyun Park --- diff --git a/contrib/coco/core/include/coco/IR/PadF.h b/contrib/coco/core/include/coco/IR/PadF.h index fb6cf38..4e3229d 100644 --- a/contrib/coco/core/include/coco/IR/PadF.h +++ b/contrib/coco/core/include/coco/IR/PadF.h @@ -18,6 +18,7 @@ #define __COCO_IR_PAD_F_H__ #include "coco/IR/Op.h" +#include "coco/IR/Part.h" #include "coco/IR/Padding2D.h" namespace coco @@ -43,10 +44,18 @@ public: const PadF *asPadF(void) const override { return this; } public: + Op *arg(void) const { return _arg.child(); } + void arg(Op *arg) { _arg.child(arg); } + +public: Padding2D *pad(void) { return &_pad; } const Padding2D *pad(void) const { return &_pad; } private: + // @brief An argument of PadF operation (= IFM) + Part _arg; + +private: Padding2D _pad; }; diff --git a/contrib/coco/core/src/IR/PadF.cpp b/contrib/coco/core/src/IR/PadF.cpp index 8604165..2b79b86 100644 --- a/contrib/coco/core/src/IR/PadF.cpp +++ b/contrib/coco/core/src/IR/PadF.cpp @@ -19,7 +19,7 @@ namespace coco { -PadF::PadF() +PadF::PadF() : _arg{this} { // DO NOTHING } @@ -28,6 +28,15 @@ std::set PadF::uses(void) const { // NOTE PadF accesses no object std::set res; + + if (auto ifm = arg()) + { + for (auto obj : ifm->uses()) + { + res.insert(obj); + } + } + return res; } diff --git a/contrib/coco/core/src/IR/PadF.test.cpp b/contrib/coco/core/src/IR/PadF.test.cpp index 28ffedd..670213c 100644 --- a/contrib/coco/core/src/IR/PadF.test.cpp +++ b/contrib/coco/core/src/IR/PadF.test.cpp @@ -58,6 +58,9 @@ TEST_F(PadFTest, initialization) // parent() should be nullptr on construction ASSERT_EQ(op->parent(), nullptr); + // arg() should be nullptr on construction + ASSERT_EQ(op->arg(), nullptr); + // pad() should be a valid ASSERT_NE(op->pad(), nullptr); }