aboutsummaryrefslogtreecommitdiff
path: root/src/graph
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-07-16 12:57:42 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commit6f109bdaed41bf9f37f201189f11ba30c60170fb (patch)
tree8de1018e09b5bf1e53eb2b947acde08acf8a2a0e /src/graph
parent665c89b264a86f4f27dd0a1259bea9c1372da396 (diff)
downloadComputeLibrary-6f109bdaed41bf9f37f201189f11ba30c60170fb.tar.gz
COMPMID-1409: Disable BN + Act fusion in the graph if activation is not supported
Change-Id: Ifba641d498638ac48bbc9624338a2168a56fe5c6 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/140075 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/graph')
-rw-r--r--src/graph/mutators/NodeFusionMutator.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/graph/mutators/NodeFusionMutator.cpp b/src/graph/mutators/NodeFusionMutator.cpp
index 39209d2f49..6677330cec 100644
--- a/src/graph/mutators/NodeFusionMutator.cpp
+++ b/src/graph/mutators/NodeFusionMutator.cpp
@@ -29,6 +29,8 @@
#include "arm_compute/core/utils/misc/Cast.h"
+#include <set>
+
namespace arm_compute
{
namespace graph
@@ -37,6 +39,9 @@ namespace detail
{
void fuse_batch_norm_with_activation(Graph &g)
{
+ // Supported activations when fusing
+ const std::set<Activation> supported_fused_activations = { Activation::RELU, Activation::BOUNDED_RELU, Activation::LU_BOUNDED_RELU };
+
// Not interested in the order of nodes
for(auto &node : g.nodes())
{
@@ -48,14 +53,20 @@ void fuse_batch_norm_with_activation(Graph &g)
// Check if following node is an activation layer node
if((output_edge != nullptr) && (output_edge->consumer() != nullptr) && (output_edge->consumer()->type() == NodeType::ActivationLayer))
{
- ARM_COMPUTE_LOG_GRAPH_VERBOSE("Fusing Batch Normalization node with ID : " << output_edge->producer_id()
- << " with Activation Layer node with ID : " << output_edge->consumer_id() << std::endl);
-
auto *bn_node = arm_compute::utils::cast::polymorphic_downcast<BatchNormalizationLayerNode *>(output_edge->producer());
auto *act_node = arm_compute::utils::cast::polymorphic_downcast<ActivationLayerNode *>(output_edge->consumer());
ARM_COMPUTE_ERROR_ON(act_node->output(0) == nullptr || bn_node->output(0) == nullptr);
+ // Check if activation is supported for fusion
+ if(supported_fused_activations.count(act_node->activation_info().activation()) == 0)
+ {
+ continue;
+ }
+
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Fusing Batch Normalization node with ID : " << output_edge->producer_id()
+ << " with Activation Layer node with ID : " << output_edge->consumer_id() << std::endl);
+
// Prevent fusion if batch normalization node has an output accessor
if(bn_node->output(0)->accessor() == nullptr)
{