[enco] Introduce ANNConv2D instruction (#2655)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 13 Dec 2018 08:26:18 +0000 (17:26 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 13 Dec 2018 08:26:18 +0000 (17:26 +0900)
This commit introduces ANNConv2D instruction class as a part of extended
coco IR.

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

index a80d64e..e81943f 100644 (file)
 #include <coco/IR.h>
 
 /**
+ * @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,
index 9d8389a..e20cbe4 100644 (file)
 
 #include <gtest/gtest.h>
 
+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;