From 6413e493b15b04d27304c0e52ccf2ecd2ec9c302 Mon Sep 17 00:00:00 2001 From: Alessandro Navone Date: Tue, 2 Feb 2021 11:39:05 +0000 Subject: Add DIV to Elementwise layer support at graph level COMPUTE-12654 Signed-off-by: Alessandro Navone Change-Id: I9e13e24fb3033888a86874528a72425d87b342ec Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5030 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Michele Di Giorgio --- arm_compute/graph/TypePrinter.h | 5 ++++- arm_compute/graph/Types.h | 1 + arm_compute/graph/backends/FunctionHelpers.h | 8 +++++++- arm_compute/graph/backends/ValidateHelpers.h | 6 +++++- src/graph/backends/CL/CLFunctionsFactory.cpp | 3 ++- src/graph/backends/CL/CLNodeValidator.cpp | 3 ++- src/graph/backends/NEON/NEFunctionFactory.cpp | 3 ++- src/graph/backends/NEON/NENodeValidator.cpp | 1 + 8 files changed, 24 insertions(+), 6 deletions(-) diff --git a/arm_compute/graph/TypePrinter.h b/arm_compute/graph/TypePrinter.h index 62bacae89f..1037c80157 100644 --- a/arm_compute/graph/TypePrinter.h +++ b/arm_compute/graph/TypePrinter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -218,6 +218,9 @@ inline ::std::ostream &operator<<(::std::ostream &os, const EltwiseOperation &el case EltwiseOperation::Sub: os << "Sub"; break; + case EltwiseOperation::Div: + os << "Div"; + break; default: ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); } diff --git a/arm_compute/graph/Types.h b/arm_compute/graph/Types.h index b891c1772f..d1c71f815b 100644 --- a/arm_compute/graph/Types.h +++ b/arm_compute/graph/Types.h @@ -106,6 +106,7 @@ enum class EltwiseOperation Sub, /**< Arithmetic subtraction */ Mul, /**< Arithmetic multiplication */ Max, /**< Arithmetic maximum */ + Div, /**< Arithmetic division */ }; /** Supported Unary Element-wise operations */ diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index ee5dc3e285..9830290d0f 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -873,6 +873,12 @@ std::unique_ptr create_eltwise_layer(EltwiseLayerNode &node) std::string("ElementwiseMaximum"), input1, input2, output, act_info); } + else if(eltwise_op == EltwiseOperation::Div) + { + std::tie(func, func_name) = create_named_function( + std::string("ArithmeticDivision"), + 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 f8cb1c12e9..93d547b036 100644 --- a/arm_compute/graph/backends/ValidateHelpers.h +++ b/arm_compute/graph/backends/ValidateHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -694,6 +694,10 @@ Status validate_eltwise_Layer(EltwiseLayerNode &node) { return EltwiseLayerFunctions::ElementwiseMax::validate(input1, input2, output, act_info); } + else if(eltwise_op == EltwiseOperation::Div) + { + return EltwiseLayerFunctions::ArithmeticDivision::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 5c98ce3b85..a3e7261721 100644 --- a/src/graph/backends/CL/CLFunctionsFactory.cpp +++ b/src/graph/backends/CL/CLFunctionsFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -66,6 +66,7 @@ struct CLEltwiseFunctions using Subtraction = CLArithmeticSubtraction; using Multiplication = CLPixelWiseMultiplication; using Maximum = CLElementwiseMax; + using Division = CLArithmeticDivision; }; /** Collection of CL unary element-wise functions */ diff --git a/src/graph/backends/CL/CLNodeValidator.cpp b/src/graph/backends/CL/CLNodeValidator.cpp index 33e8fb4947..1136086375 100644 --- a/src/graph/backends/CL/CLNodeValidator.cpp +++ b/src/graph/backends/CL/CLNodeValidator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -56,6 +56,7 @@ struct CLEltwiseLayerFunctions using ArithmeticSubtraction = CLArithmeticSubtraction; using PixelWiseMultiplication = CLPixelWiseMultiplication; using ElementwiseMax = CLElementwiseMax; + using ArithmeticDivision = CLArithmeticDivision; }; /** Collection of CL unary element-wise functions */ diff --git a/src/graph/backends/NEON/NEFunctionFactory.cpp b/src/graph/backends/NEON/NEFunctionFactory.cpp index 6a96f0a5b9..83954b6307 100644 --- a/src/graph/backends/NEON/NEFunctionFactory.cpp +++ b/src/graph/backends/NEON/NEFunctionFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -70,6 +70,7 @@ struct NEEltwiseFunctions using Subtraction = NEArithmeticSubtraction; using Multiplication = NEPixelWiseMultiplication; using Maximum = NEElementwiseMax; + using Division = NEElementwiseDivision; }; /** Collection of NEON unary element-wise functions */ diff --git a/src/graph/backends/NEON/NENodeValidator.cpp b/src/graph/backends/NEON/NENodeValidator.cpp index 75bba4c43c..3fb79dbfc0 100644 --- a/src/graph/backends/NEON/NENodeValidator.cpp +++ b/src/graph/backends/NEON/NENodeValidator.cpp @@ -57,6 +57,7 @@ struct NEEltwiseLayerFunctions using ArithmeticSubtraction = NEArithmeticSubtraction; using PixelWiseMultiplication = NEPixelWiseMultiplication; using ElementwiseMax = NEElementwiseMax; + using ArithmeticDivision = NEElementwiseDivision; }; /** Collection of NEON unary element-wise functions */ -- cgit v1.2.1