diff options
author | Isabella Gottardi <isabella.gottardi@arm.com> | 2019-02-27 09:29:21 +0000 |
---|---|---|
committer | Isabella Gottardi <isabella.gottardi@arm.com> | 2019-02-27 15:57:33 +0000 |
commit | 9197c96afa7c9d37ed2a4484fcceda781f261951 (patch) | |
tree | 32e0857c441ea23e7cb921a5b5be8fb94e2797a5 | |
parent | 9d6a31c2e5ab45b7686b73cf814b7c42e73116f2 (diff) | |
download | ComputeLibrary-9197c96afa7c9d37ed2a4484fcceda781f261951.tar.gz |
COMPMID-1995: Fix output quantization CLDeptwiseConv3x3 when activation is fused
When quantization is fused in the optimazed Deptwise Convolution 3x3,
we quatized twice the output.
Change-Id: I1cae1f646045a456d6e2754917ddef0cda0679f4
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Reviewed-on: https://review.mlplatform.org/c/796
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
-rw-r--r-- | src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NCHWKernel.cpp | 25 | ||||
-rw-r--r-- | src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NHWCKernel.cpp | 25 |
2 files changed, 14 insertions, 36 deletions
diff --git a/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NCHWKernel.cpp b/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NCHWKernel.cpp index eb561faf77..e8efe6f0a9 100644 --- a/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NCHWKernel.cpp +++ b/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NCHWKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -256,29 +256,18 @@ void CLDepthwiseConvolutionLayer3x3NCHWKernel::configure(const ICLTensor *input, if(act_info.enabled()) { - const int a_val = input->info()->quantization_info().quantize(act_info.a(), RoundingPolicy::TO_NEAREST_UP); - const int b_val = input->info()->quantization_info().quantize(act_info.b(), RoundingPolicy::TO_NEAREST_UP); - const int o1 = input->info()->quantization_info().offset; + const int a_val = output->info()->quantization_info().quantize(act_info.a(), RoundingPolicy::TO_NEAREST_UP); + const int b_val = output->info()->quantization_info().quantize(act_info.b(), RoundingPolicy::TO_NEAREST_UP); + const int o1 = output->info()->quantization_info().offset; build_opts.add_option("-DFUSED_ACTIVATION=" + lower_string(string_from_activation_func(act_info.activation()))); build_opts.add_option("-DA_VAL=" + support::cpp11::to_string(a_val)); build_opts.add_option("-DB_VAL=" + support::cpp11::to_string(b_val)); build_opts.add_option("-DCONST_0=" + support::cpp11::to_string(o1)); - if(output != nullptr) - { - const float s1 = input->info()->quantization_info().scale; - const float s2 = output->info()->quantization_info().scale; - const int o2 = output->info()->quantization_info().offset; - - build_opts.add_option("-DS1_VAL=" + float_to_string_with_full_precision(s1)); - build_opts.add_option("-DO1_VAL=" + support::cpp11::to_string(o1)); - if(o1 != o2 || s1 != s2) - { - build_opts.add_option("-DS2_VAL=" + float_to_string_with_full_precision(s2)); - build_opts.add_option("-DO2_VAL=" + support::cpp11::to_string(o2)); - } - } + const float s1 = input->info()->quantization_info().scale; + build_opts.add_option("-DS1_VAL=" + float_to_string_with_full_precision(s1)); + build_opts.add_option("-DO1_VAL=" + support::cpp11::to_string(o1)); } } _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options())); diff --git a/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NHWCKernel.cpp b/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NHWCKernel.cpp index 5e5a35c14c..a82d3a6fae 100644 --- a/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NHWCKernel.cpp +++ b/src/core/CL/kernels/CLDepthwiseConvolutionLayer3x3NHWCKernel.cpp @@ -138,7 +138,7 @@ std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITen } else { - AccessWindowStatic weights_access(weights, 0, 0, ceil_to_multiple(weights->dimension(0), num_elems_accessed_per_iteration), weights->dimension(1)); + AccessWindowStatic weights_access(weights, 0, 0, ceil_to_multiple(weights->dimension(0), num_elems_accessed_per_iteration), weights->dimension(1)); window_changed = update_window_and_padding(win, input_access, weights_access, output_access); } @@ -219,29 +219,18 @@ void CLDepthwiseConvolutionLayer3x3NHWCKernel::configure(const ICLTensor *input, if(act_info.enabled()) { - const int a_val = input->info()->quantization_info().quantize(act_info.a(), RoundingPolicy::TO_NEAREST_UP); - const int b_val = input->info()->quantization_info().quantize(act_info.b(), RoundingPolicy::TO_NEAREST_UP); - const int o1 = input->info()->quantization_info().offset; + const int a_val = output->info()->quantization_info().quantize(act_info.a(), RoundingPolicy::TO_NEAREST_UP); + const int b_val = output->info()->quantization_info().quantize(act_info.b(), RoundingPolicy::TO_NEAREST_UP); + const int o1 = output->info()->quantization_info().offset; build_opts.add_option("-DFUSED_ACTIVATION=" + lower_string(string_from_activation_func(act_info.activation()))); build_opts.add_option("-DA_VAL=" + support::cpp11::to_string(a_val)); build_opts.add_option("-DB_VAL=" + support::cpp11::to_string(b_val)); build_opts.add_option("-DCONST_0=" + support::cpp11::to_string(o1)); - if(output != nullptr) - { - const float s1 = input->info()->quantization_info().scale; - const float s2 = output->info()->quantization_info().scale; - const int o2 = output->info()->quantization_info().offset; - - build_opts.add_option("-DS1_VAL=" + float_to_string_with_full_precision(s1)); - build_opts.add_option("-DO1_VAL=" + support::cpp11::to_string(o1)); - if(o1 != o2 || s1 != s2) - { - build_opts.add_option("-DS2_VAL=" + float_to_string_with_full_precision(s2)); - build_opts.add_option("-DO2_VAL=" + support::cpp11::to_string(o2)); - } - } + const float s1 = input->info()->quantization_info().scale; + build_opts.add_option("-DS1_VAL=" + float_to_string_with_full_precision(s1)); + build_opts.add_option("-DO1_VAL=" + support::cpp11::to_string(o1)); } } else |