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>
diff --git a/tests/validation/NEON/ReductionOperation.cpp b/tests/validation/NEON/ReductionOperation.cpp
index b9b4983..074689d 100644
--- a/tests/validation/NEON/ReductionOperation.cpp
+++ b/tests/validation/NEON/ReductionOperation.cpp
@@ -51,7 +51,8 @@
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 c7624a4..1f825f0 100644
--- a/tests/validation/reference/ReductionOperation.cpp
+++ b/tests/validation/reference/ReductionOperation.cpp
@@ -42,7 +42,24 @@
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 @@
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 @@
res = static_cast<uint32_t>(i);
}
break;
+ case ReductionOperation::MIN:
+ if(res > elem)
+ {
+ res = elem;
+ }
+ break;
case ReductionOperation::SUM_SQUARE:
res += elem * elem;
break;