aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/kernels/CLPoolingLayerKernel.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-10-30 14:13:50 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit3faea25fe0bcb9f72bfe3da185085ed634d1b162 (patch)
treea53a50bf9e889b9d913dc47d5375a382aed57e58 /src/core/CL/kernels/CLPoolingLayerKernel.cpp
parentb5908c257d554009a00de3aaa95b3721000ed185 (diff)
downloadComputeLibrary-3faea25fe0bcb9f72bfe3da185085ed634d1b162.tar.gz
COMPMID-617: Adds validation to CLPoolingLayer
Change-Id: Ied405a9c0e9746598d03ac6a944ad87e9b6494eb Reviewed-on: http://mpd-gerrit.cambridge.arm.com/93680 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLPoolingLayerKernel.cpp')
-rw-r--r--src/core/CL/kernels/CLPoolingLayerKernel.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/CL/kernels/CLPoolingLayerKernel.cpp b/src/core/CL/kernels/CLPoolingLayerKernel.cpp
index 8b8f61e621..19d36a6ac6 100644
--- a/src/core/CL/kernels/CLPoolingLayerKernel.cpp
+++ b/src/core/CL/kernels/CLPoolingLayerKernel.cpp
@@ -179,6 +179,38 @@ void CLPoolingLayerKernel::configure(const ICLTensor *input, ICLTensor *output,
ICLKernel::configure(win);
}
+Error CLPoolingLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QS8, DataType::QS16, DataType::F16, DataType::F32);
+
+ int pool_pad_x = 0;
+ int pool_pad_y = 0;
+ int pool_size = pool_info.pool_size();
+ std::tie(pool_pad_x, pool_pad_y) = pool_info.pad_stride_info().pad();
+ ARM_COMPUTE_RETURN_ERROR_ON_MSG(((pool_pad_x >= pool_size) || (pool_pad_y >= pool_size)),
+ "Invalid pool size and pool pad combination");
+
+ // Checks performed when output is configured
+ if(output->total_size() != 0)
+ {
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_FIXED_POINT(input, output);
+
+ unsigned int pooled_w = 0;
+ unsigned int pooled_h = 0;
+ std::tie(pooled_w, pooled_h) = scaled_dimensions(input->dimension(0),
+ input->dimension(1),
+ pool_size,
+ pool_size,
+ pool_info.pad_stride_info());
+ ARM_COMPUTE_RETURN_ERROR_ON_MSG((output->dimension(0) != pooled_w) != (output->dimension(1) != pooled_h),
+ "Invalid output pooling dimensions!");
+ }
+
+ return Error{};
+}
+
void CLPoolingLayerKernel::run(const Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);