From 4715cf9da26c4e914b9528f736e77d6773285169 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Wed, 8 Jan 2020 16:02:47 +0000 Subject: COMPMID-2760: add support for QASYMM8_SIGNED to CLGEMMConvolutionLayer Signed-off-by: Sang-Hoon Park Change-Id: I55ab81d0f96c78af0396652cacf6640fc98ef3c2 Reviewed-on: https://review.mlplatform.org/c/2584 Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- src/core/Utils.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/core/Utils.cpp') diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index 30e5b66540..f930804ce3 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -471,6 +471,21 @@ float arm_compute::calculate_resize_ratio(size_t input_size, size_t output_size, return static_cast(in) / static_cast(out); } +std::pair arm_compute::get_quantized_activation_min_max(ActivationLayerInfo act_info, DataType data_type, UniformQuantizationInfo oq_info) +{ + const bool is_qasymm8_signed = is_data_type_quantized_asymmetric_signed(data_type); + const auto a = act_info.a(); + const auto b = act_info.b(); + const int a_int = is_qasymm8_signed ? quantize_qasymm8_signed(a, oq_info) : quantize_qasymm8(a, oq_info); + const int b_int = is_qasymm8_signed ? quantize_qasymm8_signed(b, oq_info) : quantize_qasymm8(b, oq_info); + const auto type_max_value = std::get<1>(get_min_max(data_type)).get(); + + const int32_t min_activation = act_info.activation() != ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU ? oq_info.offset : b_int; + const int32_t max_activation = act_info.activation() == ActivationLayerInfo::ActivationFunction::RELU ? type_max_value : a_int; + + return std::make_pair(min_activation, max_activation); +} + #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