From 7485d5a62685cb745ab50e970adb722cb71557ac Mon Sep 17 00:00:00 2001 From: Vidhya Sudhan Loganathan Date: Wed, 4 Jul 2018 09:34:00 +0100 Subject: COMPMID-970 : Remove QS8 / QS16 support Removed fixed point related code. Change-Id: I487acf138dace3b0450e0d72ca7071eaec254566 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/137678 Tested-by: Jenkins Reviewed-by: Anthony Barbier --- tests/validation/reference/SoftmaxLayer.cpp | 53 +++-------------------------- 1 file changed, 5 insertions(+), 48 deletions(-) (limited to 'tests/validation/reference/SoftmaxLayer.cpp') diff --git a/tests/validation/reference/SoftmaxLayer.cpp b/tests/validation/reference/SoftmaxLayer.cpp index ae4bcd8f0e..aa640ad5e6 100644 --- a/tests/validation/reference/SoftmaxLayer.cpp +++ b/tests/validation/reference/SoftmaxLayer.cpp @@ -24,7 +24,6 @@ #include "SoftmaxLayer.h" #include "arm_compute/core/Types.h" -#include "tests/validation/FixedPoint.h" namespace arm_compute { @@ -71,63 +70,21 @@ SimpleTensor softmax_layer(const SimpleTensor &src, float beta) return dst; } -template ::value, int>::type> +template ::value, int>::type> SimpleTensor softmax_layer(const SimpleTensor &src, float beta) -{ - ARM_COMPUTE_UNUSED(beta); - - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1 }; - - // Compute reference - const int cols = src.shape()[0]; - const int upper_dims = src.num_elements() / cols; - - for(int r = 0; r < upper_dims; ++r) - { - const T *src_row_ptr = src.data() + r * cols; - T *dst_row_ptr = dst.data() + r * cols; - - // Find max - const fixed_point max(*std::max_element(src_row_ptr, src_row_ptr + cols), src.fixed_point_position(), true); - - // Regularize - using promoted_type = fixed_point_arithmetic::traits::promote_t; - fixed_point sum(0, src.fixed_point_position(), true); - std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&](T val) - { - const fixed_point res = exp(fixed_point(val, src.fixed_point_position(), true) - max); - sum = add(sum, fixed_point(res.raw(), src.fixed_point_position(), true)); - return res.raw(); - }); - - // Normalize - fixed_point saturated_sum(sum); - std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [&](T val) - { - return div(fixed_point(val, src.fixed_point_position(), true), saturated_sum).raw(); - }); - } - - return dst; -} - -template <> -SimpleTensor softmax_layer(const SimpleTensor &src, float beta) { // Note: Output quantization info should always have scale = 1/256 and offset = 0 const QuantizationInfo output_quantization_info = QuantizationInfo(1.f / 256, 0); - SimpleTensor src_tmp = convert_from_asymmetric(src); - SimpleTensor dst_tmp = softmax_layer(src_tmp, beta); - SimpleTensor dst = convert_to_asymmetric(dst_tmp, output_quantization_info); + SimpleTensor src_tmp = convert_from_asymmetric(src); + SimpleTensor dst_tmp = softmax_layer(src_tmp, beta); + SimpleTensor dst = convert_to_asymmetric(dst_tmp, output_quantization_info); return dst; } template SimpleTensor softmax_layer(const SimpleTensor &src, float beta); template SimpleTensor softmax_layer(const SimpleTensor &src, float beta); +template SimpleTensor softmax_layer(const SimpleTensor &src, float beta); } // namespace reference } // namespace validation } // namespace test -- cgit v1.2.1