[coco] Add 'KernelObject' class (#743)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 23 Jul 2018 00:51:00 +0000 (09:51 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 23 Jul 2018 00:51:00 +0000 (09:51 +0900)
This commit adds 'KernelObject' class which allows us to encode convolution
kernel values in IR.

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

diff --git a/contrib/coco/core/include/coco/IR/KernelObject.h b/contrib/coco/core/include/coco/IR/KernelObject.h
new file mode 100644 (file)
index 0000000..7383874
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef __COCO_IR_KERNEL_OBJECT_H__
+#define __COCO_IR_KERNEL_OBJECT_H__
+
+#include "coco/IR/Object.h"
+
+#include <nncc/core/ADT/kernel/Shape.h>
+
+namespace coco
+{
+
+/***
+ * @brief Convolution Kernel (in CNN) values
+ */
+class KernelObject final : public Object
+{
+public:
+  explicit KernelObject(const nncc::core::ADT::kernel::Shape &shape);
+
+public:
+  virtual ~KernelObject() = default;
+
+public:
+  const nncc::core::ADT::kernel::Shape &shape(void) const { return _shape; }
+
+private:
+  nncc::core::ADT::kernel::Shape const _shape;
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_KERNEL_OBJECT_H__
diff --git a/contrib/coco/core/src/IR/KernelObject.cpp b/contrib/coco/core/src/IR/KernelObject.cpp
new file mode 100644 (file)
index 0000000..a1e4cda
--- /dev/null
@@ -0,0 +1,11 @@
+#include "coco/IR/KernelObject.h"
+
+namespace coco
+{
+
+KernelObject::KernelObject(const nncc::core::ADT::kernel::Shape &shape) : _shape{shape}
+{
+  // DO NOTHING
+}
+
+} // namespace coco
diff --git a/contrib/coco/core/src/IR/KernelObject.test.cpp b/contrib/coco/core/src/IR/KernelObject.test.cpp
new file mode 100644 (file)
index 0000000..4cc6e44
--- /dev/null
@@ -0,0 +1,15 @@
+#include "coco/IR/KernelObject.h"
+
+#include <gtest/gtest.h>
+
+TEST(IR_KERNEL_OBJECT, ctor_should_set_size)
+{
+  const nncc::core::ADT::kernel::Shape shape{1, 1, 3, 3};
+  const coco::KernelObject o{shape};
+
+  // TODO Use ASSERT_EQ(o.shape(), shape) (operator== overload is not yet available)
+  ASSERT_EQ(o.shape().depth(), shape.depth());
+  ASSERT_EQ(o.shape().count(), shape.count());
+  ASSERT_EQ(o.shape().height(), shape.height());
+  ASSERT_EQ(o.shape().width(), shape.width());
+}