aboutsummaryrefslogtreecommitdiff
path: root/src/backends/cl/ClBackend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/cl/ClBackend.cpp')
-rw-r--r--src/backends/cl/ClBackend.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backends/cl/ClBackend.cpp b/src/backends/cl/ClBackend.cpp
index 35770d9219..a9ab237325 100644
--- a/src/backends/cl/ClBackend.cpp
+++ b/src/backends/cl/ClBackend.cpp
@@ -30,6 +30,7 @@
#include "workloads/ClDivisionWorkload.hpp"
#include "workloads/ClFullyConnectedWorkload.hpp"
#include "workloads/ClMultiplicationWorkload.hpp"
+#include "workloads/ClReduceWorkload.hpp"
#include "workloads/ClSubtractionWorkload.hpp"
#include <Optimizer.hpp>
@@ -220,6 +221,7 @@ OptimizationViews ClBackend::OptimizeSubgraphView(const SubgraphView& subgraph,
--it;
Layer& base = **it;
+ // Fuse activation into previous layer if supported by backend
if ((base.GetType() == LayerType::DepthwiseConvolution2d || base.GetType() == LayerType::Convolution2d
|| base.GetType() == LayerType::BatchNormalization || base.GetType() == LayerType::FullyConnected
|| base.GetType() == LayerType::Addition || base.GetType() == LayerType::Multiplication
@@ -451,6 +453,25 @@ OptimizationViews ClBackend::OptimizeSubgraphView(const SubgraphView& subgraph,
}
}
}
+
+ // Separate reduce layer with multiple axes into multiple reduce layers with 1 axis.
+ if (base.GetType() == LayerType::Reduce)
+ {
+ ReduceLayer* baseLayer = PolymorphicDowncast<ReduceLayer*>(&base);
+ ReduceDescriptor reduceDescriptor = baseLayer->GetParameters();
+
+ if (!reduceDescriptor.m_vAxis.empty() && reduceDescriptor.m_vAxis.size() > 1)
+ {
+ // Add new layers to the graph and connect them.
+ std::vector<Layer*> layers = ChainReduceLayers<ReduceLayer>(optimizationViews,
+ baseLayer,
+ reduceDescriptor);
+
+ // Replace existing baselayer with new subgraph.
+ ReplaceLayers<ReduceLayer>(optimizationViews, baseLayer, layers);
+ untouched.erase(baseLayer->GetGuid());
+ }
+ }
}
if (optimizationViews.GetSubstitutions().empty())