From 84e0e1809c89bf0d2e27d5849135cc7240c50c72 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, 13 Dec 2018 17:26:18 +0900 Subject: [PATCH] [enco] Introduce ANNConv2D instruction (#2655) This commit introduces ANNConv2D instruction class as a part of extended coco IR. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/coex/IR.h | 53 ++++++++++++++++++++++++++++++++++ contrib/enco/core/src/coex/IR.test.cpp | 10 +++++++ 2 files changed, 63 insertions(+) diff --git a/contrib/enco/core/src/coex/IR.h b/contrib/enco/core/src/coex/IR.h index a80d64e..e81943f 100644 --- a/contrib/enco/core/src/coex/IR.h +++ b/contrib/enco/core/src/coex/IR.h @@ -20,6 +20,59 @@ #include /** + * @brief 2D Convolution through Andoird NN API + * + * TODO Support FusedActivation + */ +class ANNConv2D : public coco::Instr, public coco::Object::Producer, public coco::Object::Consumer +{ +public: + ANNConv2D() : _ofm{this}, _ifm{this}, _ker{this}, _bias{this} + { + // DO NOTHING + } + +public: + coco::Instr *loc(void) override { return this; } + +public: + coco::Object *ofm(void) const { return _ofm.value(); } + void ofm(coco::Object *o) { _ofm.value(o); } + + coco::Object *ifm(void) const { return _ifm.value(); } + void ifm(coco::Object *o) { _ifm.value(o); } + + coco::Object *ker(void) const { return _ker.value(); } + void ker(coco::Object *o) { _ker.value(o); } + + /** + * Currently, this "bias" is a Feature object with channel-wise layout + * + * NOTE This design is subject to change + */ + coco::Object *bias(void) const { return _bias.value(); } + void bias(coco::Object *o) { _bias.value(o); } + +public: + coco::Padding2D *pad(void) { return &_pad; } + const coco::Padding2D *pad(void) const { return &_pad; } + + coco::Stride2D *stride(void) { return &_stride; } + const coco::Stride2D *stride(void) const { return &_stride; } + +private: + coco::Def _ofm; + + coco::Use _ifm; + coco::Use _ker; + coco::Use _bias; + +private: + coco::Padding2D _pad; + coco::Stride2D _stride; +}; + +/** * @brief Concatenate feature maps along "depth" dimension through Andoird NN API */ class ANNDepthConcatF : public coco::Instr, diff --git a/contrib/enco/core/src/coex/IR.test.cpp b/contrib/enco/core/src/coex/IR.test.cpp index 9d8389a..e20cbe4 100644 --- a/contrib/enco/core/src/coex/IR.test.cpp +++ b/contrib/enco/core/src/coex/IR.test.cpp @@ -18,6 +18,16 @@ #include +TEST(IRTest, ANNConv2D_default_constructor) +{ + ANNConv2D ins; + + ASSERT_EQ(ins.ofm(), nullptr); + ASSERT_EQ(ins.ifm(), nullptr); + ASSERT_EQ(ins.ker(), nullptr); + ASSERT_EQ(ins.bias(), nullptr); +} + TEST(IRTest, ANNDepthConcatF_default_constructor) { ANNDepthConcatF ins; -- 2.7.4