From 94a27dd6b59657935771b3fa3fb3ad0fb2b4a901 Mon Sep 17 00:00:00 2001 From: Jihoon Lee Date: Tue, 23 Nov 2021 20:28:49 +0900 Subject: [PATCH] [nn] InputLayer->InputConnection This patch substitue input layer to input connection while removing props::InputLayer **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Jihoon Lee --- nntrainer/compiler/recurrent_realizer.h | 1 - nntrainer/layers/common_properties.cpp | 3 --- nntrainer/layers/common_properties.h | 41 +++++++++++++++------------------ nntrainer/models/neuralnet.cpp | 6 +++-- nntrainer/models/neuralnet.h | 2 +- 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/nntrainer/compiler/recurrent_realizer.h b/nntrainer/compiler/recurrent_realizer.h index 997c266..eae0fe3 100644 --- a/nntrainer/compiler/recurrent_realizer.h +++ b/nntrainer/compiler/recurrent_realizer.h @@ -26,7 +26,6 @@ namespace nntrainer { namespace props { class UnrollFor; class ReturnSequences; -class InputLayer; class OutputLayer; class RecurrentInput; class RecurrentOutput; diff --git a/nntrainer/layers/common_properties.cpp b/nntrainer/layers/common_properties.cpp index 27b5431..a17021c 100644 --- a/nntrainer/layers/common_properties.cpp +++ b/nntrainer/layers/common_properties.cpp @@ -238,9 +238,6 @@ bool WeightRegularizerConstant::isValid(const float &value) const { return value >= 0.0f; } -InputLayer::InputLayer() : Name() {} -InputLayer::InputLayer(const std::string &name) : Name(name) {} - OutputLayer::OutputLayer() : Name() {} OutputLayer::OutputLayer(const std::string &name) : Name(name) {} diff --git a/nntrainer/layers/common_properties.h b/nntrainer/layers/common_properties.h index 1f84257..aa5c6ce 100644 --- a/nntrainer/layers/common_properties.h +++ b/nntrainer/layers/common_properties.h @@ -165,6 +165,24 @@ public: static constexpr const char *key = "input_layers"; /**< unique key to access */ using prop_tag = connection_prop_tag; /**< property type */ + + /** + * @brief cast operator for property + * @todo deprecate this, this is needed to bridge input_layers(name) <-> input + * connections temporarily + * + * @return std::string value + */ + operator const std::string &() const { return get().getName(); } + + /** + * @brief cast operator for property + * @todo deprecate this, this is needed to bridge input_layers(name) <-> input + * connections temporarily + * + * @return std::string value + */ + operator std::string &() { return get().getName(); } }; /** @@ -584,29 +602,6 @@ public: }; /** - * @brief Input Layer name property which saves a single connection - * (practically, std::vector is used) - * - */ -class InputLayer : public Name { -public: - /** - * @brief Construct InputLayer object - * - */ - InputLayer(); - - /** - * @brief Construct InputLayer with the given name - * - * @param name Name for the input_layers - */ - InputLayer(const std::string &name); - static constexpr const char *key = "input_layers"; - using prop_tag = str_prop_tag; -}; - -/** * @brief Output Layer name property which saves a single connection * (practically, std::vector is used) * diff --git a/nntrainer/models/neuralnet.cpp b/nntrainer/models/neuralnet.cpp index bb5dc6a..e049d57 100644 --- a/nntrainer/models/neuralnet.cpp +++ b/nntrainer/models/neuralnet.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -108,9 +109,10 @@ int NeuralNetwork::compile() { : std::get(model_props); auto &input_layer_prop = - std::get>(model_props); + std::get>(model_props); /// @note label layer might need to be treated in the similar way as well + /// @todo deprecate this instead directly pass connection to the realizer std::vector input_layers = {}; if (!input_layer_prop.empty()) { input_layers = std::vector(input_layer_prop.begin(), @@ -179,7 +181,7 @@ int NeuralNetwork::initialize() { std::get(model_flex_props)); auto &input_layer_prop = - std::get>(model_props); + std::get>(model_props); auto &label_layer_prop = std::get>(model_props); diff --git a/nntrainer/models/neuralnet.h b/nntrainer/models/neuralnet.h index 02ea6bc..2a1f4f0 100644 --- a/nntrainer/models/neuralnet.h +++ b/nntrainer/models/neuralnet.h @@ -489,7 +489,7 @@ private: props::ContinueTrain, props::SaveBestPath, props::MemoryOptimization>; using RigidPropTypes = - std::tuple, + std::tuple, std::vector>; RigidPropTypes model_props; /**< model props */ -- 2.7.4