From ee22030441e869a7c4ff632d27a7d45c6168a14e Mon Sep 17 00:00:00 2001 From: Suhail Munshi Date: Thu, 6 May 2021 12:43:07 +0100 Subject: Adding S32 Support to NEG operator in CLElementwiseUnaryLayer Resolves : Signed-off-by: Suhail Munshi Change-Id: I4a6144ba788ae46d9637987455bec2dff8b6f561 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5586 Reviewed-by: Manuel Bottini Reviewed-by: Aleksandr Nikolaev Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h | 7 ++++--- src/core/gpu/cl/kernels/ClElementwiseUnaryKernel.cpp | 4 ++++ tests/validation/CL/NegLayer.cpp | 11 ++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h b/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h index 79b79e89de..594ee4cfdc 100644 --- a/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h +++ b/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h @@ -172,21 +172,22 @@ public: * |:--------------|:--------------| * |F16 |F16 | * |F32 |F32 | + * |S32 |S32 | * - * @param[in] input Input tensor. Data types supported: F16/F32. + * @param[in] input Input tensor. Data types supported: F16/F32/S32 * @param[out] output Output tensor. Data types supported: same as @p input. */ void configure(const ICLTensor *input, ICLTensor *output); /** Initialize the function * * @param[in] compile_context The compile context to be used. - * @param[in] input Input tensor. Data types supported: F16/F32. + * @param[in] input Input tensor. Data types supported: F16/F32/S32 * @param[out] output Output tensor. Data types supported: same as @p input. */ void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output); /** Static function to check if given info will lead to a valid configuration of @ref CLNegLayer * - * @param[in] input First tensor input info. Data types supported: F16/F32. + * @param[in] input First tensor input info. Data types supported: F16/F32/S32 * @param[in] output Output tensor info. Data types supported: Same as @p input. * * @return a status diff --git a/src/core/gpu/cl/kernels/ClElementwiseUnaryKernel.cpp b/src/core/gpu/cl/kernels/ClElementwiseUnaryKernel.cpp index 8e9698cd50..5cbb3f2e38 100644 --- a/src/core/gpu/cl/kernels/ClElementwiseUnaryKernel.cpp +++ b/src/core/gpu/cl/kernels/ClElementwiseUnaryKernel.cpp @@ -45,6 +45,10 @@ Status validate_arguments(const ITensorInfo &src, const ITensorInfo &dst, const { ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src, 1, DataType::U8); } + else if(op == ElementWiseUnary::NEG) + { + ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src, 1, DataType::F16, DataType::F32, DataType::S32); + } else { ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src, 1, DataType::F16, DataType::F32); diff --git a/tests/validation/CL/NegLayer.cpp b/tests/validation/CL/NegLayer.cpp index 690b8f44fb..01fa792543 100644 --- a/tests/validation/CL/NegLayer.cpp +++ b/tests/validation/CL/NegLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -50,6 +50,15 @@ TEST_SUITE(NegLayer) template using CLNegLayerFixture = NegValidationFixture; +TEST_SUITE(S32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLNegLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S32))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() + TEST_SUITE(Float) TEST_SUITE(FP16) FIXTURE_DATA_TEST_CASE(RunSmall, CLNegLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", -- cgit v1.2.1