From 9806fa60fb969dedf8ab3b4f83c910295a054da6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 19 Apr 2018 14:15:54 +0900 Subject: [PATCH] [caffegen] Add 'LayerContext' class (#99) This commit adds 'LayerContext' class which maintains a sequence of 'Layer' objects. Signed-off-by: Jonghyun Park --- contrib/caffegen/include/LayerContext.h | 26 ++++++++++++++++++++++++++ contrib/caffegen/src/LayerContext.cpp | 11 +++++++++++ 2 files changed, 37 insertions(+) create mode 100644 contrib/caffegen/include/LayerContext.h create mode 100644 contrib/caffegen/src/LayerContext.cpp diff --git a/contrib/caffegen/include/LayerContext.h b/contrib/caffegen/include/LayerContext.h new file mode 100644 index 0000000..b00b6f6 --- /dev/null +++ b/contrib/caffegen/include/LayerContext.h @@ -0,0 +1,26 @@ +#ifndef __LAYER_CONTEXT_H__ +#define __LAYER_CONTEXT_H__ + +#include "Layer.h" + +#include +#include +#include + +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 &&l); + +private: + std::vector> _layers; +}; + +#endif // __LAYER_CONTEXT_H__ diff --git a/contrib/caffegen/src/LayerContext.cpp b/contrib/caffegen/src/LayerContext.cpp new file mode 100644 index 0000000..943e298 --- /dev/null +++ b/contrib/caffegen/src/LayerContext.cpp @@ -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 &&l) +{ + _layers.emplace_back(std::move(l)); +} -- 2.7.4