From bf5958827211ce69e8b9523466dd6a1593cf77be Mon Sep 17 00:00:00 2001
From: Pavel Iliutchenko/AI Tools Lab /SRR/Engineer/Samsung Electronics
Date: Fri, 8 Nov 2019 15:57:07 +0300
Subject: [PATCH] [mir] Introduce new HardSwish operation (#8790)
* Added hard swish new operation to mir
Signed-off-by: Pavel Iliutchenko
---
compiler/mir/include/mir/OpDefs.h | 1 +
compiler/mir/include/mir/Operations.inc | 1 +
compiler/mir/include/mir/ops/HardSwishOp.h | 44 ++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
create mode 100644 compiler/mir/include/mir/ops/HardSwishOp.h
diff --git a/compiler/mir/include/mir/OpDefs.h b/compiler/mir/include/mir/OpDefs.h
index a57acec..49dcbf6 100644
--- a/compiler/mir/include/mir/OpDefs.h
+++ b/compiler/mir/include/mir/OpDefs.h
@@ -30,6 +30,7 @@
#include "mir/ops/EluOp.h"
#include "mir/ops/FullyConnectedOp.h"
#include "mir/ops/GatherOp.h"
+#include "mir/ops/HardSwishOp.h"
#include "mir/ops/InputOp.h"
#include "mir/ops/LeakyReluOp.h"
#include "mir/ops/MaxOp.h"
diff --git a/compiler/mir/include/mir/Operations.inc b/compiler/mir/include/mir/Operations.inc
index 5ab2096..add349c 100644
--- a/compiler/mir/include/mir/Operations.inc
+++ b/compiler/mir/include/mir/Operations.inc
@@ -31,6 +31,7 @@ HANDLE_OP(div, DivOp)
HANDLE_OP(ELU, EluOp)
HANDLE_OP(fullyConnected, FullyConnectedOp)
HANDLE_OP(gather, GatherOp)
+HANDLE_OP(hardswish, HardSwishOp)
HANDLE_OP(input, InputOp)
HANDLE_OP(leakyReLU, LeakyReluOp)
HANDLE_OP(max, MaxOp)
diff --git a/compiler/mir/include/mir/ops/HardSwishOp.h b/compiler/mir/include/mir/ops/HardSwishOp.h
new file mode 100644
index 0000000..97705b2
--- /dev/null
+++ b/compiler/mir/include/mir/ops/HardSwishOp.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _MIR_OPS_HARD_SWISH_H_
+#define _MIR_OPS_HARD_SWISH_H_
+
+#include "mir/Operation.h"
+
+namespace mir
+{
+namespace ops
+{
+
+class HardSwishOp : public Operation
+{
+public:
+ HardSwishOp(Output *arg) : Operation(Type::hardswish, {arg})
+ {
+ setOutputShape(0, getInputShape(0));
+ }
+
+ Operation *copyWithInputs(const std::vector