[manager] Remove activation input exec order from backwarding
authorParichay Kapoor <pk.kapoor@samsung.com>
Tue, 7 Dec 2021 05:30:07 +0000 (14:30 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 9 Dec 2021 01:23:21 +0000 (10:23 +0900)
This patch removes activation input exec order from backwarding as input
of the activation layer is not used in the backwarding.

This leads to change in the unittests as we cannot check all the
outputs, especially close to the end of the model. So, with optimization
enabled, only the output layer's forwarding is checked.

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
nntrainer/tensor/manager.cpp
test/unittest/models/models_test_utils.cpp
test/unittest/models/models_test_utils.h

index 84c846a261689b6900f9c86a79d0436b069fa1e0..ae678b670d430e0af0104bbcc53be0cba062b591 100644 (file)
@@ -400,6 +400,9 @@ Manager::requestInputs(const GraphNode &node,
   std::vector<unsigned int> var_exec_order(
     {forwarding_order, calcGradient_order});
 
+  if (node.getType() == ActivationLayer::type)
+    var_exec_order = {forwarding_order};
+
   if (node.getType() == MultiOutLayer::type)
     var_exec_order = {forwarding_order};
 
index 727d7479cad63c6924b25a224b9a70e9004b40f9..3f5c2749a8dbf7d0aa5bcf97f40a8618deeffbe8 100644 (file)
@@ -376,7 +376,7 @@ void GraphWatcher::compareFor(const std::string &reference,
 
     auto it = nodes.begin();
     for (; it != nodes.end() - 1; ++it) {
-      it->forward(iteration, !(it + 1)->supportInPlace());
+      it->forward(iteration, it->isOutputNode() | !optimize);
     }
     it->forward(iteration, true);
 
index 926e2a0ca907000a21a07ef07d12fa8af702e7fd..73e44934384b07f541391a027d88ff312f5636b5 100644 (file)
@@ -133,6 +133,13 @@ public:
    */
   bool needsCalcDerivative() { return node->needsCalcDerivative(); }
 
+  /**
+   * @brief check if the node is an output node
+   *
+   * @return true if output node else false
+   */
+  bool isOutputNode() { return node->getNumOutputConnections() == 0; }
+
 private:
   NodeType node;
   std::vector<nntrainer::Tensor> expected_output;