[layer] Add disable bias property for layer impl
authorParichay Kapoor <pk.kapoor@samsung.com>
Tue, 7 Dec 2021 12:17:32 +0000 (21:17 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 9 Dec 2021 01:21:32 +0000 (10:21 +0900)
Add disable bias property for the layer impl class.

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

index 5e4acce..ff52731 100644 (file)
@@ -107,6 +107,21 @@ public:
 };
 
 /**
+ * @brief BiasInitializer Initialization Enumeration Information
+ *
+ */
+class DisableBias : public nntrainer::Property<bool> {
+public:
+  /**
+   * @brief Construct a DisableBias object
+   *
+   */
+  DisableBias(bool val = false) : nntrainer::Property<bool>(val) {}
+  using prop_tag = bool_prop_tag;
+  static constexpr const char *key = "disable_bias";
+};
+
+/**
  * @brief Normalization property, normalize the input to be in range [0, 1] if
  * true
  *
index eb3ae12..83d92dd 100644 (file)
@@ -26,7 +26,8 @@ LayerImpl::LayerImpl() :
   layer_impl_props(
     std::make_unique<
       std::tuple<props::WeightRegularizer, props::WeightRegularizerConstant,
-                 props::WeightInitializer, props::BiasInitializer>>()) {}
+                 props::WeightInitializer, props::BiasInitializer,
+                 props::DisableBias>>()) {}
 
 void LayerImpl::setProperty(const std::vector<std::string> &values) {
   auto remain_props = loadProperties(values, *layer_impl_props);
index bb50850..4614846 100644 (file)
@@ -36,6 +36,7 @@ class WeightRegularizer;
 class WeightRegularizerConstant;
 class WeightInitializer;
 class BiasInitializer;
+class DisableBias;
 } // namespace props
 
 enum class ExportMethods;
@@ -82,9 +83,9 @@ public:
                         const ExportMethods &method) const override;
 
 protected:
-  std::unique_ptr<
-    std::tuple<props::WeightRegularizer, props::WeightRegularizerConstant,
-               props::WeightInitializer, props::BiasInitializer>>
+  std::unique_ptr<std::tuple<
+    props::WeightRegularizer, props::WeightRegularizerConstant,
+    props::WeightInitializer, props::BiasInitializer, props::DisableBias>>
     layer_impl_props; /**< layer_impl_props */
 };
 
index 363e303..6a11c4b 100644 (file)
@@ -66,7 +66,8 @@ void Exporter::saveTflResult(
 template <>
 void Exporter::saveTflResult(
   const std::tuple<props::WeightRegularizer, props::WeightRegularizerConstant,
-                   props::WeightInitializer, props::BiasInitializer> &props,
+                   props::WeightInitializer, props::BiasInitializer,
+                   props::DisableBias> &props,
   const LayerImpl *self) { /// layer impl has nothing to serialize so do nothing
 }
 
index 7b5708f..a057b31 100644 (file)
@@ -216,6 +216,7 @@ class BiasInitializer;
 class SharedFrom;
 class InputConnection;
 class ClipGradByGlobalNorm;
+class DisableBias;
 } // namespace props
 
 class LayerNode;
@@ -240,7 +241,8 @@ class LayerImpl;
 template <>
 void Exporter::saveTflResult(
   const std::tuple<props::WeightRegularizer, props::WeightRegularizerConstant,
-                   props::WeightInitializer, props::BiasInitializer> &props,
+                   props::WeightInitializer, props::BiasInitializer,
+                   props::DisableBias> &props,
   const LayerImpl *self);
 
 class FullyConnectedLayer;