diff options
author | Omar Al Khatib <omar.alkhatib@arm.com> | 2022-11-01 17:01:24 +0000 |
---|---|---|
committer | Omar Al Khatib <omar.alkhatib@arm.com> | 2022-11-15 10:20:29 +0000 |
commit | b230a1f9bc53bf6b3bd74789e0085ff48336f348 (patch) | |
tree | e1469efaf532a022df2c2595d8188a551592edeb | |
parent | b1f82884eab0dac9ac1bd336f5c004ead7dfafbb (diff) | |
download | ComputeLibrary-b230a1f9bc53bf6b3bd74789e0085ff48336f348.tar.gz |
Fixed Arm NN unit test failure caused by quantised multiplication patch.
Resolves : [COMPMID-5698]
Signed-off-by: Omar Al Khatib <omar.alkhatib@arm.com>
Change-Id: I21ce976473e0e8807c14989e98e68aca69c7f1f3
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8603
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r-- | src/core/NEON/wrapper/intrinsics/shr.h | 15 | ||||
-rw-r--r-- | src/cpu/kernels/CpuMulKernel.cpp | 7 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/core/NEON/wrapper/intrinsics/shr.h b/src/core/NEON/wrapper/intrinsics/shr.h index e41e9b8b31..73ca9c56c6 100644 --- a/src/core/NEON/wrapper/intrinsics/shr.h +++ b/src/core/NEON/wrapper/intrinsics/shr.h @@ -108,6 +108,19 @@ VSHRQ_IMPL(int32x4_t, vshrq_n, s32) #undef VSHRQ_IMPL #ifdef __aarch64__ +#define VSHRQ_SCALAR_IMPL(vtype, prefix, postfix) \ + template <int b> \ + inline vtype vshrq_n(const vtype &a) \ + { \ + return prefix##_##postfix(a, b); \ + } +VSHRQ_SCALAR_IMPL(uint32_t, vshrd_n, u64) +VSHRQ_SCALAR_IMPL(int32_t, vshrd_n, s64) + +#undef VSHRQ_SCALAR_IMPL +#endif // __aarch64__ + +#ifdef __aarch64__ #define VQRSHRN_EX_SCALAR_IMPL(half_vtype, vtype, prefix_signed, prefix_unsigned, postfix) \ template <int b, typename T> \ inline typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value, half_vtype>::type \ @@ -115,7 +128,7 @@ VSHRQ_IMPL(int32x4_t, vshrq_n, s32) { \ return prefix_signed##_##postfix(a, b); \ } \ - \ + \ template <int b, typename T> \ inline typename std::enable_if<std::is_integral<T>::value && !std::is_signed<T>::value, u##half_vtype>::type \ vqrshrn_ex(const vtype &a) \ diff --git a/src/cpu/kernels/CpuMulKernel.cpp b/src/cpu/kernels/CpuMulKernel.cpp index 35a9958f65..82e5445321 100644 --- a/src/cpu/kernels/CpuMulKernel.cpp +++ b/src/cpu/kernels/CpuMulKernel.cpp @@ -181,7 +181,8 @@ void mul_saturate_quantized_8(const ITensor *src1, const ITensor *src2, ITensor using ExactTagType = typename wrapper::traits::neon_vector<T, window_step_x>::tag_type; - execute_window_loop(win, [&](const Coordinates &) + execute_window_loop( + win, [&](const Coordinates &) { const auto non_broadcast_input_ptr = reinterpret_cast<const T *>(non_broadcast_input.ptr()); const auto output_ptr = reinterpret_cast<T *>(dst.ptr()); @@ -447,7 +448,7 @@ void mul_q8_neon_fixedpoint(const ITensor *src0, const ITensor *src1, ITensor *d for(; x < window_end_x; ++x) { #ifdef __aarch64__ - out_ptr[x] = wrapper::vqrshrn<2>(wrapper::vqrshrn<8>(wrapper::vqrshrn_ex<8, ScalarType>((multiplier_14p18 * (int32_t(a_ptr[x]) - a_offset_16p0) * (int32_t( + out_ptr[x] = wrapper::vqrshrn<2>(wrapper::vqrshrn_ex<8, ScalarType>(wrapper::vshrq_n<8>((multiplier_14p18 * (int32_t(a_ptr[x]) - a_offset_16p0) * (int32_t( b_val) - b_offset_16p0)) + out_offset_14p18))); #else //__aarch64__ out_ptr[x] = utility::clamp<int32_t, ScalarType>(support::cpp11::lround(multiplier * ((float(a_ptr[x]) - a_offset) * (float(b_val) - b_offset)) + float(out_offset))); @@ -536,7 +537,7 @@ void mul_q8_neon_fixedpoint(const ITensor *src0, const ITensor *src1, ITensor *d for(; x < window_end_x; ++x) { #ifdef __aarch64__ - out_ptr[x] = wrapper::vqrshrn<2>(wrapper::vqrshrn<8>(wrapper::vqrshrn_ex<8, ScalarType>((multiplier_14p18 * (int32_t(in0_ptr[x]) - in0_offset_16p0) * (int32_t( + out_ptr[x] = wrapper::vqrshrn<2>(wrapper::vqrshrn_ex<8, ScalarType>(wrapper::vshrq_n<8>((multiplier_14p18 * (int32_t(in0_ptr[x]) - in0_offset_16p0) * (int32_t( in1_ptr[x]) - in1_offset_16p0)) + out_offset_14p18))); #else //__aarch64__ out_ptr[x] = utility::clamp<int32_t, ScalarType>(support::cpp11::lround(multiplier * ((float(in0_ptr[x]) - in0_offset) * (float(in1_ptr[x]) - in1_offset)) + float(out_offset))); |