Added getter of opcode name in string format
Signed-off-by: Efimov Alexander <a.efimov@samsung.com>
std::deque<Output> _outputs;
};
+/**
+ * @return the opcode of operation in string format, like "Add", "Conv2d", etc.
+ */
+const std::string &getTypeName(Operation::Type type);
+
} // namespace mir
#endif //_MIR_OPERATION_H_
}
}
+const std::string &getTypeName(Operation::Type type)
+{
+ switch (type)
+ {
+#define HANDLE_OP(OpType, OpClass) \
+ case Operation::Type::OpType: \
+ { \
+ static const std::string name(#OpType); \
+ return name; \
+ }
+#include "mir/Operations.inc"
+#undef HANDLE_OP
+ }
+ throw std::runtime_error("unexpected opcode");
+}
+
} // namespace mir
ops::ConcatOp op_n3({input1.getOutput(0), input2.getOutput(0)}, -3);
ASSERT_EQ(op_n3.getAxis(), 0);
}
+
+TEST(Operation, OpNameTest)
+{
+#define HANDLE_OP(OpType, OpClass) ASSERT_EQ(getTypeName(Operation::Type::OpType), #OpType);
+#include "mir/Operations.inc"
+#undef HANDLE_OP
+}