From 2697fd8fa42425f7bfdd60dd486d4c2132b06523 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 15 Oct 2019 16:49:24 +0100 Subject: COMPMID-2707: add keep_dims parameter to Reduction Operation The added parameter is used to decide whether or not to keep the target dimension of reduction operation. ArgMinMax operations will always remove the reduced dimension. Following things are updated to support the parameter. - [CL/NEON] functions and reference kernel - [CL/NEON] ArgMinMax function to use ReductionOperation function - [CL/NEON] validation test suite for Reduction and ArgMinMax operations to validate the added parameter - ReductionOperationFixture is modified NOT to pre-populate output tensor and now relies on underlying kernel/function. - Adjust CL validation test suite for Reduction operation to remove excessive test cases with axis values beyond input tensor's dimension. Change-Id: I3e24d276ed469a4201f323001708f0c525f11c4f Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/2167 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Reviewed-by: Georgios Pinitas --- src/core/Utils.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/core/Utils.cpp') diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index 7e1af0e27d..fa335d757b 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -427,6 +427,16 @@ std::pair arm_compute::scaled_dimensions(unsigned in return std::make_pair(w, h); } +bool arm_compute::needs_serialized_reduction(ReductionOperation op, DataType dt, unsigned int axis) +{ + const bool is_arg_min_max = (op == ReductionOperation::ARG_IDX_MAX || op == ReductionOperation::ARG_IDX_MIN); + const bool is_min_max = (op == ReductionOperation::MAX || op == ReductionOperation::MIN); + const bool is_quantized_type = is_data_type_quantized(dt); + const bool is_first_dim = (axis == 0); + + return !is_first_dim || is_arg_min_max || is_min_max || is_quantized_type; +} + #ifdef ARM_COMPUTE_ASSERTS_ENABLED void arm_compute::print_consecutive_elements(std::ostream &s, DataType dt, const uint8_t *ptr, unsigned int n, int stream_width, const std::string &element_delim) { -- cgit v1.2.1