From f8e358463b4b612eb958fa2dd7588dbefe9b3e2a Mon Sep 17 00:00:00 2001 From: thecha01 Date: Tue, 28 Jul 2020 17:28:17 +0100 Subject: Add support ElementwiseMax operator in graph API Signed-off-by: thecha01 Change-Id: I764f1eabb6412350eb719cc755b8777efc7d70a1 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3736 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio --- arm_compute/graph/Types.h | 1 + arm_compute/graph/backends/FunctionHelpers.h | 6 ++++++ arm_compute/graph/backends/ValidateHelpers.h | 4 ++++ src/graph/backends/CL/CLFunctionsFactory.cpp | 1 + src/graph/backends/CL/CLNodeValidator.cpp | 1 + src/graph/backends/NEON/NEFunctionFactory.cpp | 1 + src/graph/backends/NEON/NENodeValidator.cpp | 1 + 7 files changed, 15 insertions(+) diff --git a/arm_compute/graph/Types.h b/arm_compute/graph/Types.h index 3a4d0a6070..65d737c7b2 100644 --- a/arm_compute/graph/Types.h +++ b/arm_compute/graph/Types.h @@ -104,6 +104,7 @@ enum class EltwiseOperation Add, /**< Arithmetic addition */ Sub, /**< Arithmetic subtraction */ Mul, /**< Arithmetic multiplication */ + Max, /**< Arithmetic maximum */ }; /** Supported Unary Element-wise operations */ diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index af748341a5..60a03e67b0 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -798,6 +798,12 @@ std::unique_ptr create_eltwise_layer(EltwiseLayerNode &node) std::string("PixelWiseMultiplication"), input1, input2, output, 1.f, convert_policy, node.rounding_policy(), act_info); } + else if(eltwise_op == EltwiseOperation::Max) + { + std::tie(func, func_name) = create_named_function( + std::string("ElementwiseMaximum"), + input1, input2, output, act_info); + } else { ARM_COMPUTE_ERROR("Unsupported element-wise operation!"); diff --git a/arm_compute/graph/backends/ValidateHelpers.h b/arm_compute/graph/backends/ValidateHelpers.h index c929983834..0aec2aec1c 100644 --- a/arm_compute/graph/backends/ValidateHelpers.h +++ b/arm_compute/graph/backends/ValidateHelpers.h @@ -616,6 +616,10 @@ Status validate_eltwise_Layer(EltwiseLayerNode &node) { return EltwiseLayerFunctions::PixelWiseMultiplication::validate(input1, input2, output, scale, convert_policy, round_policy, act_info); } + else if(eltwise_op == EltwiseOperation::Max) + { + return EltwiseLayerFunctions::ElementwiseMax::validate(input1, input2, output, act_info); + } else { ARM_COMPUTE_ERROR("Unsupported element-wise operation!"); diff --git a/src/graph/backends/CL/CLFunctionsFactory.cpp b/src/graph/backends/CL/CLFunctionsFactory.cpp index d41da4bf7f..c9d1f6a2bb 100644 --- a/src/graph/backends/CL/CLFunctionsFactory.cpp +++ b/src/graph/backends/CL/CLFunctionsFactory.cpp @@ -64,6 +64,7 @@ struct CLEltwiseFunctions using Addition = CLArithmeticAddition; using Subtraction = CLArithmeticSubtraction; using Multiplication = CLPixelWiseMultiplication; + using Maximum = CLElementwiseMax; }; /** Collection of CL unary element-wise functions */ diff --git a/src/graph/backends/CL/CLNodeValidator.cpp b/src/graph/backends/CL/CLNodeValidator.cpp index cc618db127..7646ac323f 100644 --- a/src/graph/backends/CL/CLNodeValidator.cpp +++ b/src/graph/backends/CL/CLNodeValidator.cpp @@ -44,6 +44,7 @@ struct CLEltwiseLayerFunctions using ArithmeticAddition = CLArithmeticAddition; using ArithmeticSubtraction = CLArithmeticSubtraction; using PixelWiseMultiplication = CLPixelWiseMultiplication; + using ElementwiseMax = CLElementwiseMax; }; /** Collection of CL unary element-wise functions */ diff --git a/src/graph/backends/NEON/NEFunctionFactory.cpp b/src/graph/backends/NEON/NEFunctionFactory.cpp index 4fee630192..1a1519bb6d 100644 --- a/src/graph/backends/NEON/NEFunctionFactory.cpp +++ b/src/graph/backends/NEON/NEFunctionFactory.cpp @@ -69,6 +69,7 @@ struct NEEltwiseFunctions using Addition = NEArithmeticAddition; using Subtraction = NEArithmeticSubtraction; using Multiplication = NEPixelWiseMultiplication; + using Maximum = NEElementwiseMax; }; /** Collection of NEON unary element-wise functions */ diff --git a/src/graph/backends/NEON/NENodeValidator.cpp b/src/graph/backends/NEON/NENodeValidator.cpp index a5d22fb965..74c959a95e 100644 --- a/src/graph/backends/NEON/NENodeValidator.cpp +++ b/src/graph/backends/NEON/NENodeValidator.cpp @@ -44,6 +44,7 @@ struct NEEltwiseLayerFunctions using ArithmeticAddition = NEArithmeticAddition; using ArithmeticSubtraction = NEArithmeticSubtraction; using PixelWiseMultiplication = NEPixelWiseMultiplication; + using ElementwiseMax = NEElementwiseMax; }; /** Collection of NEON unary element-wise functions */ -- cgit v1.2.1