[neurun] Define TypeInfo class (#2415)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 22 Aug 2018 08:53:13 +0000 (17:53 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 22 Aug 2018 08:53:13 +0000 (17:53 +0900)
Define TypeInfo class to remove data type information from Shape

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/internal/operand/TypeInfo.cc [new file with mode: 0644]
runtimes/neurun/src/internal/operand/TypeInfo.h [new file with mode: 0644]

diff --git a/runtimes/neurun/src/internal/operand/TypeInfo.cc b/runtimes/neurun/src/internal/operand/TypeInfo.cc
new file mode 100644 (file)
index 0000000..d727a52
--- /dev/null
@@ -0,0 +1,19 @@
+#include "TypeInfo.h"
+
+namespace neurun
+{
+namespace internal
+{
+namespace operand
+{
+
+DataType TypeInfo::typeFromOperandCode(OperandCode type)
+{
+  // Now neurun::internal::operand::DataType share same enum value with OperandCode
+  // in NeuralNetworks.h.
+  return static_cast<DataType>(static_cast<uint32_t>(type));
+}
+
+} // namespace operand
+} // namespace internal
+} // namespace neurun
diff --git a/runtimes/neurun/src/internal/operand/TypeInfo.h b/runtimes/neurun/src/internal/operand/TypeInfo.h
new file mode 100644 (file)
index 0000000..a274751
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef __NEURUN_INTERNAL_OPERAND_TYPEINFO_H__
+#define __NEURUN_INTERNAL_OPERAND_TYPEINFO_H__
+
+#include <cstdint>
+
+#include <NeuralNetworks.h>
+
+#include "DataType.h"
+
+namespace neurun
+{
+namespace internal
+{
+namespace operand
+{
+
+class TypeInfo
+{
+public:
+  TypeInfo(OperandCode type, float scale, int32_t offset)
+      : _type(typeFromOperandCode(type)), _scale(scale), _offset(offset)
+  {
+    // DO NOTHING
+  }
+
+public:
+  DataType type() const { return _type; }
+  float scale() const { return _scale; }
+  int32_t offset() const { return _offset; }
+
+private:
+  // Now neurun::internal::operand::DataType share same enum value with OperandCode
+  // in NeuralNetworks.h.
+  // If we don't share same value, we must fix this mapping function.
+  DataType typeFromOperandCode(OperandCode type);
+
+private:
+  DataType _type;
+  float _scale;
+  int32_t _offset;
+};
+} // namespace operand
+} // namespace internal
+} // namespace neurun
+
+#endif // __NEURUN_INTERNAL_OPERAND_TYPEINFO_H__