[caffegen] Add 'LayerContext' class (#99)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 19 Apr 2018 05:15:54 +0000 (14:15 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 19 Apr 2018 05:15:54 +0000 (14:15 +0900)
This commit adds 'LayerContext' class which maintains a sequence of
'Layer' objects.

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

diff --git a/contrib/caffegen/include/LayerContext.h b/contrib/caffegen/include/LayerContext.h
new file mode 100644 (file)
index 0000000..b00b6f6
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef __LAYER_CONTEXT_H__
+#define __LAYER_CONTEXT_H__
+
+#include "Layer.h"
+
+#include <vector>
+#include <memory>
+#include <cstdint>
+
+class LayerContext
+{
+public:
+  uint32_t size(void) const;
+
+public:
+  Layer &at(uint32_t n);
+  const Layer &at(uint32_t n) const;
+
+public:
+  LayerContext &append(std::unique_ptr<Layer> &&l);
+
+private:
+  std::vector<std::unique_ptr<Layer>> _layers;
+};
+
+#endif // __LAYER_CONTEXT_H__
diff --git a/contrib/caffegen/src/LayerContext.cpp b/contrib/caffegen/src/LayerContext.cpp
new file mode 100644 (file)
index 0000000..943e298
--- /dev/null
@@ -0,0 +1,11 @@
+#include "LayerContext.h"
+
+uint32_t LayerContext::size(void) const { return _layers.size(); };
+
+Layer &LayerContext::at(uint32_t n) { return *(_layers.at(n)); }
+const Layer &LayerContext::at(uint32_t n) const { return *(_layers.at(n)); }
+
+LayerContext &LayerContext::append(std::unique_ptr<Layer> &&l)
+{
+  _layers.emplace_back(std::move(l));
+}