From 9247c92bd8c53be4d0c4ae931f51ca8f88e4150b Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 28 Jun 2017 18:29:47 +0100 Subject: COMPMID-428: Port NESoftmaxLayer to 16-bit fixed point. Change-Id: I65122950bab9124b9758c27096c0f458b77aeabb Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79365 Reviewed-by: Moritz Pflanzer Tested-by: Kaizen Reviewed-by: Steven Niu --- arm_compute/core/FixedPoint.inl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'arm_compute/core/FixedPoint.inl') diff --git a/arm_compute/core/FixedPoint.inl b/arm_compute/core/FixedPoint.inl index fdbc3f0c06..b921b32ed9 100644 --- a/arm_compute/core/FixedPoint.inl +++ b/arm_compute/core/FixedPoint.inl @@ -90,13 +90,22 @@ inline qint8_t sqadd_qs8(qint8_t a, qint8_t b) inline qint16_t sqadd_qs16(qint16_t a, qint16_t b) { - // We need to store the temporary result in qint16_t otherwise we cannot evaluate the overflow + // We need to store the temporary result in qint32_t otherwise we cannot evaluate the overflow qint32_t tmp = (static_cast(a) + static_cast(b)); // Saturate the result in case of overflow and cast to qint16_t return saturate_convert(tmp); } +inline qint32_t sqadd_qs32(qint32_t a, qint32_t b) +{ + // We need to store the temporary result in qint64_t otherwise we cannot evaluate the overflow + qint64_t tmp = (static_cast(a) + static_cast(b)); + + // Saturate the result in case of overflow and cast to qint32_t + return saturate_convert(tmp); +} + inline qint8_t ssub_qs8(qint8_t a, qint8_t b) { return a - b; @@ -388,4 +397,10 @@ inline qint8_t sqmovn_qs16(qint16_t a) // Saturate the result in case of overflow and cast to qint8_t return saturate_convert(a); } + +inline qint16_t sqmovn_qs32(qint32_t a) +{ + // Saturate the result in case of overflow and cast to qint16_t + return saturate_convert(a); +} } -- cgit v1.2.1