aboutsummaryrefslogtreecommitdiff
path: root/src/core/NEON/kernels/NECol2ImKernel.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-11-27 21:00:13 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:41:36 +0000
commitd912fd8eaaa56aac90f2b0b118c76f24ba8efa02 (patch)
tree1474ecd7ddb8218c6471d2e2a2273e6060bcf0b5 /src/core/NEON/kernels/NECol2ImKernel.cpp
parentb6f182d3e5b69cc193d7e5ec397c4d61083572d5 (diff)
downloadComputeLibrary-d912fd8eaaa56aac90f2b0b118c76f24ba8efa02.tar.gz
COMPMID-617: Add validation to NEON functions.
Adds validation to: - NECol2Im - NEIm2Col Change-Id: I346298583a6985ea793f71bb4527aa216a5cd4b2 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/110835 Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com <bsgcomp@arm.com> Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/core/NEON/kernels/NECol2ImKernel.cpp')
-rw-r--r--src/core/NEON/kernels/NECol2ImKernel.cpp58
1 files changed, 43 insertions, 15 deletions
diff --git a/src/core/NEON/kernels/NECol2ImKernel.cpp b/src/core/NEON/kernels/NECol2ImKernel.cpp
index 68fc50ced6..ca769f73cc 100644
--- a/src/core/NEON/kernels/NECol2ImKernel.cpp
+++ b/src/core/NEON/kernels/NECol2ImKernel.cpp
@@ -36,6 +36,37 @@
using namespace arm_compute;
+namespace
+{
+TensorShape get_output_shape(const ITensorInfo *input, const Size2D &convolved_dims)
+{
+ TensorShape output_shape = input->tensor_shape();
+ output_shape.set(0, convolved_dims.width);
+ output_shape.set(1, convolved_dims.height);
+ output_shape.set(2, input->tensor_shape()[0]);
+
+ return output_shape;
+}
+
+Error validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const Size2D &convolved_dims)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8, DataType::S8, DataType::QS8, DataType::QASYMM8,
+ DataType::U16, DataType::S16, DataType::QS16,
+ DataType::U32, DataType::S32,
+ DataType::F16, DataType::F32);
+
+ // Validate configured output
+ if(output->total_size() != 0)
+ {
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), get_output_shape(input, convolved_dims));
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_FIXED_POINT(input, output);
+ }
+
+ return Error{};
+}
+} // namespace
+
template <typename T>
void NECol2ImKernel::run_col2im(const Window &window)
{
@@ -55,7 +86,7 @@ void NECol2ImKernel::run_col2im(const Window &window)
execute_window_loop(window, [&](const Coordinates & id)
{
const int hidx = id.y();
- const int idx = id.x() * output_stride_z + (hidx / _convolved_dims.first) * output_stride_y + (hidx % _convolved_dims.first) * output_stride_x;
+ const int idx = id.x() * output_stride_z + (hidx / _convolved_dims.width) * output_stride_y + (hidx % _convolved_dims.width) * output_stride_x;
*(reinterpret_cast<T *>(out.ptr() + idx)) = *(reinterpret_cast<const T *>(in.ptr()));
},
@@ -67,24 +98,15 @@ NECol2ImKernel::NECol2ImKernel()
{
}
-void NECol2ImKernel::configure(const ITensor *input, ITensor *output, std::pair<unsigned int, unsigned int> convolved_dims)
+void NECol2ImKernel::configure(const ITensor *input, ITensor *output, const Size2D &convolved_dims)
{
- ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8, DataType::S8, DataType::QS8, DataType::QASYMM8, DataType::U16, DataType::S16, DataType::QS16, DataType::U32, DataType::S32,
- DataType::F16,
- DataType::F32);
- ARM_COMPUTE_ERROR_ON_NULLPTR(output);
-
- TensorShape output_shape = input->info()->tensor_shape();
- output_shape.set(0, convolved_dims.first);
- output_shape.set(1, convolved_dims.second);
- output_shape.set(2, input->info()->tensor_shape()[0]);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
// Output auto inizialitation if not yet initialized
- auto_init_if_empty(*output->info(), output_shape, 1, input->info()->data_type(), input->info()->fixed_point_position());
+ auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(get_output_shape(input->info(), convolved_dims)));
- ARM_COMPUTE_ERROR_ON_MISMATCHING_DIMENSIONS(output->info()->tensor_shape(), output_shape);
- ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
- ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, output);
+ // Perform validation step
+ ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), convolved_dims));
_input = input;
_output = output;
@@ -117,6 +139,12 @@ void NECol2ImKernel::configure(const ITensor *input, ITensor *output, std::pair<
INEKernel::configure(win);
}
+Error NECol2ImKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &convolved_dims)
+{
+ ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, convolved_dims));
+ return Error{};
+}
+
void NECol2ImKernel::run(const Window &window, const ThreadInfo &info)
{
ARM_COMPUTE_UNUSED(info);