aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-12-19 16:23:17 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2019-01-14 16:26:50 +0000
commitdea2d2d58fe3a742e6f66fe50befbe0044e15ad1 (patch)
tree87c30d892f45b8cc2de5fdb2c825d9ff05de7fae
parent053e7510f24c2b02f9fae9c45fb6b874631a5376 (diff)
downloadComputeLibrary-dea2d2d58fe3a742e6f66fe50befbe0044e15ad1.tar.gz
COMPMID-1772: Implement PadV2 for NEON
Change-Id: Ia4604524a034c46b004fd850183480c5fbfd8cb3 Reviewed-on: https://review.mlplatform.org/437 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
-rw-r--r--arm_compute/core/NEON/NEKernels.h1
-rw-r--r--arm_compute/core/NEON/kernels/NEMemsetKernel.h71
-rw-r--r--arm_compute/core/utils/misc/ShapeCalculator.h4
-rw-r--r--arm_compute/runtime/CL/functions/CLPadLayer.h24
-rw-r--r--arm_compute/runtime/NEON/NEFunctions.h1
-rw-r--r--arm_compute/runtime/NEON/functions/NEPadLayer.h79
-rw-r--r--src/core/NEON/kernels/NEMemsetKernel.cpp82
-rw-r--r--src/runtime/CL/functions/CLPadLayer.cpp12
-rw-r--r--src/runtime/NEON/functions/NEPadLayer.cpp108
-rw-r--r--tests/validation/CL/PadLayer.cpp (renamed from tests/validation/CL/Padding.cpp)6
-rw-r--r--tests/validation/NEON/PadLayer.cpp184
-rw-r--r--tests/validation/fixtures/PadLayerFixture.h3
12 files changed, 552 insertions, 23 deletions
diff --git a/arm_compute/core/NEON/NEKernels.h b/arm_compute/core/NEON/NEKernels.h
index a99b7d08e1..b7810cbd51 100644
--- a/arm_compute/core/NEON/NEKernels.h
+++ b/arm_compute/core/NEON/NEKernels.h
@@ -94,6 +94,7 @@
#include "arm_compute/core/NEON/kernels/NEMagnitudePhaseKernel.h"
#include "arm_compute/core/NEON/kernels/NEMeanStdDevKernel.h"
#include "arm_compute/core/NEON/kernels/NEMedian3x3Kernel.h"
+#include "arm_compute/core/NEON/kernels/NEMemsetKernel.h"
#include "arm_compute/core/NEON/kernels/NEMinMaxLayerKernel.h"
#include "arm_compute/core/NEON/kernels/NEMinMaxLocationKernel.h"
#include "arm_compute/core/NEON/kernels/NENonLinearFilterKernel.h"
diff --git a/arm_compute/core/NEON/kernels/NEMemsetKernel.h b/arm_compute/core/NEON/kernels/NEMemsetKernel.h
new file mode 100644
index 0000000000..721ecf9ae2
--- /dev/null
+++ b/arm_compute/core/NEON/kernels/NEMemsetKernel.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2018-2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_NEMEMSETKERNEL_H__
+#define __ARM_COMPUTE_NEMEMSETKERNEL_H__
+
+#include "arm_compute/core/NEON/INEKernel.h"
+#include "arm_compute/core/PixelValue.h"
+#include "arm_compute/core/Types.h"
+
+namespace arm_compute
+{
+// Forward declarations
+class ITensor;
+
+/** Interface for filling the planes of a tensor */
+class NEMemsetKernel : public INEKernel
+{
+public:
+ const char *name() const override
+ {
+ return "NEMemsetKernel";
+ }
+ /** Default constructor */
+ NEMemsetKernel();
+ /** Default destructor */
+ ~NEMemsetKernel() = default;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEMemsetKernel(const NEMemsetKernel &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEMemsetKernel &operator=(const NEMemsetKernel &) = delete;
+ /** Allow instances of this class to be moved */
+ NEMemsetKernel(NEMemsetKernel &&) = default;
+ /** Allow instances of this class to be moved */
+ NEMemsetKernel &operator=(NEMemsetKernel &&) = default;
+ /** Initialise the kernel's tensor and filling value
+ *
+ * @param[in,out] tensor Input tensor to fill. Supported data types: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32
+ * @param[in] constant_value The value used to fill the planes of the tensor
+ */
+ void configure(ITensor *tensor, const PixelValue &constant_value);
+
+ // Inherited methods overridden:
+ void run(const Window &window, const ThreadInfo &info) override;
+
+private:
+ ITensor *_tensor;
+ PixelValue _constant_value;
+};
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_NEMEMSETKERNEL_H__ */
diff --git a/arm_compute/core/utils/misc/ShapeCalculator.h b/arm_compute/core/utils/misc/ShapeCalculator.h
index 619234d306..f8a6df7fe7 100644
--- a/arm_compute/core/utils/misc/ShapeCalculator.h
+++ b/arm_compute/core/utils/misc/ShapeCalculator.h
@@ -1011,7 +1011,9 @@ inline TensorShape compute_padded_shape(const TensorShape &input_shape, const Pa
TensorShape padded_shape = input_shape;
for(size_t dim = 0; dim < padding.size(); ++dim)
{
- padded_shape.set(dim, padding[dim].first + input_shape[dim] + padding[dim].second);
+ const auto &padding_pair = padding[dim];
+ const uint32_t shape_on_index = (padded_shape.num_dimensions() <= dim) ? 1 : input_shape[dim];
+ padded_shape.set(dim, padding_pair.first + shape_on_index + padding_pair.second);
}
return padded_shape;
}
diff --git a/arm_compute/runtime/CL/functions/CLPadLayer.h b/arm_compute/runtime/CL/functions/CLPadLayer.h
index b9dca665d0..1ecf82fa7c 100644
--- a/arm_compute/runtime/CL/functions/CLPadLayer.h
+++ b/arm_compute/runtime/CL/functions/CLPadLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 ARM Limited.
+ * Copyright (c) 2018-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -49,21 +49,23 @@ public:
/** Initialize the function
*
- * @param[in] input Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
- * @param[out] output Output tensor. Data type supported: same as @p input
- * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
- * specifies the front and the end padding in the i-th dimension.
+ * @param[in] input Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
+ * @param[out] output Output tensor. Data type supported: same as @p input
+ * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
+ * specifies the front and the end padding in the i-th dimension.
+ * @param[in] constant_value (Optional) Constant value to be used for the padding
*/
- void configure(ICLTensor *input, ICLTensor *output, const PaddingList &padding);
+ void configure(ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value = PixelValue());
/** Static function to check if given info will lead to a valid configuration of @ref CLPadLayer.
*
- * @param[in] input Source tensor info. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
- * @param[in] output Output tensor info. Data type supported: same as @p input
- * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
- * specifies the front and the end padding in the i-th dimension.
+ * @param[in] input Source tensor info. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
+ * @param[in] output Output tensor info. Data type supported: same as @p input
+ * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
+ * specifies the front and the end padding in the i-th dimension.
+ * @param[in] constant_value (Optional) Constant value to be used for the padding
*/
- static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding);
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value = PixelValue());
// Inherited methods overridden:
void run() override;
diff --git a/arm_compute/runtime/NEON/NEFunctions.h b/arm_compute/runtime/NEON/NEFunctions.h
index ceebc7b844..606f282e16 100644
--- a/arm_compute/runtime/NEON/NEFunctions.h
+++ b/arm_compute/runtime/NEON/NEFunctions.h
@@ -99,6 +99,7 @@
#include "arm_compute/runtime/NEON/functions/NENonMaximaSuppression3x3.h"
#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h"
#include "arm_compute/runtime/NEON/functions/NEOpticalFlow.h"
+#include "arm_compute/runtime/NEON/functions/NEPadLayer.h"
#include "arm_compute/runtime/NEON/functions/NEPermute.h"
#include "arm_compute/runtime/NEON/functions/NEPhase.h"
#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h"
diff --git a/arm_compute/runtime/NEON/functions/NEPadLayer.h b/arm_compute/runtime/NEON/functions/NEPadLayer.h
new file mode 100644
index 0000000000..3a0863802a
--- /dev/null
+++ b/arm_compute/runtime/NEON/functions/NEPadLayer.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2018-2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_NEPADLAYER_H__
+#define __ARM_COMPUTE_NEPADLAYER_H__
+
+#include "arm_compute/runtime/IFunction.h"
+#include "arm_compute/runtime/SubTensor.h"
+
+#include "arm_compute/core/NEON/kernels/NECopyKernel.h"
+#include "arm_compute/core/NEON/kernels/NEMemsetKernel.h"
+#include "arm_compute/core/Types.h"
+
+namespace arm_compute
+{
+// Forward declarations
+class ITensor;
+
+/** Basic function to pad a tensor. This function calls the following NEON kernels:
+ *
+ * -# @ref NEMemsetKernel
+ * -# @ref NECopyKernel
+ */
+class NEPadLayer : public IFunction
+{
+public:
+ /** Default constructor*/
+ NEPadLayer();
+ /** Initialize the function
+ *
+ * @param[in] input Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
+ * @param[out] output Output tensor. Data type supported: same as @p input
+ * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
+ * specifies the front and the end padding in the i-th dimension.
+ * @param[in] constant_value (Optional) Constant value to be used for the padding
+ */
+ void configure(ITensor *input, ITensor *output, const PaddingList &padding, PixelValue constant_value = PixelValue());
+ /** Static function to check if given info will lead to a valid configuration of @ref NEPadLayer.
+ *
+ * @param[in] input Source tensor info. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
+ * @param[in] output Output tensor info. Data type supported: same as @p input
+ * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
+ * specifies the front and the end padding in the i-th dimension.
+ * @param[in] constant_value (Optional) Constant value to be used for the padding
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value = PixelValue());
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ NEMemsetKernel _memset_kernel;
+ NECopyKernel _copy_kernel;
+ SubTensor _output_subtensor;
+};
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_NEPADLAYER_H__ */
diff --git a/src/core/NEON/kernels/NEMemsetKernel.cpp b/src/core/NEON/kernels/NEMemsetKernel.cpp
new file mode 100644
index 0000000000..2b57b1595b
--- /dev/null
+++ b/src/core/NEON/kernels/NEMemsetKernel.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018-2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/core/NEON/kernels/NEMemsetKernel.h"
+
+#include "arm_compute/core/AccessWindowStatic.h"
+#include "arm_compute/core/Helpers.h"
+#include "arm_compute/core/ITensor.h"
+#include "arm_compute/core/Utils.h"
+#include "arm_compute/core/Validate.h"
+#include "arm_compute/core/Window.h"
+
+namespace arm_compute
+{
+NEMemsetKernel::NEMemsetKernel()
+ : _tensor(nullptr), _constant_value()
+{
+}
+
+void NEMemsetKernel::configure(ITensor *tensor, const PixelValue &constant_value)
+{
+ ARM_COMPUTE_ERROR_ON_NULLPTR(tensor);
+ _tensor = tensor;
+ _constant_value = constant_value;
+
+ // Configure kernel window
+ Window win = calculate_max_window(*tensor->info(), Steps());
+ INEKernel::configure(win);
+}
+
+void NEMemsetKernel::run(const Window &window, const ThreadInfo &info)
+{
+ ARM_COMPUTE_UNUSED(info);
+ ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
+ ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
+
+ // Collapse all the batches on the third dimension
+ bool has_collapsed = true;
+ Window collapsed = window.collapse_if_possible(window, Window::DimZ, &has_collapsed);
+ ARM_COMPUTE_ERROR_ON(!has_collapsed);
+
+ uint8_t *const start_valid_region = _tensor->ptr_to_element(_tensor->info()->valid_region().anchor);
+ const auto window_width = static_cast<int>(collapsed.x().end()) - static_cast<int>(collapsed.x().start());
+ const size_t element_size = _tensor->info()->element_size();
+
+ // Unroll X dimension
+ collapsed.set(Window::DimX, Window::Dimension(0, 1, 1));
+
+ Iterator tensor_it(_tensor, collapsed);
+ execute_window_loop(collapsed, [&](const Coordinates & id)
+ {
+ uint8_t *base_addr = start_valid_region + tensor_it.offset();
+ // Set memory
+ for(int i = 0; i < window_width; ++i)
+ {
+ std::memcpy(base_addr + i * element_size, &_constant_value.value, element_size);
+ }
+
+ },
+ tensor_it);
+}
+} // namespace arm_compute
diff --git a/src/runtime/CL/functions/CLPadLayer.cpp b/src/runtime/CL/functions/CLPadLayer.cpp
index de43c7dca2..3aa1b1e1a0 100644
--- a/src/runtime/CL/functions/CLPadLayer.cpp
+++ b/src/runtime/CL/functions/CLPadLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 ARM Limited.
+ * Copyright (c) 2018-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -34,21 +34,21 @@ CLPadLayer::CLPadLayer()
{
}
-void CLPadLayer::configure(ICLTensor *input, ICLTensor *output, const PaddingList &padding)
+void CLPadLayer::configure(ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value)
{
// Copy the input to the output
_copy_kernel.configure(input, output, padding);
// Set the pages of the output to zero
- _memset_kernel.configure(output, PixelValue());
+ _memset_kernel.configure(output, constant_value);
// Fill padding on the first two dimensions with zeros
- _fillborder_kernel.configure(input, input->info()->padding(), BorderMode::CONSTANT);
+ _fillborder_kernel.configure(input, input->info()->padding(), BorderMode::CONSTANT, constant_value);
}
-Status CLPadLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding)
+Status CLPadLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value)
{
- ARM_COMPUTE_RETURN_ON_ERROR(CLMemsetKernel::validate(input, PixelValue()));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLMemsetKernel::validate(input, constant_value));
ARM_COMPUTE_RETURN_ON_ERROR(CLCopyKernel::validate(input, output, padding));
return Status{};
diff --git a/src/runtime/NEON/functions/NEPadLayer.cpp b/src/runtime/NEON/functions/NEPadLayer.cpp
new file mode 100644
index 0000000000..f5c2718cec
--- /dev/null
+++ b/src/runtime/NEON/functions/NEPadLayer.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2018-2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/runtime/NEON/functions/NEPadLayer.h"
+
+#include "arm_compute/runtime/NEON/NEScheduler.h"
+
+#include "arm_compute/core/ITensor.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/core/utils/misc/ShapeCalculator.h"
+
+#include "support/ToolchainSupport.h"
+
+namespace arm_compute
+{
+namespace
+{
+TensorInfo get_expected_output_tensorinfo(const ITensorInfo &input, const PaddingList &paddings)
+{
+ const TensorShape expected_output_shape = arm_compute::misc::shape_calculator::compute_padded_shape(input.tensor_shape(), paddings);
+ const TensorInfo expected_output_info = input.clone()->set_tensor_shape(expected_output_shape);
+ return expected_output_info;
+}
+
+Status validate_arguments(const ITensorInfo &input, ITensorInfo &output, const PaddingList &paddings)
+{
+ const TensorInfo expected_output_info = get_expected_output_tensorinfo(input, paddings);
+ auto_init_if_empty(output, expected_output_info);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&output, &expected_output_info);
+
+ return Status{};
+}
+
+Coordinates get_subtensor_coords(const PaddingList &paddings)
+{
+ Coordinates coords;
+ for(unsigned int i = 0; i < paddings.size(); ++i)
+ {
+ coords.set(i, paddings[i].first);
+ }
+
+ return coords;
+}
+} // namespace
+
+NEPadLayer::NEPadLayer()
+ : _memset_kernel(), _copy_kernel(), _output_subtensor()
+{
+}
+
+void NEPadLayer::configure(ITensor *input, ITensor *output, const PaddingList &padding, PixelValue constant_value)
+{
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_THROW_ON_ERROR(NEPadLayer::validate(input->info(), output->info(), padding, constant_value));
+
+ // Auto-init
+ auto_init_if_empty(*output->info(), get_expected_output_tensorinfo(*input->info(), padding));
+
+ // Create SubTensor (Can use sub-tensor as the kernels to be executed do not require padding)
+ _output_subtensor = SubTensor(output, input->info()->tensor_shape(), get_subtensor_coords(padding), true);
+
+ // Set the pages of the output to the specified value
+ _memset_kernel.configure(output, constant_value);
+
+ // Copy the input to the output
+ _copy_kernel.configure(input, &_output_subtensor);
+}
+
+Status NEPadLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value)
+{
+ ARM_COMPUTE_UNUSED(constant_value);
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
+
+ auto output_clone = output->clone();
+
+ SubTensorInfo output_subtensor_info(output_clone.get(), input->tensor_shape(), get_subtensor_coords(padding), true);
+ ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(*input, *output_clone, padding));
+ ARM_COMPUTE_RETURN_ON_ERROR(NECopyKernel::validate(input, &output_subtensor_info));
+
+ return Status{};
+}
+
+void NEPadLayer::run()
+{
+ NEScheduler::get().schedule(&_memset_kernel, Window::DimY);
+ NEScheduler::get().schedule(&_copy_kernel, Window::DimY);
+}
+} // namespace arm_compute
diff --git a/tests/validation/CL/Padding.cpp b/tests/validation/CL/PadLayer.cpp
index a7777128c9..4bbd7b8e14 100644
--- a/tests/validation/CL/Padding.cpp
+++ b/tests/validation/CL/PadLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 ARM Limited.
+ * Copyright (c) 2018-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -50,7 +50,7 @@ const auto PaddingSizesDataset = framework::dataset::make("PaddingSize", { Paddi
} // namespace
TEST_SUITE(CL)
-TEST_SUITE(Padding)
+TEST_SUITE(PadLayer)
// *INDENT-OFF*
// clang-format off
@@ -140,7 +140,7 @@ FIXTURE_DATA_TEST_CASE(RunPadding, CLPaddingFixture<uint8_t>, framework::Dataset
TEST_SUITE_END() // QASYMM8
TEST_SUITE_END() // Quantized
-TEST_SUITE_END() // Padding
+TEST_SUITE_END() // PadLayer
TEST_SUITE_END() // CL
} // namespace validation
} // namespace test
diff --git a/tests/validation/NEON/PadLayer.cpp b/tests/validation/NEON/PadLayer.cpp
new file mode 100644
index 0000000000..90d3ae98d8
--- /dev/null
+++ b/tests/validation/NEON/PadLayer.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2018-2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/NEON/functions/NEPadLayer.h"
+#include "arm_compute/runtime/Tensor.h"
+#include "arm_compute/runtime/TensorAllocator.h"
+#include "tests/NEON/Accessor.h"
+#include "tests/PaddingCalculator.h"
+#include "tests/datasets/ShapeDatasets.h"
+#include "tests/framework/Asserts.h"
+#include "tests/framework/Macros.h"
+#include "tests/framework/datasets/Datasets.h"
+#include "tests/validation/Validation.h"
+#include "tests/validation/fixtures/PadLayerFixture.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace
+{
+const auto PaddingSizesDataset = framework::dataset::make("PaddingSize", { PaddingList{ { 0, 0 } },
+ PaddingList{ { 1, 1 } },
+ PaddingList{ { 1, 1 }, { 2, 2 } },
+ PaddingList{ { 1, 1 }, { 1, 1 }, { 1, 1 }, { 1, 1 } },
+ PaddingList{ { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 2 } },
+ PaddingList{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 1, 1 } }
+});
+} // namespace
+
+TEST_SUITE(NEON)
+TEST_SUITE(PadLayer)
+
+// *INDENT-OFF*
+// clang-format off
+
+DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
+ framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/output
+ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes
+ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32)
+ }),
+ framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16),
+ TensorInfo(TensorShape(28U, 11U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(29U, 17U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(29U, 15U, 4U, 3U), 1, DataType::F32),
+ TensorInfo(TensorShape(27U, 14U, 3U, 4U), 1, DataType::F32),
+ TensorInfo(TensorShape(32U, 13U, 2U, 3U), 1, DataType::F32)
+ })),
+ framework::dataset::make("PaddingSize", { PaddingList{{0, 0}},
+ PaddingList{{1, 1}},
+ PaddingList{{1, 1}, {2, 2}},
+ PaddingList{{1,1}, {1,1}, {1,1}, {1,1}},
+ PaddingList{{0,0}, {1,0}, {0,1}, {1,2}},
+ PaddingList{{0,0}, {0,0}, {0,0}, {1,1}}
+ })),
+ framework::dataset::make("Expected", { false, false, true, true, true, true })),
+ input_info, output_info, padding, expected)
+{
+ Status s = NEPadLayer::validate(&input_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), padding);
+ ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS);
+}
+
+// clang-format on
+// *INDENT-ON*
+
+template <typename T>
+using NEPaddingFixture = PaddingFixture<Tensor, Accessor, NEPadLayer, T>;
+
+TEST_SUITE(Float)
+
+TEST_SUITE(FP32)
+FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<float>, framework::DatasetMode::ALL,
+ combine(
+ combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::F32 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<float>, framework::DatasetMode::NIGHTLY,
+ combine(
+ combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::F32 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+TEST_SUITE_END() // FP32
+
+#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
+TEST_SUITE(FP16)
+FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<half>, framework::DatasetMode::ALL,
+ combine(
+ combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::F16 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<half>, framework::DatasetMode::NIGHTLY,
+ combine(
+ combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::F16 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+TEST_SUITE_END() // FP16
+#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
+TEST_SUITE_END() // Float
+
+TEST_SUITE(Integer)
+TEST_SUITE(S8)
+FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<int8_t>, framework::DatasetMode::ALL,
+ combine(
+ combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::S8 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<int8_t>, framework::DatasetMode::NIGHTLY,
+ combine(
+ combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::S8 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+TEST_SUITE_END() // S8
+TEST_SUITE_END() // Integer
+
+TEST_SUITE(Quantized)
+TEST_SUITE(QASYMM8)
+FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<uint8_t>, framework::DatasetMode::ALL,
+ combine(
+ combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::QASYMM8 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
+ combine(
+ combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::QASYMM8 })),
+ PaddingSizesDataset))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+TEST_SUITE_END() // QASYMM8
+TEST_SUITE_END() // Quantized
+
+TEST_SUITE_END() // PadLayer
+TEST_SUITE_END() // NEON
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/validation/fixtures/PadLayerFixture.h b/tests/validation/fixtures/PadLayerFixture.h
index 72ce57dc9f..839313a118 100644
--- a/tests/validation/fixtures/PadLayerFixture.h
+++ b/tests/validation/fixtures/PadLayerFixture.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 ARM Limited.
+ * Copyright (c) 2018-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,7 +26,6 @@
#include "arm_compute/core/TensorShape.h"
#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/CL/functions/CLPadLayer.h"
#include "tests/AssetsLibrary.h"
#include "tests/Globals.h"
#include "tests/IAccessor.h"