aboutsummaryrefslogtreecommitdiff
path: root/src/core/Utils.cpp
diff options
context:
space:
mode:
authorPablo Tello <pablo.tello@arm.com>2017-08-22 13:34:13 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commitf5f34bb068565bf9435ba5561aae1c9280db8bbe (patch)
tree9920a815ee9653c3b97a09f90d765cb4efb7af06 /src/core/Utils.cpp
parent43fc5cd712eed23b9cec340f526e6d5fb5050afa (diff)
downloadComputeLibrary-f5f34bb068565bf9435ba5561aae1c9280db8bbe.tar.gz
COMPMID-470: Neon Deconvolution.
Implemented by up-sampling the input with zeros insertions between the input samples and convolving the Deconvolution kernels on the up-sampled result. The upsampling is performed by the function NEDeconvolutionLayerUpsample. Convolving is done by NEDirectConvolutionLayer. Change-Id: I25f7ba7c6b99cd9310797972ede40aeff4a54900 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/85319 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/core/Utils.cpp')
-rw-r--r--src/core/Utils.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp
index 99d39569c7..d5ce1ea027 100644
--- a/src/core/Utils.cpp
+++ b/src/core/Utils.cpp
@@ -247,6 +247,43 @@ std::string arm_compute::lower_string(const std::string &val)
return res;
}
+TensorShape arm_compute::deconvolution_output_shape(const std::pair<unsigned int, unsigned int> &out_dims, TensorShape input, TensorShape weights)
+{
+ TensorShape out_shape(input);
+ out_shape.set(0, out_dims.first);
+ out_shape.set(1, out_dims.second);
+ out_shape.set(2, weights[3]);
+ return out_shape;
+}
+
+const std::pair<unsigned int, unsigned int> arm_compute::deconvolution_output_dimensions(
+ unsigned int in_width, unsigned int in_height, unsigned int kernel_width, unsigned int kernel_height, unsigned int padx, unsigned int pady,
+ unsigned int ax, unsigned int ay, float upscalex, float upscaley, DimensionRoundingType round)
+{
+ ARM_COMPUTE_ERROR_ON(in_width < 1 || in_height < 1);
+ ARM_COMPUTE_ERROR_ON(((in_width - 1) * upscalex + kernel_width + ax) < 2.f * padx);
+ ARM_COMPUTE_ERROR_ON(((in_height - 1) * upscaley + kernel_height + ay) < 2.f * pady);
+ const float fw = (in_width - 1) * upscalex - 2.f * padx + kernel_width + ax;
+ const float fh = (in_height - 1) * upscaley - 2.f * pady + kernel_height + ay;
+ int w = 0;
+ int h = 0;
+ switch(round)
+ {
+ case DimensionRoundingType::FLOOR:
+ w = std::floor(fw);
+ h = std::floor(fh);
+ break;
+ case DimensionRoundingType::CEIL:
+ w = std::ceil(fw);
+ h = std::ceil(fh);
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Not supported");
+ break;
+ }
+ return std::make_pair<unsigned int, unsigned int>(w, h);
+}
+
const std::pair<unsigned int, unsigned int> arm_compute::scaled_dimensions(unsigned int width, unsigned int height,
unsigned int kernel_width, unsigned int kernel_height,
const PadStrideInfo &pad_stride_info)