diff options
author | Luca Foschiani <luca.foschiani@arm.com> | 2020-02-20 12:19:12 +0000 |
---|---|---|
committer | Luca Foschiani <luca.foschiani@arm.com> | 2020-02-20 16:55:22 +0000 |
commit | d239053e03e93f0f7a0e7e3dc941d9b9b2eeff52 (patch) | |
tree | f4fdff7e54ab94ee91dbbe1a4bf8200182db94fa /tests/validation/reference/ReductionOperation.cpp | |
parent | f04ddbc77d6799470fb1c5e92baf3deae2ddea3b (diff) | |
download | ComputeLibrary-d239053e03e93f0f7a0e7e3dc941d9b9b2eeff52.tar.gz |
COMPMID-3212 Investigate CLReduceMean failure with QASYMM8
Signed-off-by: Luca Foschiani <luca.foschiani@arm.com>
Change-Id: I96d8cbef2e167e09484b0e9b5d8a12ffee0f6e67
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2755
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@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 | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/tests/validation/reference/ReductionOperation.cpp b/tests/validation/reference/ReductionOperation.cpp index 9b35cdf6f5..a0b6a8eaed 100644 --- a/tests/validation/reference/ReductionOperation.cpp +++ b/tests/validation/reference/ReductionOperation.cpp @@ -64,7 +64,7 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in if(std::is_integral<type>::value) { - auto int_res = static_cast<uint32_t>(res); + auto int_res = static_cast<int32_t>(res); for(int i = 0; i < reduce_elements; ++i) { auto elem = *(ptr + stride * i); @@ -101,7 +101,7 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in { int_res /= reduce_elements; } - res = saturate_cast<type>(int_res); + res = static_cast<type>(int_res); } else { @@ -279,9 +279,17 @@ SimpleTensor<uint8_t> reduction_operation(const SimpleTensor<uint8_t> &src, cons { if(src.data_type() == DataType::QASYMM8) { - SimpleTensor<float> src_f = convert_from_asymmetric(src); - SimpleTensor<float> dst_f = reference::reduction_operation<float, float>(src_f, dst_shape, axis, op); - return convert_to_asymmetric<uint8_t>(dst_f, src.quantization_info()); + // If the operation is MEAN_SUM, we can directly use the uint8 implementation without taking into account scale and offset + if(op == ReductionOperation::MEAN_SUM) + { + return compute_reduction_operation<uint8_t, uint8_t>(src, dst_shape, axis, op); + } + else + { + SimpleTensor<float> src_f = convert_from_asymmetric(src); + SimpleTensor<float> dst_f = reference::reduction_operation<float, float>(src_f, dst_shape, axis, op); + return convert_to_asymmetric<uint8_t>(dst_f, src.quantization_info()); + } } else { @@ -294,9 +302,17 @@ SimpleTensor<int8_t> reduction_operation(const SimpleTensor<int8_t> &src, const { if(src.data_type() == DataType::QASYMM8_SIGNED) { - SimpleTensor<float> src_f = convert_from_asymmetric(src); - SimpleTensor<float> dst_f = reference::reduction_operation<float, float>(src_f, dst_shape, axis, op); - return convert_to_asymmetric<int8_t>(dst_f, src.quantization_info()); + // If the operation is MEAN_SUM, we can directly use the int8 implementation without taking into account scale and offset + if(op == ReductionOperation::MEAN_SUM) + { + return compute_reduction_operation<int8_t, int8_t>(src, dst_shape, axis, op); + } + else + { + SimpleTensor<float> src_f = convert_from_asymmetric(src); + SimpleTensor<float> dst_f = reference::reduction_operation<float, float>(src_f, dst_shape, axis, op); + return convert_to_asymmetric<int8_t>(dst_f, src.quantization_info()); + } } else { |