[enco] Introduce ANN Operand ID (#1090)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 20 Aug 2018 07:55:10 +0000 (16:55 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 20 Aug 2018 07:55:10 +0000 (16:55 +0900)
This commit introduces 'ann::OperandID' class to denote an
operand in Android NN network in a type-safe way.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/ANN/IR/OperandID.h [new file with mode: 0644]
contrib/enco/core/src/ANN/IR/OperandID.test.cpp [new file with mode: 0644]

diff --git a/contrib/enco/core/src/ANN/IR/OperandID.h b/contrib/enco/core/src/ANN/IR/OperandID.h
new file mode 100644 (file)
index 0000000..c344084
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __ANN_IR_OPERAND_ID_H__
+#define __ANN_IR_OPERAND_ID_H__
+
+#include <cstdint>
+
+namespace ann
+{
+
+class OperandID
+{
+public:
+  OperandID() : _value{0}
+  {
+    // DO NOTHING
+  }
+
+public:
+  explicit OperandID(uint32_t value) : _value{value}
+  {
+    // DO NOTHING
+  }
+
+public:
+  uint32_t value(void) const { return _value; }
+
+private:
+  uint32_t _value;
+};
+
+} // namespace ann
+
+#endif // __ANN_IR_OPERAND_ID_H__
diff --git a/contrib/enco/core/src/ANN/IR/OperandID.test.cpp b/contrib/enco/core/src/ANN/IR/OperandID.test.cpp
new file mode 100644 (file)
index 0000000..3b1d2a5
--- /dev/null
@@ -0,0 +1,17 @@
+#include "OperandID.h"
+
+#include <gtest/gtest.h>
+
+TEST(ANN_IR_OPERAND_ID, default_constructor)
+{
+  ann::OperandID id;
+
+  ASSERT_EQ(id.value(), 0);
+}
+
+TEST(ANN_IR_OPERAND_ID, explicit_constructor)
+{
+  ann::OperandID id{4};
+
+  ASSERT_EQ(id.value(), 4);
+}