[optimizer] prepare for learning rate scheduler
authorParichay Kapoor <pk.kapoor@samsung.com>
Thu, 9 Dec 2021 11:52:48 +0000 (20:52 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 17 Feb 2022 04:14:41 +0000 (13:14 +0900)
Move declaration and definition of learning rate related properties out
to common properties from optimizer_impl class.

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
nntrainer/layers/common_properties.h
nntrainer/optimizers/optimizer_impl.cpp
nntrainer/optimizers/optimizer_impl.h

index e67c5c3..7bef681 100644 (file)
@@ -1109,6 +1109,37 @@ public:
   using prop_tag = float_prop_tag; /**< property type */
 };
 
+/**
+ * @brief Learning Rate props
+ *
+ */
+class LearningRate : public Property<float> {
+public:
+  static constexpr const char *key =
+    "learning_rate";               /**< unique key to access */
+  using prop_tag = float_prop_tag; /**< property type */
+};
+
+/**
+ * @brief Decay rate property
+ *
+ */
+class DecayRate : public Property<float> {
+public:
+  static constexpr const char *key = "decay_rate"; /**< unique key to access */
+  using prop_tag = float_prop_tag;                 /**< property type */
+};
+
+/**
+ * @brief decay steps property
+ *
+ */
+class DecaySteps : public PositiveIntegerProperty {
+public:
+  static constexpr const char *key = "decay_steps"; /**< unique key to access */
+  using prop_tag = uint_prop_tag;                   /**< property type */
+};
+
 } // namespace props
 } // namespace nntrainer
 
index 305c983..93dd62c 100644 (file)
  *
  */
 
+#include <cmath>
 #include <fstream>
 #include <iostream>
 
-#include <cmath>
+#include <common_properties.h>
 #include <nntrainer_error.h>
 #include <nntrainer_log.h>
 #include <node_exporter.h>
@@ -25,7 +26,8 @@
 namespace nntrainer {
 
 OptimizerImpl::OptimizerImpl() :
-  optimizer_impl_props(PropsLR(), PropsDecayRate(), PropsDecaySteps()) {}
+  optimizer_impl_props(props::LearningRate(), props::DecayRate(),
+                       props::DecaySteps()) {}
 
 void OptimizerImpl::setProperty(const std::vector<std::string> &values) {
   auto left = loadProperties(values, optimizer_impl_props);
index 81cc996..22c6870 100644 (file)
 
 #include <tuple>
 
-#include <base_properties.h>
+#include <common_properties.h>
 #include <optimizer_devel.h>
 
 namespace nntrainer {
 
 /**
- * @brief Learning Rate props
- *
- */
-class PropsLR : public Property<float> {
-public:
-  static constexpr const char *key =
-    "learning_rate";               /**< unique key to access */
-  using prop_tag = float_prop_tag; /**< property type */
-};
-
-/**
- * @brief Decay rate property
- *
- */
-class PropsDecayRate : public Property<float> {
-public:
-  static constexpr const char *key = "decay_rate"; /**< unique key to access */
-  using prop_tag = float_prop_tag;                 /**< property type */
-};
-
-/**
- * @brief decay steps property
- *
- */
-class PropsDecaySteps : public PositiveIntegerProperty {
-public:
-  static constexpr const char *key = "decay_steps"; /**< unique key to access */
-  using prop_tag = uint_prop_tag;                   /**< property type */
-};
-
-/**
  * @class   Optimizer Base class for optimizers
  * @brief   Basic implementation class for nntrainer supported optimizers
  */
@@ -120,7 +89,8 @@ public:
   }
 
 protected:
-  std::tuple<PropsLR, PropsDecayRate, PropsDecaySteps> optimizer_impl_props;
+  std::tuple<props::LearningRate, props::DecayRate, props::DecaySteps>
+    optimizer_impl_props;
 };
 
 } /* namespace nntrainer */