From 272e425d12a6f790f1807bd7ca6fe97aa6e47c93 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Tue, 6 Oct 2020 17:44:40 +0100 Subject: COMPMID-3821: NEON Reduction op PROD failures Signed-off-by: Michalis Spyrou Change-Id: I8cfdd24c4e71a6a4be610ba67a75ad2943a43801 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4097 Reviewed-by: Michele Di Giorgio Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins --- src/core/NEON/kernels/NEReductionOperationKernel.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/core/NEON/kernels/NEReductionOperationKernel.cpp') diff --git a/src/core/NEON/kernels/NEReductionOperationKernel.cpp b/src/core/NEON/kernels/NEReductionOperationKernel.cpp index 01534f77b4..9eebb42151 100644 --- a/src/core/NEON/kernels/NEReductionOperationKernel.cpp +++ b/src/core/NEON/kernels/NEReductionOperationKernel.cpp @@ -1368,7 +1368,7 @@ struct RedOpYZW_quantized // Compute left-over elements for(; x < window_end_x; ++x) { - auto res_value = 0; + float res_value = 0.f; switch(op) { case ReductionOperation::ARG_IDX_MAX: @@ -1413,11 +1413,11 @@ struct RedOpYZW_quantized //de-quantize input if(std::is_same::value) { - res_value *= dequantize_qasymm8(*input_ptr, iq_info); + res_value *= dequantize_qasymm8(*in_ptr, iq_info); } else { - res_value *= dequantize_qasymm8_signed(*input_ptr, iq_info); + res_value *= dequantize_qasymm8_signed(*in_ptr, iq_info); } break; } @@ -1458,8 +1458,9 @@ struct RedOpYZW_quantized { case ReductionOperation::MEAN_SUM: { - res_value /= in_info.dimension(axis); - *reinterpret_cast(output.ptr() + x) = utils::cast::saturate_cast(res_value); + int32_t res = static_cast(res_value); + res /= in_info.dimension(axis); + *reinterpret_cast(output.ptr() + x) = utils::cast::saturate_cast(res); break; } case ReductionOperation::SUM: @@ -1472,16 +1473,17 @@ struct RedOpYZW_quantized case ReductionOperation::PROD: { //re-quantize result + T res = 0; if(std::is_same::value) { - res_value = quantize_qasymm8(res_value, iq_info); + res = quantize_qasymm8(res_value, iq_info); } else { - res_value = quantize_qasymm8_signed(res_value, iq_info); + res = quantize_qasymm8_signed(res_value, iq_info); } + *(reinterpret_cast(output.ptr() + x)) = res; break; - *(reinterpret_cast(output.ptr() + x)) = res_value; } case ReductionOperation::ARG_IDX_MIN: case ReductionOperation::ARG_IDX_MAX: -- cgit v1.2.1