[locomotiv] Simplify ReLU6 implementation (#7506)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 17 Sep 2019 04:55:27 +0000 (13:55 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 17 Sep 2019 04:55:27 +0000 (13:55 +0900)
Let's make ReLU6 similar to other element-wise unary operations.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
compiler/locomotiv/src/Node/ReLU6.cpp

index 7da8926..586c015 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "NodeExecution.h"
 
+// TODO Remove deprecated code
+#if 0
 #include "NodeDataImpl.h"
 #include "NodeDomain.h"
 #include "Validation.h"
@@ -31,6 +33,7 @@ using nncc::core::ADT::tensor::make_buffer;
 
 #include <cassert>
 #include <stdexcept>
+#endif
 
 namespace
 {
@@ -44,6 +47,8 @@ namespace locomotiv
 
 void NodeExecution::execute(loco::ReLU6 *relu6)
 {
+// TODO Remove deprecated code
+#if 0
   auto input_data = annot_data(relu6->input());
 
   validate(input_data, "Input not ready");
@@ -76,6 +81,16 @@ void NodeExecution::execute(loco::ReLU6 *relu6)
   assert(relu6_data != nullptr);
   annot_data(relu6, std::move(relu6_data));
   annot_domain(relu6, annot_domain(relu6->input()));
+#endif
+
+  struct Func final : public UnaryFunc
+  {
+    float apply(float v) const final { return relu6_ew(v); }
+  };
+
+  Func f;
+
+  eltwise_unary(relu6, f);
 }
 
 } // namespace locomotiv