From a4a08ad5e33867f9938a3fbaf9b6dcc56ad8f7b5 Mon Sep 17 00:00:00 2001 From: Usama Arif Date: Mon, 20 May 2019 12:38:33 +0100 Subject: COMPMID-2280: Implement REDUCE_MIN operator for NEON Change-Id: Iaa8d97e3328ce69dae7a97a7111120ecc61fb465 Signed-off-by: Usama Arif Reviewed-on: https://review.mlplatform.org/c/1192 Comments-Addressed: Arm Jenkins Reviewed-by: Pablo Marquez Tested-by: Arm Jenkins --- tests/validation/NEON/ReductionOperation.cpp | 3 ++- tests/validation/reference/ReductionOperation.cpp | 31 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/validation/NEON/ReductionOperation.cpp b/tests/validation/NEON/ReductionOperation.cpp index b9b4983ae6..074689d678 100644 --- a/tests/validation/NEON/ReductionOperation.cpp +++ b/tests/validation/NEON/ReductionOperation.cpp @@ -51,7 +51,8 @@ RelativeTolerance tolerance_qasymm8(1); const auto ReductionOperations = framework::dataset::make("ReductionOperation", { ReductionOperation::SUM, - ReductionOperation::PROD + ReductionOperation::PROD, + ReductionOperation::MIN, }); const auto QuantizationInfos = framework::dataset::make("QuantizationInfo", diff --git a/tests/validation/reference/ReductionOperation.cpp b/tests/validation/reference/ReductionOperation.cpp index c7624a4628..1f825f0e0f 100644 --- a/tests/validation/reference/ReductionOperation.cpp +++ b/tests/validation/reference/ReductionOperation.cpp @@ -42,7 +42,24 @@ template OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, int stride) { using type = typename std::remove_cv::type; - auto res = (op == ReductionOperation::PROD) ? type(1) : type(0); + T res; + switch(op) + { + case ReductionOperation::PROD: + { + res = type(1); + } + break; + case ReductionOperation::MIN: + { + res = *ptr; + } + break; + default: + { + res = type(0); + } + } if(std::is_integral::value) { @@ -65,6 +82,12 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in int_res = static_cast(i); } break; + case ReductionOperation::MIN: + if(static_cast(int_res) > elem) + { + int_res = elem; + } + break; case ReductionOperation::SUM_SQUARE: int_res += elem * elem; break; @@ -104,6 +127,12 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in res = static_cast(i); } break; + case ReductionOperation::MIN: + if(res > elem) + { + res = elem; + } + break; case ReductionOperation::SUM_SQUARE: res += elem * elem; break; -- cgit v1.2.1