[layers] bugfix for layers
authorParichay Kapoor <pk.kapoor@samsung.com>
Mon, 23 Aug 2021 10:33:59 +0000 (19:33 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 30 Sep 2021 23:13:38 +0000 (08:13 +0900)
This patch adds bugfixes for layers:
1. acti_func in-place support bug
2. batch normalization layer weight name bug
3. loss layers not using tensor reference bug

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
nntrainer/layers/acti_func.cpp
nntrainer/layers/loss/cross_entropy_sigmoid_loss_layer.cpp
nntrainer/layers/loss/cross_entropy_softmax_loss_layer.cpp
nntrainer/layers/loss/mse_loss_layer.cpp

index e4a21fd..ae9c06d 100644 (file)
@@ -137,7 +137,7 @@ Tensor &ActiFunc::run_prime_fn(Tensor &in, Tensor &ret, Tensor const &deriv) {
 }
 
 bool ActiFunc::supportInPlace() const {
-  bool support_in_place = true;
+  bool support_in_place = in_place;
   if (activation_type == ActivationType::ACT_SOFTMAX)
     support_in_place = false;
 
index c4fad1e..d0b205d 100644 (file)
@@ -26,8 +26,7 @@ static constexpr size_t SINGLE_INOUT_IDX = 0;
 void CrossEntropySigmoidLossLayer::forwarding(RunLayerContext &context,
                                               bool training) {
   Tensor &hidden_ = context.getOutput(SINGLE_INOUT_IDX);
-  // TODO: try Tensor & - it should work
-  Tensor y = context.getInput(SINGLE_INOUT_IDX);
+  Tensor &y = context.getInput(SINGLE_INOUT_IDX);
 
   // fill the output
   hidden_ = y.apply(ActiFunc::sigmoid, hidden_);
index 613bf6d..5312f46 100644 (file)
@@ -26,8 +26,7 @@ static constexpr size_t SINGLE_INOUT_IDX = 0;
 void CrossEntropySoftmaxLossLayer::forwarding(RunLayerContext &context,
                                               bool training) {
   Tensor &hidden_ = context.getOutput(SINGLE_INOUT_IDX);
-  // TODO: try Tensor & - it should work
-  Tensor y = context.getInput(SINGLE_INOUT_IDX);
+  Tensor &y = context.getInput(SINGLE_INOUT_IDX);
 
   // fill the output
   hidden_ = y.apply(ActiFunc::softmax, hidden_);
index e0f46dc..9691aa3 100644 (file)
@@ -20,8 +20,7 @@ static constexpr size_t SINGLE_INOUT_IDX = 0;
 
 void MSELossLayer::forwarding(RunLayerContext &context, bool training) {
   Tensor &hidden_ = context.getOutput(SINGLE_INOUT_IDX);
-  // TODO: try Tensor & - it should work
-  Tensor y = context.getInput(SINGLE_INOUT_IDX);
+  Tensor &y = context.getInput(SINGLE_INOUT_IDX);
   Tensor l;
 
   // fill the output