diff options
author | Manuel Bottini <manuel.bottini@arm.com> | 2019-06-14 17:18:12 +0100 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-06-20 17:41:16 +0000 |
commit | 3689fcd5915cd902cb4ea5f618f2a6e42f6dc4a1 (patch) | |
tree | 9d068e7548af2a6054468c35f3259b52bdda91a5 /tests/validation/reference | |
parent | a28aebc5f80630683f50ce934e8584c6b0004beb (diff) | |
download | ComputeLibrary-3689fcd5915cd902cb4ea5f618f2a6e42f6dc4a1.tar.gz |
COMPMID-2408: Add QSYMM16 support for ElementwiseAddition for NEON
Change-Id: I22991e9369ffba9b51a94522ff4977933e887b94
Signed-off-by: Manuel Bottini <manuel.bottini@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1352
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Diffstat (limited to 'tests/validation/reference')
-rw-r--r-- | tests/validation/reference/ArithmeticOperations.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/validation/reference/ArithmeticOperations.cpp b/tests/validation/reference/ArithmeticOperations.cpp index a6205af2c6..abd4f31d72 100644 --- a/tests/validation/reference/ArithmeticOperations.cpp +++ b/tests/validation/reference/ArithmeticOperations.cpp @@ -124,8 +124,32 @@ SimpleTensor<uint8_t> arithmetic_operation(ArithmeticOperation op, const SimpleT } } -template SimpleTensor<int16_t> arithmetic_operation(ArithmeticOperation op, const SimpleTensor<int16_t> &src1, const SimpleTensor<int16_t> &src2, SimpleTensor<int16_t> &dst, - ConvertPolicy convert_policy); +template <> +SimpleTensor<int16_t> arithmetic_operation(ArithmeticOperation op, const SimpleTensor<int16_t> &src1, const SimpleTensor<int16_t> &src2, SimpleTensor<int16_t> &dst, ConvertPolicy convert_policy) +{ + Coordinates id_src1{}; + Coordinates id_src2{}; + Coordinates id_dst{}; + + if(dst.data_type() == DataType::QSYMM16) + { + SimpleTensor<float> src1_tmp = convert_from_symmetric<int16_t>(src1); + SimpleTensor<float> src2_tmp = convert_from_symmetric<int16_t>(src2); + SimpleTensor<float> dst_tmp(TensorShape::broadcast_shape(src1.shape(), src2.shape()), dst.data_type()); + + BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(op, src1_tmp, src2_tmp, dst_tmp, convert_policy, id_src1, id_src2, id_dst); + + dst = convert_to_symmetric<int16_t>(dst_tmp, dst.quantization_info()); + return dst; + } + else + { + // DataType::S16 + BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(op, src1, src2, dst, convert_policy, id_src1, id_src2, id_dst); + return dst; + } +} + template SimpleTensor<int8_t> arithmetic_operation(ArithmeticOperation op, const SimpleTensor<int8_t> &src1, const SimpleTensor<int8_t> &src2, SimpleTensor<int8_t> &dst, ConvertPolicy convert_policy); template SimpleTensor<half> arithmetic_operation(ArithmeticOperation op, const SimpleTensor<half> &src1, const SimpleTensor<half> &src2, SimpleTensor<half> &dst, ConvertPolicy convert_policy); template SimpleTensor<float> arithmetic_operation(ArithmeticOperation op, const SimpleTensor<float> &src1, const SimpleTensor<float> &src2, SimpleTensor<float> &dst, ConvertPolicy convert_policy); @@ -133,7 +157,7 @@ template SimpleTensor<float> arithmetic_operation(ArithmeticOperation op, const template <typename T> SimpleTensor<T> arithmetic_operation(ArithmeticOperation op, const SimpleTensor<T> &src1, const SimpleTensor<T> &src2, DataType dst_data_type, ConvertPolicy convert_policy) { - ARM_COMPUTE_ERROR_ON_MSG(dst_data_type == DataType::QASYMM8, "For QASYMM8, the quantized output tensor should be passed directly."); + ARM_COMPUTE_ERROR_ON_MSG(is_data_type_quantized(dst_data_type), "For quantized input data types, the quantized output tensor should be passed directly."); SimpleTensor<T> dst(TensorShape::broadcast_shape(src1.shape(), src2.shape()), dst_data_type); arithmetic_operation<T>(op, src1, src2, dst, convert_policy); |