From 0779fecbf897fe85c5e13da52b129e439c4cc75d Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Wed, 13 Nov 2019 17:08:12 +0000 Subject: COMPMID-2763 [CL] add support for QASYMM8_SIGNED to SoftmaxLayer Change-Id: I4556bde3aa51eb874a4e674dbbd575fa4491c088 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/2375 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Reviewed-by: Georgios Pinitas --- src/core/Utils.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/core/Utils.cpp') diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index fa56118587..7e7dea5e34 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -438,6 +438,27 @@ bool arm_compute::needs_serialized_reduction(ReductionOperation op, DataType dt, return !is_first_dim || is_min_max || is_quantized_type; } +QuantizationInfo arm_compute::get_softmax_output_quantization_info(DataType input_type, bool is_log) +{ + // Note: Output quantization info for softmax should always have + // * Softmax with QASYMM8: scale = 1/256, offset = 0 + // * Softmax with QASYMM8_SIGNED: scale = 1/256, offset = -128 + // * LogSoftmax with QASYMM8: scale = 1/256, offset = 0 + // * LogSoftmax with QASYMM8_SIGNED: scale = 16/256, offset = 127 + if(is_data_type_quantized_asymmetric_signed(input_type)) + { + if(is_log) + { + return QuantizationInfo(16.f / 256, 127); + } + else + { + return QuantizationInfo(1.f / 256, -128); + } + } + return QuantizationInfo(1.f / 256, 0); +} + #ifdef ARM_COMPUTE_ASSERTS_ENABLED void arm_compute::print_consecutive_elements(std::ostream &s, DataType dt, const uint8_t *ptr, unsigned int n, int stream_width, const std::string &element_delim) { -- cgit v1.2.1