aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2018-01-29 13:43:35 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:47:40 +0000
commit995f55252dfaaa5b64075b96272ae11e23d6ca9b (patch)
tree4d7b246645f9dcd1ca5ae5a39f581d55abf600a3
parent8913d8d7bc83fdcb6c5dc9baca6bb369418de48b (diff)
downloadComputeLibrary-995f55252dfaaa5b64075b96272ae11e23d6ca9b.tar.gz
COMPMID-864 Window::collapse_if_possible() is misused in several CL kernels
Removed unnecessary collapse_if_possible() calls. Change-Id: I6f3434bc4a26470c4de5bac4e3d90b4b019c2c9c Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/117993 Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com> Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
-rw-r--r--arm_compute/core/CL/kernels/CLQuantizationLayerKernel.h6
-rw-r--r--arm_compute/core/Window.h10
-rw-r--r--arm_compute/core/Window.inl10
-rw-r--r--src/core/CL/kernels/CLDequantizationLayerKernel.cpp4
-rw-r--r--src/core/CL/kernels/CLMinMaxLayerKernel.cpp15
-rw-r--r--src/core/CL/kernels/CLQuantizationLayerKernel.cpp14
-rw-r--r--src/core/NEON/kernels/NEDequantizationLayerKernel.cpp4
-rw-r--r--src/core/NEON/kernels/NEMinMaxLayerKernel.cpp3
-rw-r--r--src/core/NEON/kernels/NEQuantizationLayerKernel.cpp4
-rw-r--r--src/core/NEON/kernels/NEReshapeLayerKernel.cpp3
10 files changed, 38 insertions, 35 deletions
diff --git a/arm_compute/core/CL/kernels/CLQuantizationLayerKernel.h b/arm_compute/core/CL/kernels/CLQuantizationLayerKernel.h
index 13092400c7..a24ddb1a3a 100644
--- a/arm_compute/core/CL/kernels/CLQuantizationLayerKernel.h
+++ b/arm_compute/core/CL/kernels/CLQuantizationLayerKernel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -51,8 +51,8 @@ public:
~CLQuantizationLayerKernel() = default;
/** Set the input, output, min and max.
*
- * @param[in] input Source tensor. Data types supported: F32.
- * @param[out] output Destination tensor. Data types supported: U8.
+ * @param[in] input Source tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data types supported: F32.
+ * @param[out] output Destination tensor with the same dimensions of input. Output data type must be U8.
* @param[in] min_max Pointer to the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor.
* The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32.
*/
diff --git a/arm_compute/core/Window.h b/arm_compute/core/Window.h
index cca12c9efe..5ca210a112 100644
--- a/arm_compute/core/Window.h
+++ b/arm_compute/core/Window.h
@@ -177,6 +177,16 @@ public:
*/
void shift(size_t dimension, int shift_value);
+ /** Shift down all the dimensions of a window
+ *
+ * i.e new_dims[n] = old_dims[n+shift_value].
+ *
+ * @param[in] shift_value Number of dimensions to shift the window by.
+ *
+ * @return The window with the shifted dimensions.
+ */
+ Window shift_dimensions(unsigned int shift_value) const;
+
/** Adjust the start or end of a given dimension by the given value
*
* @param[in] dimension The dimension to adjust
diff --git a/arm_compute/core/Window.inl b/arm_compute/core/Window.inl
index 23b2a8e322..18d454a0cb 100644
--- a/arm_compute/core/Window.inl
+++ b/arm_compute/core/Window.inl
@@ -77,6 +77,16 @@ inline Window Window::collapse_if_possible(const Window &full_window, const size
return collapsed;
}
+inline Window Window::shift_dimensions(unsigned int shift_value) const
+{
+ Window shifted_window;
+ for(size_t n = 0; n < (Coordinates::num_max_dimensions - shift_value); n++)
+ {
+ shifted_window.set(n, _dims[n + shift_value]);
+ }
+ return shifted_window;
+}
+
inline Window Window::collapse(const Window &full_window, const size_t first, const size_t last) const
{
bool has_collapsed = false;
diff --git a/src/core/CL/kernels/CLDequantizationLayerKernel.cpp b/src/core/CL/kernels/CLDequantizationLayerKernel.cpp
index 216fa2757e..4efdb764bd 100644
--- a/src/core/CL/kernels/CLDequantizationLayerKernel.cpp
+++ b/src/core/CL/kernels/CLDequantizationLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -97,5 +97,5 @@ void CLDequantizationLayerKernel::run(const Window &window, cl::CommandQueue &qu
add_1D_tensor_argument(idx, _min_max, min_max_slice);
enqueue(queue, *this, slice);
}
- while(window.slide_window_slice_3D(slice) && min_max_window.slide_window_slice_1D(min_max_slice));
+ while(window_collapsed.slide_window_slice_3D(slice) && min_max_window.slide_window_slice_1D(min_max_slice));
}
diff --git a/src/core/CL/kernels/CLMinMaxLayerKernel.cpp b/src/core/CL/kernels/CLMinMaxLayerKernel.cpp
index 9b4533bd8d..8ba1f776a1 100644
--- a/src/core/CL/kernels/CLMinMaxLayerKernel.cpp
+++ b/src/core/CL/kernels/CLMinMaxLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -89,7 +89,6 @@ void CLMinMaxLayerKernel::reset(cl::CommandQueue &queue)
Window window_output;
window_output.use_tensor_dimensions(_output->info()->tensor_shape());
window_output.set(Window::DimX, Window::Dimension(0, 1, 1));
- window_output.collapse_if_possible(ICLKernel::window(), 1);
Iterator output(_output, window_output);
@@ -110,27 +109,21 @@ void CLMinMaxLayerKernel::run(const Window &window, cl::CommandQueue &queue)
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window);
- // Collapse min/max batches
Window window_collapsed = window.collapse_if_possible(ICLKernel::window(), 3);
Window slice = window_collapsed.first_slice_window_3D();
slice.set(Window::DimX, Window::Dimension(0, 1, 1));
slice.set(Window::DimY, Window::Dimension(0, 1, 1));
slice.set(Window::DimZ, Window::Dimension(0, 1, 1));
- Window window_output;
- window_output.use_tensor_dimensions(_output->info()->tensor_shape());
- window_output.set(Window::DimX, Window::Dimension(0, 1, 1));
- window_output.collapse_if_possible(ICLKernel::window(), 1);
-
- Window output_slice = window_output.first_slice_window_1D();
-
do
{
+ Window output_slice = slice.shift_dimensions(2);
+
unsigned int idx = 0;
// Set inputs
add_3D_tensor_argument(idx, _input, slice);
add_1D_tensor_argument(idx, _output, output_slice);
enqueue(queue, *this, slice);
}
- while(window.slide_window_slice_3D(slice) && window_output.slide_window_slice_1D(output_slice));
+ while(window_collapsed.slide_window_slice_3D(slice));
}
diff --git a/src/core/CL/kernels/CLQuantizationLayerKernel.cpp b/src/core/CL/kernels/CLQuantizationLayerKernel.cpp
index 47564436a9..8b082a8704 100644
--- a/src/core/CL/kernels/CLQuantizationLayerKernel.cpp
+++ b/src/core/CL/kernels/CLQuantizationLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -82,20 +82,16 @@ void CLQuantizationLayerKernel::run(const Window &window, cl::CommandQueue &queu
Window window_collapsed = window.collapse_if_possible(ICLKernel::window(), 3);
Window slice = window_collapsed.first_slice_window_3D();
- Window window_min_max;
- window_min_max.use_tensor_dimensions(_min_max->info()->tensor_shape());
- window_min_max.set(Window::DimX, Window::Dimension(0, 1, 1));
- window_min_max.collapse_if_possible(ICLKernel::window(), 1);
-
- Window slice_min_max = window_min_max.first_slice_window_1D();
-
do
{
+ Window slice_min_max = slice.shift_dimensions(2);
+ slice_min_max.set(Window::DimX, Window::Dimension(0, 1, 1));
+
unsigned int idx = 0;
add_3D_tensor_argument(idx, _input, slice);
add_3D_tensor_argument(idx, _output, slice);
add_1D_tensor_argument(idx, _min_max, slice_min_max);
enqueue(queue, *this, slice);
}
- while(window.slide_window_slice_3D(slice) && window_min_max.slide_window_slice_1D(slice_min_max));
+ while(window_collapsed.slide_window_slice_3D(slice));
}
diff --git a/src/core/NEON/kernels/NEDequantizationLayerKernel.cpp b/src/core/NEON/kernels/NEDequantizationLayerKernel.cpp
index 70984f0a75..be211b2cb2 100644
--- a/src/core/NEON/kernels/NEDequantizationLayerKernel.cpp
+++ b/src/core/NEON/kernels/NEDequantizationLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -78,13 +78,11 @@ void NEDequantizationLayerKernel::run(const Window &window, const ThreadInfo &in
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
Window window_input_output(window);
- window_input_output.collapse_if_possible(INEKernel::window(), 3);
window_input_output.set(3, Window::Dimension(0, 1, 1));
Window window_min_max;
window_min_max.use_tensor_dimensions(_min_max->info()->tensor_shape());
window_min_max.set(Window::DimX, Window::Dimension(0, 1, 1));
- window_min_max.collapse_if_possible(INEKernel::window(), 1);
Iterator input(_input, window_input_output);
Iterator output(_output, window_input_output);
diff --git a/src/core/NEON/kernels/NEMinMaxLayerKernel.cpp b/src/core/NEON/kernels/NEMinMaxLayerKernel.cpp
index a81725fe84..01be36b1c6 100644
--- a/src/core/NEON/kernels/NEMinMaxLayerKernel.cpp
+++ b/src/core/NEON/kernels/NEMinMaxLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -96,7 +96,6 @@ void NEMinMaxLayerKernel::run(const Window &window, const ThreadInfo &info)
// First one will use vector operations, second one processes the left over pixels
Window window_input(window);
window_input.set(Window::DimX, Window::Dimension(0, 1, 1));
- window_input.collapse_if_possible(INEKernel::window(), 3);
window_input.set(3, Window::Dimension(0, 1, 1));
Iterator input(_input, window_input);
diff --git a/src/core/NEON/kernels/NEQuantizationLayerKernel.cpp b/src/core/NEON/kernels/NEQuantizationLayerKernel.cpp
index bff79f0f0c..767af08d0d 100644
--- a/src/core/NEON/kernels/NEQuantizationLayerKernel.cpp
+++ b/src/core/NEON/kernels/NEQuantizationLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -77,13 +77,11 @@ void NEQuantizationLayerKernel::run(const Window &window, const ThreadInfo &info
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
Window window_input_output(window);
- window_input_output.collapse_if_possible(INEKernel::window(), 3);
window_input_output.set(3, Window::Dimension(0, 1, 1));
Window window_min_max;
window_min_max.use_tensor_dimensions(_min_max->info()->tensor_shape());
window_min_max.set(Window::DimX, Window::Dimension(0, 1, 1));
- window_min_max.collapse_if_possible(INEKernel::window(), 1);
Iterator input(_input, window_input_output);
Iterator output(_output, window_input_output);
diff --git a/src/core/NEON/kernels/NEReshapeLayerKernel.cpp b/src/core/NEON/kernels/NEReshapeLayerKernel.cpp
index a0f324ef18..45ba68d9fa 100644
--- a/src/core/NEON/kernels/NEReshapeLayerKernel.cpp
+++ b/src/core/NEON/kernels/NEReshapeLayerKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -46,7 +46,6 @@ inline void reshape_tensor(const Window &window, const ITensor *input, ITensor *
const TensorShape &output_shape = output->info()->tensor_shape();
Coordinates output_coord{};
- window.collapse_if_possible(window, 3);
Iterator in(input, window);
execute_window_loop(window, [&](const Coordinates & id)