[coco] Add 'OutputManager' class (#744)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 23 Jul 2018 01:07:43 +0000 (10:07 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 23 Jul 2018 01:07:43 +0000 (10:07 +0900)
This commit adds 'OutputManager' class which serves as 'Output' object
factory.

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

diff --git a/contrib/coco/core/include/coco/IR/OutputManager.h b/contrib/coco/core/include/coco/IR/OutputManager.h
new file mode 100644 (file)
index 0000000..4371cfb
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef __COCO_IR_OUTPUT_MANAGER_H__
+#define __COCO_IR_OUTPUT_MANAGER_H__
+
+#include "coco/IR/Output.h"
+
+#include "coco/ADT/PtrManager.h"
+
+namespace coco
+{
+
+struct OutputManager final : public PtrManager<Output>
+{
+  Output *make(const nncc::core::ADT::tensor::Shape &);
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_OUTPUT_MANAGER_H__
diff --git a/contrib/coco/core/src/IR/OutputManager.cpp b/contrib/coco/core/src/IR/OutputManager.cpp
new file mode 100644 (file)
index 0000000..97d8ae1
--- /dev/null
@@ -0,0 +1,13 @@
+#include "coco/IR/OutputManager.h"
+
+#include <nncc/foundation/Memory.h>
+
+namespace coco
+{
+
+Output *OutputManager::make(const nncc::core::ADT::tensor::Shape &shape)
+{
+  return take(nncc::foundation::make_unique<Output>(shape));
+}
+
+} // namespace coco
diff --git a/contrib/coco/core/src/IR/OutputManager.test.cpp b/contrib/coco/core/src/IR/OutputManager.test.cpp
new file mode 100644 (file)
index 0000000..2d70fe6
--- /dev/null
@@ -0,0 +1,14 @@
+#include "coco/IR/OutputManager.h"
+
+#include <gtest/gtest.h>
+
+TEST(IR_OUTPUT_MANAGER, make)
+{
+  const nncc::core::ADT::tensor::Shape shape{1, 3, 3, 1};
+
+  coco::OutputManager mgr;
+
+  auto output = mgr.make(shape);
+
+  ASSERT_EQ(output->shape(), shape);
+}