diff options
author | Pablo Palmier <Pablo.Palmier@arm.com> | 2017-10-05 15:01:34 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:42:17 +0000 |
commit | a2b89ca5407532257a959ad1852f29187e1be4ac (patch) | |
tree | a202070aea45a81ec1ea8a86fa4047035eb2d567 /tests/validation/reference | |
parent | 5948634bb97e05934e9eea180ba41dcddf874416 (diff) | |
download | ComputeLibrary-a2b89ca5407532257a959ad1852f29187e1be4ac.tar.gz |
IVGCVSW-631 Neon support for Softmax beta parameter (F32 only)
Change-Id: Ibf6f038b39f1a4e557f5d04feb08e3d5ef54e223
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/112019
Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/validation/reference')
-rw-r--r-- | tests/validation/reference/SoftmaxLayer.cpp | 22 | ||||
-rw-r--r-- | tests/validation/reference/SoftmaxLayer.h | 4 |
2 files changed, 14 insertions, 12 deletions
diff --git a/tests/validation/reference/SoftmaxLayer.cpp b/tests/validation/reference/SoftmaxLayer.cpp index 8e8cc1bd25..90b9b1f7e2 100644 --- a/tests/validation/reference/SoftmaxLayer.cpp +++ b/tests/validation/reference/SoftmaxLayer.cpp @@ -35,7 +35,7 @@ namespace validation namespace reference { template <typename T, typename std::enable_if<is_floating_point<T>::value, int>::type> -SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src) +SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src, float beta) { // Create reference SimpleTensor<T> dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; @@ -54,9 +54,9 @@ SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src) // Regularize T sum(0.f); - std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&sum, max](T val) + std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&sum, max, beta](T val) { - const T res(std::exp(val - max)); + const T res(std::exp((val - max) * beta)); sum += res; return res; }); @@ -72,8 +72,10 @@ SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src) } template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type> -SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src) +SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src, float beta) { + ARM_COMPUTE_UNUSED(beta); + using namespace fixed_point_arithmetic; // Create reference @@ -113,21 +115,21 @@ SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src) } template <> -SimpleTensor<uint8_t> softmax_layer<uint8_t>(const SimpleTensor<uint8_t> &src) +SimpleTensor<uint8_t> softmax_layer<uint8_t>(const SimpleTensor<uint8_t> &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<float> src_tmp = convert_from_asymmetric(src); - SimpleTensor<float> dst_tmp = softmax_layer<float>(src_tmp); + SimpleTensor<float> dst_tmp = softmax_layer<float>(src_tmp, beta); SimpleTensor<uint8_t> dst = convert_to_asymmetric(dst_tmp, output_quantization_info); return dst; } -template SimpleTensor<float> softmax_layer(const SimpleTensor<float> &src); -template SimpleTensor<half> softmax_layer(const SimpleTensor<half> &src); -template SimpleTensor<qint8_t> softmax_layer(const SimpleTensor<qint8_t> &src); -template SimpleTensor<qint16_t> softmax_layer(const SimpleTensor<qint16_t> &src); +template SimpleTensor<float> softmax_layer(const SimpleTensor<float> &src, float beta); +template SimpleTensor<half> softmax_layer(const SimpleTensor<half> &src, float beta); +template SimpleTensor<qint8_t> softmax_layer(const SimpleTensor<qint8_t> &src, float beta); +template SimpleTensor<qint16_t> softmax_layer(const SimpleTensor<qint16_t> &src, float beta); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/reference/SoftmaxLayer.h b/tests/validation/reference/SoftmaxLayer.h index ab79bc4850..a6d4c3b8cf 100644 --- a/tests/validation/reference/SoftmaxLayer.h +++ b/tests/validation/reference/SoftmaxLayer.h @@ -36,10 +36,10 @@ namespace validation namespace reference { template <typename T, typename std::enable_if<is_floating_point<T>::value, int>::type = 0> -SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src); +SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src, float beta); template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> -SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src); +SimpleTensor<T> softmax_layer(const SimpleTensor<T> &src, float beta); } // namespace reference } // namespace validation } // namespace test |