It was replaced by several binary elementwise operations.
Signed-off-by: Sergei Barannikov <s.barannikov@samsung.com>
src/ops/Conv2DOp.cpp
src/ops/DeConv2DOp.cpp
src/ops/DepthwiseConv2DOp.cpp
- src/ops/ElementwiseOp.cpp
src/ops/FullyConnectedOp.cpp
src/ops/GatherOp.cpp
src/ops/GemmOp.cpp
void visit(ops::DeConv2DOp &op) override;
void visit(ops::DepthwiseConv2DOp &op) override;
void visit(ops::DropoutOp &op) override;
- void visit(ops::ElementwiseOp &op) override;
void visit(ops::EluOp &op) override;
void visit(ops::FullyConnectedOp &op) override;
void visit(ops::GatherOp &op) override;
#include "mir/ops/DepthwiseConv2DOp.h"
#include "mir/ops/DivOp.h"
#include "mir/ops/DropoutOp.h"
-#include "mir/ops/ElementwiseOp.h"
#include "mir/ops/EluOp.h"
#include "mir/ops/FullyConnectedOp.h"
#include "mir/ops/GatherOp.h"
HANDLE_OP(depthwiseConv, DepthwiseConv2DOp)
HANDLE_OP(div, DivOp)
HANDLE_OP(dropout, DropoutOp)
-HANDLE_OP(elementwise, ElementwiseOp)
HANDLE_OP(ELU, EluOp)
HANDLE_OP(fullyConnected, FullyConnectedOp)
HANDLE_OP(gather, GatherOp)
+++ /dev/null
-/*
- * Copyright (c) 2018 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_ELEMENTWISE_OP_H_
-#define _MIR_OPS_ELEMENTWISE_OP_H_
-
-#include "mir/Operation.h"
-
-namespace mir
-{
-namespace ops
-{
-
-class ElementwiseOp : public Operation
-{
-public:
- enum class OpType
- {
- mul,
- add,
- max,
- div,
- sub,
- };
-
- /**
- * Apply 2-arg operation elementwise reducing along input tensors
- * @param op_type Type of operation to perform
- * @param num_inputs Number of inputs
- */
- ElementwiseOp(const std::vector<Output *> &args, OpType op_type)
- : Operation(Type::elementwise, args), _op_type(op_type), _needs_broadcast(false)
- {
- inferOutputShapes();
- };
-
- Operation *copyWithInputs(const std::vector<Output *> &inputs) override
- {
- return new ElementwiseOp(inputs, _op_type);
- }
-
- bool getBroadcast() const { return _needs_broadcast; }
-
-private:
- void inferOutputShapes();
-
- OpType _op_type;
- bool _needs_broadcast;
-
-public:
- OpType getOpType() const { return _op_type; }
-};
-
-} // namespace ops
-} // namespace mir
-
-#endif //_MIR_OPS_ELEMENTWISE_OP_H_
_dot_builder.updateWithOp(&op, nodeInfo);
}
-void mir::IrDotDumper::visit(ops::ElementwiseOp &op)
-{
- static const std::map<ops::ElementwiseOp::OpType, const char *> op_types{
- {ops::ElementwiseOp::OpType::mul, "mul"},
- {ops::ElementwiseOp::OpType::add, "add"},
- {ops::ElementwiseOp::OpType::max, "max"},
- {ops::ElementwiseOp::OpType::div, "div"}};
-
- auto node_info = DotIrNodeInfo()
- .withType("ElementwiseOp", op.getName())
- .withInShapes(getInputShapes(op))
- .withOutShapes(getOutputShapes(op))
- .withMisc("Operation", op_types.at(op.getOpType()));
-
- _dot_builder.updateWithOp(&op, node_info);
-}
-
void IrDotDumper::visit(ops::SqueezeOp &op)
{
auto node_info = DotIrNodeInfo()
+++ /dev/null
-/*
- * Copyright (c) 2018 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.
- */
-
-#include "mir/ops/ElementwiseOp.h"
-
-namespace mir
-{
-namespace ops
-{
-
-void ElementwiseOp::inferOutputShapes()
-{
- int max_rank = getInputShape(0).rank();
- size_t max_ind = 0;
- for (size_t i = 0; i < getNumInputs(); i++)
- {
- if (max_rank < getInputShape(i).rank())
- {
- max_rank = getInputShape(i).rank();
- max_ind = i;
- }
- }
- Shape max_shape = getInputShape(max_ind);
- for (size_t i = 0; i < getNumInputs(); i++)
- {
- const auto ¤t_shape = getInputShape(i);
- _needs_broadcast = _needs_broadcast || max_shape != current_shape; // check not equal
- const int rank = current_shape.rank();
- for (int axis = 0; axis < rank; axis++)
- {
- auto current_dim = current_shape.dim(rank - axis - 1);
- // get max for all axes
- if (max_shape.dim(max_rank - axis - 1) == 1 && current_dim != 1)
- {
- max_shape.dim(max_rank - axis - 1) = current_dim;
- }
- else
- {
- assert((current_dim == 1 || current_dim == max_shape.dim(max_rank - axis - 1)) &&
- "Incompatible shapes in broadcast!");
- }
- }
- }
- setOutputShape(0, max_shape);
-}
-
-} // namespace ops
-} // namespace mir
*/
#include "mir/Graph.h"
+#include "mir/ops/AddOp.h"
#include "mir/ops/ReshapeOp.h"
-#include "mir/ops/ElementwiseOp.h"
#include "mir/ops/ResizeOp.h"
#include "mir/ops/SqueezeOp.h"
#include "mir/ops/ReduceOp.h"
auto input = g.create<ops::InputOp>("input1", input_shape);
auto input2 = g.create<ops::InputOp>("input2", input2_shape);
- std::vector<Operation::Output *> add_inputs{input->getOutput(0), input2->getOutput(0)};
- auto add = g.create<ops::ElementwiseOp>("add_1", add_inputs, ops::ElementwiseOp::OpType::add);
+ auto add = g.create<ops::AddOp>("add_1", input->getOutput(0), input2->getOutput(0));
ASSERT_EQ(add->getOutputShape(0), Shape({1, 10, 10, 10}));
}