aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/kernels/CLNormalizationLayerKernel.cpp
diff options
context:
space:
mode:
authorGian Marco Iodice <gianmarco.iodice@arm.com>2017-08-10 10:43:40 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commitd60a6b9d7977c6bd63ff7c523bed84d42363898b (patch)
tree4b1ef99dfd76883060688dcaadbadaaf5c14cf6d /src/core/CL/kernels/CLNormalizationLayerKernel.cpp
parent4e09b3839206254d0df56095ad0762718a764c9c (diff)
downloadComputeLibrary-d60a6b9d7977c6bd63ff7c523bed84d42363898b.tar.gz
COMPMID-477 - Optimized CLNormalizationLayer
CLPixelWiseMultiplication has been removed within the function Change-Id: Ibe7edd7921d5cef6ff68fdeeca89771129a8eaea Reviewed-on: http://mpd-gerrit.cambridge.arm.com/84459 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLNormalizationLayerKernel.cpp')
-rw-r--r--src/core/CL/kernels/CLNormalizationLayerKernel.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/core/CL/kernels/CLNormalizationLayerKernel.cpp b/src/core/CL/kernels/CLNormalizationLayerKernel.cpp
index b382e9d510..a74473980b 100644
--- a/src/core/CL/kernels/CLNormalizationLayerKernel.cpp
+++ b/src/core/CL/kernels/CLNormalizationLayerKernel.cpp
@@ -36,7 +36,7 @@
using namespace arm_compute;
CLNormalizationLayerKernel::CLNormalizationLayerKernel()
- : _input(nullptr), _squared_input(nullptr), _output(nullptr), _border_size(0), _is_in_map(false)
+ : _input(nullptr), _output(nullptr), _border_size(0), _is_in_map(false)
{
}
@@ -45,7 +45,7 @@ BorderSize CLNormalizationLayerKernel::border_size() const
return _border_size;
}
-void CLNormalizationLayerKernel::configure(const ICLTensor *input, const ICLTensor *squared_input, ICLTensor *output, NormalizationLayerInfo norm_info)
+void CLNormalizationLayerKernel::configure(const ICLTensor *input, ICLTensor *output, NormalizationLayerInfo norm_info)
{
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QS8, DataType::QS16, DataType::F16, DataType::F32);
ARM_COMPUTE_ERROR_ON_NULLPTR(output);
@@ -53,21 +53,20 @@ void CLNormalizationLayerKernel::configure(const ICLTensor *input, const ICLTens
// Output tensor auto initialization if not yet initialized
auto_init_if_empty(*output->info(), input->info()->tensor_shape(), 1, input->info()->data_type(), input->info()->fixed_point_position());
- ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, squared_input, output);
- ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(input, squared_input, output);
+ ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
+ ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(input, output);
ARM_COMPUTE_ERROR_ON_MSG(!(norm_info.norm_size() % 2), "Normalization size should be odd");
ARM_COMPUTE_ERROR_ON_MSG(norm_info.type() == NormType::IN_MAP_2D, "2D In-Map Normalization not implemented");
if(is_data_type_fixed_point(input->info()->data_type()))
{
- ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, squared_input, output);
+ ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, output);
ARM_COMPUTE_ERROR_ON_VALUE_NOT_REPRESENTABLE_IN_FIXED_POINT(norm_info.beta(), input);
ARM_COMPUTE_ERROR_ON_VALUE_NOT_REPRESENTABLE_IN_FIXED_POINT(norm_info.kappa(), input);
ARM_COMPUTE_ERROR_ON_VALUE_NOT_REPRESENTABLE_IN_FIXED_POINT(norm_info.scale_coeff(), input);
}
- _input = input;
- _squared_input = squared_input;
- _output = output;
+ _input = input;
+ _output = output;
_is_in_map = (norm_info.type() != NormType::CROSS_MAP);
const unsigned int border_width = _is_in_map ? std::min(norm_info.norm_size() / 2, 3U) : 0;
@@ -87,23 +86,20 @@ void CLNormalizationLayerKernel::configure(const ICLTensor *input, const ICLTens
build_opts.emplace(("-DBETA=" + float_to_string_with_full_precision(norm_info.beta())));
build_opts.emplace(("-DKAPPA=" + float_to_string_with_full_precision(norm_info.kappa())));
build_opts.emplace(("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration)));
+ build_opts.emplace(("-DRADIUS=" + support::cpp11::to_string(norm_info.norm_size() / 2)));
+ build_opts.emplace(("-DNUM_SLICES=" + support::cpp11::to_string(input->info()->dimension(2))));
// Create kernel
std::string kernel_name = (norm_info.type() == NormType::IN_MAP_1D) ? "normalization_layer_in_map_1D" : "normalization_layer_cross_map";
_kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts));
- // Set kernel static arguments
- unsigned int idx = 3 * num_arguments_per_3D_tensor(); // Skip the input and output parameters
- _kernel.setArg<cl_uint>(idx++, norm_info.norm_size() / 2);
-
// Configure kernel window
Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration));
AccessWindowHorizontal input_access(input->info(), -_border_size.left, num_elems_read_per_iteration);
- AccessWindowHorizontal squared_input_access(squared_input->info(), -_border_size.left, num_elems_read_per_iteration);
AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration);
- update_window_and_padding(win, input_access, squared_input_access, output_access);
+ update_window_and_padding(win, input_access, output_access);
output_access.set_valid_region(win, input->info()->valid_region());
@@ -123,7 +119,6 @@ void CLNormalizationLayerKernel::run(const Window &window, cl::CommandQueue &que
{
unsigned int idx = 0;
add_3D_tensor_argument(idx, _input, slice);
- add_3D_tensor_argument(idx, _squared_input, slice);
add_3D_tensor_argument(idx, _output, slice);
enqueue(queue, *this, slice);
}