[mir] Introduce new HardSwish operation (#8790)
authorPavel Iliutchenko/AI Tools Lab /SRR/Engineer/Samsung Electronics <p.iliutchenk@samsung.com>
Fri, 8 Nov 2019 12:57:07 +0000 (15:57 +0300)
committerAlexander Efimov/AI Tools Lab/./Samsung Electronics <a.efimov@samsung.com>
Fri, 8 Nov 2019 12:57:07 +0000 (15:57 +0300)
* Added hard swish new operation to mir

Signed-off-by: Pavel Iliutchenko <p.iliutchenk@samsung.com>
compiler/mir/include/mir/OpDefs.h
compiler/mir/include/mir/Operations.inc
compiler/mir/include/mir/ops/HardSwishOp.h [new file with mode: 0644]

index a57acec..49dcbf6 100644 (file)
@@ -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"
index 5ab2096..add349c 100644 (file)
@@ -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 (file)
index 0000000..97705b2
--- /dev/null
@@ -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<Output *> &inputs) override
+  {
+    return new HardSwishOp(inputs[0]);
+  }
+};
+
+} // namespace ops
+} // namespace mir
+
+#endif //_MIR_OPS_HARD_SWISH_H_