aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/kernels/CLActivationLayerKernel.cpp
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2018-01-17 16:13:46 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:43:42 +0000
commita0d1183a15c6788676a12160f56e4c576ee1a84b (patch)
tree9f404c3addc837ddcc333cea7000a79a17b4c9f3 /src/core/CL/kernels/CLActivationLayerKernel.cpp
parent51a673020af96273ab9d760ea7473a62aad5460f (diff)
downloadComputeLibrary-a0d1183a15c6788676a12160f56e4c576ee1a84b.tar.gz
COMPMID-751 QASYMM8 ActivationLayer optimisation: don't requantize if not necessary
Change-Id: Iea8a21f7c71025bfde6fdf7c7a7c92ba749b189b Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/116673 Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLActivationLayerKernel.cpp')
-rw-r--r--src/core/CL/kernels/CLActivationLayerKernel.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/core/CL/kernels/CLActivationLayerKernel.cpp b/src/core/CL/kernels/CLActivationLayerKernel.cpp
index eecc94f23c..d85de88ae2 100644
--- a/src/core/CL/kernels/CLActivationLayerKernel.cpp
+++ b/src/core/CL/kernels/CLActivationLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -145,18 +145,21 @@ void CLActivationLayerKernel::configure(ICLTensor *input, ICLTensor *output, Act
build_opts.emplace(("-DA_VAL=" + support::cpp11::to_string(a_const_int)));
build_opts.emplace(("-DB_VAL=" + support::cpp11::to_string(b_const_int)));
- // Set scale and offset of the input and output
- if(is_data_type_quantized_asymmetric(dt))
+ // Set scale and offset of the input and output if they have different quantization info
+ if(is_data_type_quantized_asymmetric(dt) && output != nullptr)
{
- float s1 = input->info()->quantization_info().scale;
- int o1 = input->info()->quantization_info().offset;
- // If output is nullptr, assume same quantization scale/offset as input
- float s2 = output != nullptr ? output->info()->quantization_info().scale : s1;
- int o2 = output != nullptr ? output->info()->quantization_info().offset : o1;
- build_opts.emplace(("-DS1_VAL=" + float_to_string_with_full_precision(s1)));
- build_opts.emplace(("-DS2_VAL=" + float_to_string_with_full_precision(s2)));
- build_opts.emplace(("-DO1_VAL=" + support::cpp11::to_string(o1)));
- build_opts.emplace(("-DO2_VAL=" + support::cpp11::to_string(o2)));
+ const float s1 = input->info()->quantization_info().scale;
+ const float s2 = output->info()->quantization_info().scale;
+ const int o1 = input->info()->quantization_info().offset;
+ const int o2 = output->info()->quantization_info().offset;
+
+ if(o1 != o2 || s1 != s2)
+ {
+ build_opts.emplace(("-DS1_VAL=" + float_to_string_with_full_precision(s1)));
+ build_opts.emplace(("-DS2_VAL=" + float_to_string_with_full_precision(s2)));
+ build_opts.emplace(("-DO1_VAL=" + support::cpp11::to_string(o1)));
+ build_opts.emplace(("-DO2_VAL=" + support::cpp11::to_string(o2)));
+ }
}
}
else