diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-06-19 13:02:56 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:14:20 +0100 |
commit | 4cbee6e66f4425a3ab5bfac3bbf400e6818a224d (patch) | |
tree | a7ce1ed077c7d5ce1041f8cfc44454a7d55f9bf2 | |
parent | ce093143ec7b554edefc533c90e45c80946cde51 (diff) | |
download | ComputeLibrary-4cbee6e66f4425a3ab5bfac3bbf400e6818a224d.tar.gz |
COMPMID-345: Scale input valid region in TransposeWindow.
Change-Id: I880e85834acc42d9d15b38ceeaadbaee9690a484
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78093
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
-rw-r--r-- | src/core/AccessWindowTranspose.cpp | 4 | ||||
-rw-r--r-- | src/core/CL/kernels/CLGEMMTranspose1xWKernel.cpp | 27 | ||||
-rw-r--r-- | src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp | 3 | ||||
-rw-r--r-- | tests/dataset/ConvolutionLayerDataset.h | 4 |
4 files changed, 12 insertions, 26 deletions
diff --git a/src/core/AccessWindowTranspose.cpp b/src/core/AccessWindowTranspose.cpp index b3605c43f7..b1043305b8 100644 --- a/src/core/AccessWindowTranspose.cpp +++ b/src/core/AccessWindowTranspose.cpp @@ -66,8 +66,8 @@ ValidRegion AccessWindowTranspose::compute_valid_region(const Window &window, Va // a size of the region. // As the relation between input and output is transposed window.y() is // used for x shape and window.x() for y shape. - shape.set(0, std::min<int>(old_anchor[1] + old_shape[1] - border_size.right, (window.y().end() - window.y().step()) * _scale_x + _width) - anchor[0]); - shape.set(1, std::min<int>(old_anchor[0] + old_shape[0] - border_size.bottom, (window.x().end() - window.x().step()) * _scale_y + _height) - anchor[1]); + shape.set(0, std::min<int>((old_anchor[1] + old_shape[1]) * _scale_x - border_size.right, (window.y().end() - window.y().step()) * _scale_x + _width) - anchor[0]); + shape.set(1, std::min<int>((old_anchor[0] + old_shape[0]) * _scale_y - border_size.bottom, (window.x().end() - window.x().step()) * _scale_y + _height) - anchor[1]); // For higher dimensions use the intersection of the window size and the // valid region of the input diff --git a/src/core/CL/kernels/CLGEMMTranspose1xWKernel.cpp b/src/core/CL/kernels/CLGEMMTranspose1xWKernel.cpp index ecee1abd72..4067280bf0 100644 --- a/src/core/CL/kernels/CLGEMMTranspose1xWKernel.cpp +++ b/src/core/CL/kernels/CLGEMMTranspose1xWKernel.cpp @@ -54,9 +54,12 @@ void CLGEMMTranspose1xWKernel::configure(const ICLTensor *input, ICLTensor *outp ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); ARM_COMPUTE_ERROR_ON_MISMATCHING_DIMENSIONS(output->info()->tensor_shape(), output_shape); - _input = input; - _output = output; const unsigned int num_elems_processed_per_iteration = max_cl_vector_width / data_size_from_type(input->info()->data_type()); + const float scale_x = num_elems_processed_per_iteration; + ARM_COMPUTE_ERROR_ON((0 == static_cast<int>(input->info()->dimension(0) * (1.f / scale_x)))); + + _input = input; + _output = output; /* * Following an example of how the transposition1xW works when the input data type is F32 @@ -77,30 +80,12 @@ void CLGEMMTranspose1xWKernel::configure(const ICLTensor *input, ICLTensor *outp // Configure window Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration)); - float scale_x = 1.f; - - switch(input->info()->data_type()) - { - case DataType::U8: - scale_x = 16.f; - break; - case DataType::F16: - scale_x = 8.f; - break; - case DataType::F32: - scale_x = 4.f; - break; - default: - // Do nothing - break; - } - AccessWindowHorizontal input_access(input->info(), 0, num_elems_processed_per_iteration); AccessWindowTranspose output_access(output->info(), 0, 0, num_elems_processed_per_iteration, 1, scale_x, 1.f / scale_x); update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), input->info()->tensor_shape())); ICLKernel::configure(win); } diff --git a/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp b/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp index ccf5cb4de3..38e7eaee78 100644 --- a/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp +++ b/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp @@ -59,6 +59,7 @@ void NEGEMMTranspose1xWKernel::configure(const ITensor *input, ITensor *output) const unsigned int num_elems_processed_per_iteration = 16 / input->info()->element_size(); const float scale_x = num_elems_processed_per_iteration; + ARM_COMPUTE_ERROR_ON((0 == static_cast<int>(input->info()->dimension(0) * (1.f / scale_x)))); _input = input; _output = output; @@ -71,7 +72,7 @@ void NEGEMMTranspose1xWKernel::configure(const ITensor *input, ITensor *output) AccessWindowHorizontal(input->info(), 0, num_elems_processed_per_iteration), output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), input->info()->tensor_shape())); INEKernel::configure(win); } diff --git a/tests/dataset/ConvolutionLayerDataset.h b/tests/dataset/ConvolutionLayerDataset.h index e66117e0d8..85f46cceb5 100644 --- a/tests/dataset/ConvolutionLayerDataset.h +++ b/tests/dataset/ConvolutionLayerDataset.h @@ -80,8 +80,8 @@ public: : GenericDataset { ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 11U), TensorShape(11U), TensorShape(11U, 12U, 11U), PadStrideInfo(3, 2, 1, 0) }, - ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 5U, 2U, 5U), TensorShape(5U), TensorShape(15U, 15U, 5U, 7U), PadStrideInfo(1, 2, 1, 1) } + ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U), PadStrideInfo(3, 2, 1, 0) }, + ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U, 7U), PadStrideInfo(1, 2, 1, 1) } } { } |