[coco] Introduce Window2D class (#1296)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 3 Sep 2018 05:47:35 +0000 (14:47 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 3 Sep 2018 05:47:35 +0000 (14:47 +0900)
This commit introduces Window2D class which denotes the size of
receptive field that some spatial operator (such as Pooling) uses.

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

diff --git a/contrib/coco/core/include/coco/IR/Window2D.h b/contrib/coco/core/include/coco/IR/Window2D.h
new file mode 100644 (file)
index 0000000..3cb94ce
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __COCO_IR_WINDOW_2D_H__
+#define __COCO_IR_WINDOW_2D_H__
+
+#include <cstdint>
+
+namespace coco
+{
+
+class Window2D
+{
+public:
+  Window2D() : _vertical{1}, _horizontal{1}
+  {
+    // DO NOTHING
+  }
+
+public:
+  Window2D(uint32_t vertical, uint32_t horizontal) : _vertical{vertical}, _horizontal{horizontal}
+  {
+    // DO NOTHING
+  }
+
+public:
+  uint32_t vertical(void) const { return _vertical; }
+  Window2D &vertical(uint32_t value);
+
+public:
+  uint32_t horizontal(void) const { return _horizontal; }
+  Window2D &horizontal(uint32_t value);
+
+private:
+  uint32_t _vertical;
+  uint32_t _horizontal;
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_WINDOW_2D_H__
diff --git a/contrib/coco/core/src/IR/Window2D.cpp b/contrib/coco/core/src/IR/Window2D.cpp
new file mode 100644 (file)
index 0000000..dc6da00
--- /dev/null
@@ -0,0 +1,18 @@
+#include "coco/IR/Window2D.h"
+
+namespace coco
+{
+
+Window2D &Window2D::vertical(uint32_t value)
+{
+  _vertical = value;
+  return (*this);
+}
+
+Window2D &Window2D::horizontal(uint32_t value)
+{
+  _horizontal = value;
+  return (*this);
+}
+
+} // namespace coco
diff --git a/contrib/coco/core/src/IR/Window2D.test.cpp b/contrib/coco/core/src/IR/Window2D.test.cpp
new file mode 100644 (file)
index 0000000..6880ec7
--- /dev/null
@@ -0,0 +1,29 @@
+#include "coco/IR/Window2D.h"
+
+#include <gtest/gtest.h>
+
+TEST(IR_WINDOW_2D, default_constructor)
+{
+  coco::Window2D stride;
+
+  ASSERT_EQ(stride.vertical(), 1);
+  ASSERT_EQ(stride.horizontal(), 1);
+}
+
+TEST(IR_WINDOW_2D, explicit_constructor_4)
+{
+  coco::Window2D stride{2, 3};
+
+  ASSERT_EQ(stride.vertical(), 2);
+  ASSERT_EQ(stride.horizontal(), 3);
+}
+
+TEST(IR_WINDOW_2D, update)
+{
+  coco::Window2D stride;
+
+  stride.vertical(2).horizontal(3);
+
+  ASSERT_EQ(stride.vertical(), 2);
+  ASSERT_EQ(stride.horizontal(), 3);
+}