[loco] EltwiseDiv IR (#6229)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Mon, 5 Aug 2019 23:21:59 +0000 (08:21 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 5 Aug 2019 23:21:59 +0000 (08:21 +0900)
This will introduce canonical EltwiseDiv IR

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
compiler/loco/include/loco/IR/CanonicalNodes.lst
compiler/loco/include/loco/IR/Nodes.h
compiler/loco/src/IR/Nodes.test.cpp
compiler/loco/src/Service/CanonicalShapeInferenceRule.cpp
compiler/loco/src/Service/TypeInference.cpp

index b87b2e2..771dc35 100644 (file)
@@ -14,6 +14,7 @@ CANONICAL_NODE(Conv2D, Conv2D)
 CANONICAL_NODE(DepthwiseConv2D, DepthwiseConv2D)
 CANONICAL_NODE(DepthwiseFilterEncode, DepthwiseFilterEncode)
 CANONICAL_NODE(EltwiseAdd, EltwiseAdd)
+CANONICAL_NODE(EltwiseDiv, EltwiseDiv)
 CANONICAL_NODE(EltwiseMul, EltwiseMul)
 CANONICAL_NODE(EltwiseSub, EltwiseSub)
 CANONICAL_NODE(FeatureBiasAdd, BiasAdd<Domain::Feature>)
index 740cc0d..fd7c051 100644 (file)
@@ -672,6 +672,22 @@ public:
   void rhs(Node *node) { return at(1)->node(node); }
 };
 
+/**
+ * @brief Elementwise Div lhs and rhs
+ */
+class EltwiseDiv final : public CanonicalNodeDef<CanonicalOpcode::EltwiseDiv, FixedArity<2>::Mixin>
+{
+public:
+  EltwiseDiv() = default;
+
+public:
+  Node *lhs(void) const { return at(0)->node(); }
+  void lhs(Node *node) { return at(0)->node(node); }
+
+  Node *rhs(void) const { return at(1)->node(); }
+  void rhs(Node *node) { return at(1)->node(node); }
+};
+
 } // namespace loco
 
 #endif // __LOCO_IR_NODES_H__
index 025ca89..06be67f 100644 (file)
@@ -443,3 +443,10 @@ TEST(EltwiseSubTest, constructor)
 
   SUCCEED();
 }
+
+TEST(EltwiseDivTest, constructor)
+{
+  loco::EltwiseDiv eltwise_div;
+
+  SUCCEED();
+}
index ae1df7b..98d4d75 100644 (file)
@@ -47,6 +47,7 @@ public:
   // TODO Support DepthwiseConv2D
   // TODO Support DepthwiseFilterEncode
   // TODO Support EltwiseAdd
+  // TODO Support EltwiseDiv
   // TODO Support EltwiseMul
   // TODO Support EltwiseSub
   // TODO Support Forward
index 67e3c33..7e70f48 100644 (file)
@@ -101,6 +101,7 @@ struct CanonicalTypeForwardAlgorithm final : public loco::CanonicalNodeVisitor<l
   // TODO Support DepthwiseConv2D
   // TODO Support DepthwiseFilterEncode
   loco::DataType visit(const loco::EltwiseAdd *node) { return loco::dtype_get(node->lhs()); }
+  loco::DataType visit(const loco::EltwiseDiv *node) { return loco::dtype_get(node->lhs()); }
   loco::DataType visit(const loco::EltwiseMul *node) { return loco::dtype_get(node->lhs()); }
   loco::DataType visit(const loco::EltwiseSub *node) { return loco::dtype_get(node->lhs()); }
   // TODO Support Forward