diff options
author | Usama Arif <usama.arif@arm.com> | 2019-05-20 12:38:33 +0100 |
---|---|---|
committer | Usama Arif <usama.arif@arm.com> | 2019-05-22 15:06:06 +0000 |
commit | a4a08ad5e33867f9938a3fbaf9b6dcc56ad8f7b5 (patch) | |
tree | 0689ecbe56aed40fd61fa250a4e8a7a98d549bc3 /tests/validation/reference/ReductionOperation.cpp | |
parent | b28905010a95044c7a1c0a5665fc886521a56541 (diff) | |
download | ComputeLibrary-a4a08ad5e33867f9938a3fbaf9b6dcc56ad8f7b5.tar.gz |
COMPMID-2280: Implement REDUCE_MIN operator for NEON
Change-Id: Iaa8d97e3328ce69dae7a97a7111120ecc61fb465
Signed-off-by: Usama Arif <usama.arif@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1192
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez <pablo.tello@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/reference/ReductionOperation.cpp')
-rw-r--r-- | tests/validation/reference/ReductionOperation.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
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 <typename T, typename OT> OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, int stride) { using type = typename std::remove_cv<OT>::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<type>::value) { @@ -65,6 +82,12 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in int_res = static_cast<uint32_t>(i); } break; + case ReductionOperation::MIN: + if(static_cast<T>(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<uint32_t>(i); } break; + case ReductionOperation::MIN: + if(res > elem) + { + res = elem; + } + break; case ReductionOperation::SUM_SQUARE: res += elem * elem; break; |