[coco] Support Div operation (#2770)
author박천교/On-Device Lab(SR)/Engineer/삼성전자 <ch.bahk@samsung.com>
Tue, 8 Jan 2019 00:49:54 +0000 (09:49 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 8 Jan 2019 00:49:54 +0000 (09:49 +0900)
This commit extends coco IR including Div operation

Signed-off-by: Cheongyo Bahk <ch.bahk@samsung.com>
contrib/coco/core/include/coco/IR/Op.lst
contrib/coco/core/include/coco/IR/Ops.h
contrib/coco/core/src/IR/OpManager.test.cpp
contrib/coco/core/src/IR/Ops.test.cpp

index c79a95e..40cc489 100644 (file)
@@ -336,6 +336,25 @@ public:
 };
 
 /**
+ * @brief Element-wise division
+ *
+ * Div(L, R) is valid only when L and R have identical kind/shape/dtype
+ */
+class Div final : public BinaryOp
+{
+public:
+  explicit Div() = default;
+
+public:
+  Div(const Div &) = delete;
+  Div(Div &&) = delete;
+
+public:
+  Div *asDiv(void) override { return this; }
+  const Div *asDiv(void) const override { return this; }
+};
+
+/**
  * @brief Concatenate two feature maps
  *
  * ConcatF(L, R) requires
index 62aeb53..0af6ac7 100644 (file)
@@ -68,6 +68,13 @@ TEST_F(OpManagerTest, Sub)
   ASSERT_NE(obj, nullptr);
 }
 
+TEST_F(OpManagerTest, Div)
+{
+  auto obj = mgr.create<coco::Div>();
+
+  ASSERT_NE(obj, nullptr);
+}
+
 TEST_F(OpManagerTest, PadF)
 {
   auto op = mgr.create<coco::PadF>();
index 965708b..ae979b2 100644 (file)
@@ -78,6 +78,17 @@ TEST(MulTest, constructor)
 }
 
 /**
+ * Section: Div Op
+ */
+TEST(DivTest, constructor)
+{
+  auto op = make_unique<coco::Div>();
+
+  ASSERT_EQ(op->left(), nullptr);
+  ASSERT_EQ(op->right(), nullptr);
+}
+
+/**
  * Section: Op Helpers
  */
 namespace