From 6427c8233661f81053d1ad486b5914c612cef3d6 Mon Sep 17 00:00:00 2001 From: morgolock Date: Mon, 13 Jan 2020 11:53:20 +0000 Subject: COMPMID-2994: Add support QASYMM8_SIGNED in NEElementwiseSquareDiff Updated interface documention and added precommit tests. Change-Id: I6d4fe250eb72d3daff977e5a98c1086692e3654a Signed-off-by: morgolock Reviewed-on: https://review.mlplatform.org/c/2580 Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- .../NEON/functions/NEElementwiseOperations.h | 12 +++++------ tests/validation/NEON/ElementwiseSquareDiff.cpp | 24 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h b/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h index 9499867f81..eec9bb9fa9 100644 --- a/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h +++ b/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h @@ -33,7 +33,7 @@ class ITensor; /** Basic function to run @ref NEArithmeticOperationKernel for max * - * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. + * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. * @note The function performs a max operation between two tensors. */ class NEElementwiseMax : public INESimpleFunction @@ -59,8 +59,8 @@ public: /** Basic function to run @ref NEArithmeticOperationKernel for min * - * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. - * @note The function performs a max operation between two tensors. + * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. + * @note The function performs a min operation between two tensors. */ class NEElementwiseMin : public INESimpleFunction { @@ -85,7 +85,7 @@ public: /** Basic function to run @ref NEArithmeticOperationKernel for squared difference * - * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. + * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 */ class NEElementwiseSquaredDiff : public INESimpleFunction @@ -93,14 +93,14 @@ class NEElementwiseSquaredDiff : public INESimpleFunction public: /** Initialise the kernel's inputs, output and conversion policy. * - * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32. + * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. * @param[out] output Output tensor. Data types supported: Same as @p input1. */ void configure(ITensor *input1, ITensor *input2, ITensor *output); /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference * - * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32. + * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. * @param[in] output Output tensor info. Data types supported: Same as @p input1. * diff --git a/tests/validation/NEON/ElementwiseSquareDiff.cpp b/tests/validation/NEON/ElementwiseSquareDiff.cpp index 1a9ff8a4a6..cf55c6a66b 100644 --- a/tests/validation/NEON/ElementwiseSquareDiff.cpp +++ b/tests/validation/NEON/ElementwiseSquareDiff.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 ARM Limited. + * Copyright (c) 2018-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -51,6 +51,11 @@ RelativeTolerance tolerance_fp16(0.01f); const auto ElementwiseSquaredDiffQASYMM8Dataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("DataType", DataType::QASYMM8)); + +const auto ElementwiseSquaredDiffQASYMM8SignedDataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), + framework::dataset::make("DataType", + DataType::QASYMM8_SIGNED)); + /** Input data sets **/ const auto ElementwiseSquaredDiffS32Dataset = combine(combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::S32)), framework::dataset::make("DataType", @@ -79,20 +84,23 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::S32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32), // Invalid data type combination TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes + TensorInfo(TensorShape(1U, 1U, 2U), 1, DataType::QASYMM8_SIGNED), // Mismatching types }), framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::S32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(1U, 1U, 2U), 1, DataType::QASYMM8_SIGNED), })), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::S32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32), TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(1U, 1U, 2U), 1, DataType::QASYMM8, QuantizationInfo(0.3f,1)), })), - framework::dataset::make("Expected", { true, true, true, false, false})), + framework::dataset::make("Expected", { true, true, true, false, false, false})), input1_info, input2_info, output_info, expected) { ARM_COMPUTE_EXPECT(bool(NEElementwiseSquaredDiff::validate(&input1_info.clone()->set_is_resizable(false), &input2_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false))) == expected, framework::LogLevel::ERRORS); @@ -197,6 +205,18 @@ FIXTURE_DATA_TEST_CASE(RunSmallBroadcast, NEElementwiseSquaredDiffQuantizedBroad validate(Accessor(_target), _reference); } TEST_SUITE_END() + +TEST_SUITE(QASYMM8_SIGNED) +FIXTURE_DATA_TEST_CASE(RunSmall, NEElementwiseSquaredDiffQuantizedFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), + ElementwiseSquaredDiffQASYMM8SignedDataset), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f, 5) })), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(.5f, 5) })), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(.2f, 5) }))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() TEST_SUITE_END() TEST_SUITE(Float) -- cgit v1.2.1