[coco] Implement 'InputManager' class (#741)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 23 Jul 2018 00:21:09 +0000 (09:21 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 23 Jul 2018 00:21:09 +0000 (09:21 +0900)
This commit implements 'InputManager' class which serves as a Input
(IR entity) factory.

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

diff --git a/contrib/coco/core/include/coco/IR/InputManager.h b/contrib/coco/core/include/coco/IR/InputManager.h
new file mode 100644 (file)
index 0000000..cc43723
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef __COCO_IR_INPUT_MANAGER_H__
+#define __COCO_IR_INPUT_MANAGER_H__
+
+#include "coco/IR/Input.h"
+
+#include "coco/ADT/PtrManager.h"
+
+namespace coco
+{
+
+struct InputManager final : public PtrManager<Input>
+{
+  Input *make(const nncc::core::ADT::tensor::Shape &);
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_INPUT_MANAGER_H__
diff --git a/contrib/coco/core/src/IR/InputManager.cpp b/contrib/coco/core/src/IR/InputManager.cpp
new file mode 100644 (file)
index 0000000..fd15529
--- /dev/null
@@ -0,0 +1,13 @@
+#include "coco/IR/InputManager.h"
+
+#include <nncc/foundation/Memory.h>
+
+namespace coco
+{
+
+Input *InputManager::make(const nncc::core::ADT::tensor::Shape &shape)
+{
+  return take(nncc::foundation::make_unique<Input>(shape));
+}
+
+} // namespace coco
diff --git a/contrib/coco/core/src/IR/InputManager.test.cpp b/contrib/coco/core/src/IR/InputManager.test.cpp
new file mode 100644 (file)
index 0000000..ed5ede8
--- /dev/null
@@ -0,0 +1,14 @@
+#include "coco/IR/InputManager.h"
+
+#include <gtest/gtest.h>
+
+TEST(IR_INPUT_MANAGER, make)
+{
+  const nncc::core::ADT::tensor::Shape shape{1, 3, 3, 1};
+
+  coco::InputManager mgr;
+
+  auto input = mgr.make(shape);
+
+  ASSERT_EQ(input->shape(), shape);
+}