diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-12-13 12:33:09 +0000 |
---|---|---|
committer | Pablo Marquez <pablo.tello@arm.com> | 2019-12-19 14:18:23 +0000 |
commit | 14d9d986c63eb8f07acec2f075383f9f4843ae1c (patch) | |
tree | 543b9fc7781f7e2deba0287fbacd69d27fd16840 /src/core/CL/kernels/CLScaleKernel.cpp | |
parent | d7d7e9035ca28b1b5200b20a73825397d46830fc (diff) | |
download | ComputeLibrary-14d9d986c63eb8f07acec2f075383f9f4843ae1c.tar.gz |
COMPMID-2819: Retain configuration step data layout to avoid side-effects.
Configuring functions serially can lead to side-effects in tensor
attributes. One of them is the data layout changing in case functions
share same IO tensors. Retain DataLayout used during configuration.
Change-Id: I17538ce08b86df6986f0fcf21fa6544fbd5bd74b
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Reviewed-on: https://review.mlplatform.org/c/2470
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Giorgio Arena <giorgio.arena@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLScaleKernel.cpp')
-rw-r--r-- | src/core/CL/kernels/CLScaleKernel.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/CL/kernels/CLScaleKernel.cpp b/src/core/CL/kernels/CLScaleKernel.cpp index 488313fd12..82c5c8a446 100644 --- a/src/core/CL/kernels/CLScaleKernel.cpp +++ b/src/core/CL/kernels/CLScaleKernel.cpp @@ -160,11 +160,12 @@ const ICLTensor *CLScaleKernel::output() const void CLScaleKernel::configure(const ICLTensor *input, ICLTensor *output, InterpolationPolicy policy, BorderMode border_mode, SamplingPolicy sampling_policy) { + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), policy)); + _input = input; _output = output; _interpolationPolicy = policy; - - ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), policy)); + _data_layout = input->info()->data_layout(); float wr = 0.f; float hr = 0.f; @@ -172,10 +173,9 @@ void CLScaleKernel::configure(const ICLTensor *input, ICLTensor *output, Interpo const bool call_quantized_kernel = is_data_type_quantized_asymmetric(input->info()->data_type()) && policy == InterpolationPolicy::BILINEAR; - DataLayout data_layout = input->info()->data_layout(); - const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); - const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); - const bool is_nhwc = data_layout == DataLayout::NHWC; + const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); + const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); + const bool is_nhwc = _data_layout == DataLayout::NHWC; // Compute the ratio between source width/height and destination width/height const unsigned int input_width = input->info()->dimension(idx_width); @@ -215,7 +215,7 @@ void CLScaleKernel::configure(const ICLTensor *input, ICLTensor *output, Interpo std::transform(interpolation_name.begin(), interpolation_name.end(), interpolation_name.begin(), ::tolower); std::string kernel_name = "scale_" + interpolation_name; kernel_name += call_quantized_kernel ? "_quantized_" : "_"; - kernel_name += lower_string(string_from_data_layout(data_layout)); + kernel_name += lower_string(string_from_data_layout(_data_layout)); _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options())); unsigned int idx = is_nhwc ? 2 * num_arguments_per_4D_tensor() : 2 * num_arguments_per_2D_tensor(); //Skip the input and output parameters @@ -249,7 +249,7 @@ void CLScaleKernel::run(const Window &window, cl::CommandQueue &queue) ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); - switch(_input->info()->data_layout()) + switch(_data_layout) { case DataLayout::NCHW: { |