From f6e475c9a092bc6e0fb53f484fbf2832183a9c44 Mon Sep 17 00:00:00 2001 From: Usama Arif Date: Fri, 10 May 2019 12:06:28 +0100 Subject: COMPMID-2268: Implement NEG for NEON. Change-Id: I90c023dbea8ea12e9af677294ba576b2bfcc02a4 Signed-off-by: Usama Arif Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/184216 Tested-by: bsgcomp Comments-Addressed: bsgcomp Reviewed-by: Pablo Tello Reviewed-on: https://review.mlplatform.org/c/1099 Tested-by: Arm Jenkins Reviewed-by: Pablo Marquez Comments-Addressed: Arm Jenkins --- .../validation/fixtures/ElementWiseUnaryFixture.h | 41 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/ElementWiseUnaryFixture.h b/tests/validation/fixtures/ElementWiseUnaryFixture.h index f508bc1d34..ba131630a3 100644 --- a/tests/validation/fixtures/ElementWiseUnaryFixture.h +++ b/tests/validation/fixtures/ElementWiseUnaryFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -53,7 +53,7 @@ public: protected: template - void fill(U &&tensor, int i) + void fill(U &&tensor, int i, DataType data_type) { switch(_op) { @@ -69,6 +69,28 @@ protected: library->fill(tensor, distribution, i); break; } + case ElementWiseUnary::NEG: + { + switch(data_type) + { + case DataType::F32: + case DataType::F16: + { + std::uniform_real_distribution<> distribution(-2.0f, 2.0f); + library->fill(tensor, distribution, i); + break; + } + case DataType::S32: + { + std::uniform_int_distribution distribution(-100, 100); + library->fill(tensor, distribution, i); + break; + } + default: + ARM_COMPUTE_ERROR("DataType for Elementwise Negation Not implemented"); + } + break; + } default: ARM_COMPUTE_ERROR("Not implemented"); } @@ -95,7 +117,7 @@ protected: ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); // Fill tensors - fill(AccessorType(src), 0); + fill(AccessorType(src), 0, data_type); // Compute function elwiseunary_layer.run(); @@ -109,7 +131,7 @@ protected: SimpleTensor src{ shape, data_type }; // Fill reference - fill(src, 0); + fill(src, 0, data_type); return reference::elementwise_unary(src, _op); } @@ -140,6 +162,17 @@ public: ElementWiseUnaryValidationFixture::setup(shape, data_type, ElementWiseUnary::EXP); } }; + +template +class NegValidationFixture : public ElementWiseUnaryValidationFixture +{ +public: + template + void setup(const TensorShape &shape, DataType data_type) + { + ElementWiseUnaryValidationFixture::setup(shape, data_type, ElementWiseUnary::NEG); + } +}; } // namespace validation } // namespace test } // namespace arm_compute -- cgit v1.2.1