diff options
author | Sang-Hoon Park <sang-hoon.park@arm.com> | 2019-11-13 17:08:12 +0000 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-12-20 11:47:29 +0000 |
commit | 0779fecbf897fe85c5e13da52b129e439c4cc75d (patch) | |
tree | c9d9edd74eb423099d9c8d31e1d655a2b6e59173 /src/core/Utils.cpp | |
parent | 64e738f32187e8a4ea2624d15b48ed79b34cc824 (diff) | |
download | ComputeLibrary-0779fecbf897fe85c5e13da52b129e439c4cc75d.tar.gz |
COMPMID-2763 [CL] add support for QASYMM8_SIGNED to SoftmaxLayer
Change-Id: I4556bde3aa51eb874a4e674dbbd575fa4491c088
Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/2375
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'src/core/Utils.cpp')
-rw-r--r-- | src/core/Utils.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
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) { |