[loco] ReLU6 node (#4077)
author채성우/On-Device Lab(SR)/Engineer/삼성전자 <sw4670.chae@samsung.com>
Wed, 3 Jul 2019 09:12:48 +0000 (18:12 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 3 Jul 2019 09:12:48 +0000 (18:12 +0900)
This commit introduce ReLU6 node to loco.

Signed-off-by: seongwoo <sw4670.chae@samsung.com>
contrib/loco/include/loco/IR/CanonicalNodes.lst
contrib/loco/include/loco/IR/Nodes.h
contrib/loco/src/IR/Nodes.test.cpp

index bc119d9..ff1dee8 100644 (file)
@@ -22,5 +22,6 @@ CANONICAL_NODE(Push, Push)
 // WARN Pull may be excluded from canoncial dialect in the future
 CANONICAL_NODE(Pull, Pull)
 CANONICAL_NODE(ReLU, ReLU)
+CANONICAL_NODE(ReLU6, ReLU6)
 CANONICAL_NODE(TensorConcat, TensorConcat)
 CANONICAL_NODE(TensorBiasAdd, BiasAdd<Domain::Tensor>)
index 93559f5..29778cd 100644 (file)
@@ -89,6 +89,19 @@ public:
 };
 
 /**
+ * @brief Create a new value that rectifies its input capping the units at 6.
+ */
+class ReLU6 final : public FixedArityNode<1, CanonicalNodeImpl<CanonicalOpcode::ReLU6>>
+{
+public:
+  ReLU6() = default;
+
+public:
+  Node *input(void) const { return at(0)->node(); }
+  void input(Node *node) { at(0)->node(node); }
+};
+
+/**
  * @brief Create a value from constant byte array
  *
  * @note ConstGen assumes "lexical memory layout".
index 5d32713..14f6d2b 100644 (file)
@@ -90,6 +90,16 @@ TEST(ReLUTest, constructor)
   ASSERT_EQ(relu_node.input(), nullptr);
 }
 
+TEST(ReLU6Test, constructor)
+{
+  loco::ReLU6 relu6_node;
+
+  ASSERT_EQ(relu6_node.dialect(), loco::CanonicalDialect::get());
+  ASSERT_EQ(relu6_node.opcode(), loco::CanonicalOpcode::ReLU6);
+
+  ASSERT_EQ(relu6_node.input(), nullptr);
+}
+
 TEST(ConstGenTest, constructor)
 {
   loco::ConstGen constgen_node;