From 4a61653202afb018f4f259d3c144a735d73f0a20 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Thu, 4 Jun 2020 15:05:38 +0100 Subject: COMPMID-3480: Perform in-place computations in NEArithmeticAdditionKernel Change-Id: I0089657dd95d7c7b8592984def8e8de1d7e6d085 Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3308 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- src/graph/mutators/InPlaceOperationMutator.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/graph/mutators/InPlaceOperationMutator.cpp') diff --git a/src/graph/mutators/InPlaceOperationMutator.cpp b/src/graph/mutators/InPlaceOperationMutator.cpp index 3b06537cd9..327e985625 100644 --- a/src/graph/mutators/InPlaceOperationMutator.cpp +++ b/src/graph/mutators/InPlaceOperationMutator.cpp @@ -25,6 +25,7 @@ #include "arm_compute/graph/Graph.h" #include "arm_compute/graph/Logger.h" +#include "arm_compute/graph/backends/BackendRegistry.h" namespace arm_compute { @@ -42,13 +43,29 @@ IGraphMutator::MutationType InPlaceOperationMutator::type() const void InPlaceOperationMutator::mutate(Graph &g) { - std::set in_place_nodes = { NodeType::BatchNormalizationLayer, NodeType::ActivationLayer, NodeType::PrintLayer }; + std::set in_place_nodes = + { + NodeType::ActivationLayer, + NodeType::BatchNormalizationLayer, + NodeType::EltwiseLayer, + NodeType::PrintLayer, + }; // Not interested in the order of nodes for(auto &node : g.nodes()) { if(node && in_place_nodes.find(node->type()) != std::end(in_place_nodes)) { + // Validate node + backends::IDeviceBackend &backend = backends::BackendRegistry::get().get_backend(node->assigned_target()); + Status status = backend.validate_node(*node); + + // If in-place computation is not supported, do nothing and go to next node + if(!bool(status)) + { + continue; + } + // Get input edge Edge *input_edge = node->input_edge(0); -- cgit v1.2.1