aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bazelrc1
-rw-r--r--Android.bp2
-rw-r--r--BUILD.bazel23
-rw-r--r--CMakeLists.txt12
-rw-r--r--arm_compute/runtime/NEON/NEFunctions.h1
-rw-r--r--arm_compute/runtime/NEON/functions/NEReorderLayer.h84
-rw-r--r--cmake/Options.cmake12
-rw-r--r--filelist.json8
-rw-r--r--src/BUILD.bazel2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/core/NEON/NEKernels.h3
-rw-r--r--src/core/NEON/kernels/NEReorderKernel.cpp223
-rw-r--r--src/core/NEON/kernels/NEReorderKernel.h93
-rw-r--r--src/runtime/NEON/functions/NEReorder.cpp53
-rw-r--r--tests/BUILD.bazel7
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/datasets/ReorderLayerDataset.h158
-rw-r--r--tests/validation/CMakeLists.txt1
-rw-r--r--tests/validation/NEON/ReorderLayer.cpp66
-rw-r--r--tests/validation/fixtures/ReorderFixture.h109
-rw-r--r--tests/validation/reference/Reorder.cpp156
-rw-r--r--tests/validation/reference/Reorder.h44
22 files changed, 1046 insertions, 15 deletions
diff --git a/.bazelrc b/.bazelrc
index 8611db3d4a..d6a5e62871 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -37,3 +37,4 @@ build --flag_alias=logging=//:logging
build --flag_alias=openmp=//:openmp
build --flag_alias=cppthreads=//:cppthreads
build --flag_alias=enable_bf16_validation=//:enable_bf16_validation
+build --flag_alias=enable_sve_validation=//:enable_sve_validation
diff --git a/Android.bp b/Android.bp
index bfc747405f..83b971bd0e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -296,6 +296,7 @@ cc_library_static {
"src/core/NEON/kernels/NEROIPoolingLayerKernel.cpp",
"src/core/NEON/kernels/NERangeKernel.cpp",
"src/core/NEON/kernels/NEReductionOperationKernel.cpp",
+ "src/core/NEON/kernels/NEReorderKernel.cpp",
"src/core/NEON/kernels/NEReorgLayerKernel.cpp",
"src/core/NEON/kernels/NEReverseKernel.cpp",
"src/core/NEON/kernels/NESelectKernel.cpp",
@@ -963,6 +964,7 @@ cc_library_static {
"src/runtime/NEON/functions/NERange.cpp",
"src/runtime/NEON/functions/NEReduceMean.cpp",
"src/runtime/NEON/functions/NEReductionOperation.cpp",
+ "src/runtime/NEON/functions/NEReorder.cpp",
"src/runtime/NEON/functions/NEReorgLayer.cpp",
"src/runtime/NEON/functions/NEReshapeLayer.cpp",
"src/runtime/NEON/functions/NEReverse.cpp",
diff --git a/BUILD.bazel b/BUILD.bazel
index e3ad75abd8..d246336c29 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -72,6 +72,12 @@ bool_flag(
visibility = ["//visibility:public"],
)
+bool_flag(
+ name = "enable_sve_validation",
+ build_setting_default = False,
+ visibility = ["//visibility:public"],
+)
+
#---------------------------------------------------------------------
# Flag variables
config_setting(
@@ -116,6 +122,13 @@ config_setting(
},
)
+config_setting(
+ name = "sve_validation_flag",
+ flag_values = {
+ ":enable_sve_validation": "true",
+ },
+)
+
#---------------------------------------------------------------------
# Common defines used for all targets
@@ -138,8 +151,6 @@ cc_library(
"DARM_COMPUTE_GRAPH_ENABLED",
"ARM_COMPUTE_ENABLE_SVEF32MM",
"ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS",
- "ENABLE_SVE",
- "ARM_COMPUTE_ENABLE_SVE",
"_GLIBCXX_USE_NANOSLEEP"
] + select({
"//:debug_flag": [
@@ -243,8 +254,10 @@ cc_library(
"//conditions:default": [],
}),
local_defines = [
+ "ENABLE_SVE",
+ "ARM_COMPUTE_ENABLE_SVE",
"ARM_COMPUTE_ENABLE_SVE2",
- "ARM_COMPUTE_ENABLE_BF16"
+ "ARM_COMPUTE_ENABLE_BF16",
],
deps = [
"//:common_defines",
@@ -292,6 +305,8 @@ cc_library(
"//conditions:default": [],
}),
local_defines = [
+ "ENABLE_SVE",
+ "ARM_COMPUTE_ENABLE_SVE",
"ARM_COMPUTE_ENABLE_BF16",
],
deps = [
@@ -348,6 +363,8 @@ cc_library(
"//conditions:default": [],
}),
local_defines = [
+ "ENABLE_SVE",
+ "ARM_COMPUTE_ENABLE_SVE",
"ARM_COMPUTE_ENABLE_BF16",
],
visibility = ["//visibility:public"],
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 72992ed038..060370d33a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,6 +149,8 @@ add_library(arm_compute_sve "")
target_compile_options(arm_compute_sve
PRIVATE "-march=armv8.2-a+sve+fp16+dotprod")
target_compile_definitions(arm_compute_sve PRIVATE ARM_COMPUTE_ENABLE_BF16)
+target_compile_definitions(arm_compute_sve PRIVATE ENABLE_SVE)
+target_compile_definitions(arm_compute_sve PRIVATE ARM_COMPUTE_ENABLE_SVE)
target_include_directories(
arm_compute_sve
PUBLIC $<INSTALL_INTERFACE:include>
@@ -170,6 +172,8 @@ target_compile_options(arm_compute_sve2
PRIVATE "-march=armv8.6-a+sve2+fp16+dotprod")
target_compile_definitions(arm_compute_sve2 PRIVATE ARM_COMPUTE_ENABLE_SVE2)
target_compile_definitions(arm_compute_sve2 PRIVATE ARM_COMPUTE_ENABLE_BF16)
+target_compile_definitions(arm_compute_sve2 PRIVATE ENABLE_SVE)
+target_compile_definitions(arm_compute_sve2 PRIVATE ARM_COMPUTE_ENABLE_SVE)
target_include_directories(
arm_compute_sve2
PUBLIC $<INSTALL_INTERFACE:include>
@@ -189,6 +193,8 @@ target_include_directories(
add_library(arm_compute_core "")
target_compile_options(arm_compute_core PRIVATE "-march=armv8.2-a+fp16")
target_compile_definitions(arm_compute_core PRIVATE ARM_COMPUTE_ENABLE_BF16)
+target_compile_definitions(arm_compute_core PRIVATE ENABLE_SVE)
+target_compile_definitions(arm_compute_core PRIVATE ARM_COMPUTE_ENABLE_SVE)
target_include_directories(
arm_compute_core
PUBLIC $<INSTALL_INTERFACE:include>
@@ -211,6 +217,8 @@ target_link_libraries(
add_library(arm_compute_graph "")
target_compile_options(arm_compute_graph PRIVATE "-march=armv8.2-a+fp16")
+target_compile_definitions(arm_compute_graph PRIVATE ENABLE_SVE)
+target_compile_definitions(arm_compute_graph PRIVATE ARM_COMPUTE_ENABLE_SVE)
# add_subdirectory(src/graph)
target_include_directories(
@@ -262,6 +270,10 @@ if(BUILD_TESTING)
if(ENABLE_BF16_VALIDATION)
target_compile_definitions(arm_compute_validation PRIVATE ARM_COMPUTE_ENABLE_BF16)
endif()
+ if(ENABLE_SVE_VALIDATION)
+ target_compile_definitions(arm_compute_validation PRIVATE ENABLE_SVE)
+ target_compile_definitions(arm_compute_validation PRIVATE ARM_COMPUTE_ENABLE_SVE)
+ endif()
add_subdirectory(tests/validation)
target_compile_options(arm_compute_validation PUBLIC ${COMMON_CXX_FLAGS})
set_target_properties(
diff --git a/arm_compute/runtime/NEON/NEFunctions.h b/arm_compute/runtime/NEON/NEFunctions.h
index 836cba7699..3a10310452 100644
--- a/arm_compute/runtime/NEON/NEFunctions.h
+++ b/arm_compute/runtime/NEON/NEFunctions.h
@@ -93,6 +93,7 @@
#include "arm_compute/runtime/NEON/functions/NERange.h"
#include "arm_compute/runtime/NEON/functions/NEReduceMean.h"
#include "arm_compute/runtime/NEON/functions/NEReductionOperation.h"
+#include "arm_compute/runtime/NEON/functions/NEReorderLayer.h"
#include "arm_compute/runtime/NEON/functions/NEReorgLayer.h"
#include "arm_compute/runtime/NEON/functions/NEReshapeLayer.h"
#include "arm_compute/runtime/NEON/functions/NEReverse.h"
diff --git a/arm_compute/runtime/NEON/functions/NEReorderLayer.h b/arm_compute/runtime/NEON/functions/NEReorderLayer.h
new file mode 100644
index 0000000000..4d5e3fa850
--- /dev/null
+++ b/arm_compute/runtime/NEON/functions/NEReorderLayer.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2023 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 ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEREORDERLAYER
+#define ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEREORDERLAYER
+
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/IFunction.h"
+#include "src/core/NEON/kernels/NEReorderKernel.h"
+
+namespace arm_compute
+{
+class ITensor;
+class ITensorInfo;
+/** Function to compute blocked reorder. */
+class NEReorderLayer : public IFunction
+{
+public:
+ /** Default constructor */
+ NEReorderLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEReorderLayer(const NEReorderLayer &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEReorderLayer &operator=(const NEReorderLayer &) = delete;
+ /** Prevent instances of this class from being moved (As this class contains non movable objects) */
+ NEReorderLayer(NEReorderLayer &&) = delete;
+ /** Prevent instances of this class from being moved (As this class contains non movable objects) */
+ NEReorderLayer &operator=(NEReorderLayer &&) = delete;
+ /** Default destructor */
+ ~NEReorderLayer() = default;
+ /** Set the input and output tensors.
+ *
+ * Valid data layouts:
+ * - NCHW
+ *
+ * Valid data type configurations:
+ * |src |dst |
+ * |:--------|:---------|
+ * |F32 |F32 |
+ *
+ * @param[in] input Source tensor. Data type supported: F32. Data layouts supported: NCHW.
+ * @param[out] output Destination with the same dimensions, data type, data layout as @p input
+ * except last dimension of data layout which needs to be multiple of blocking parameter ksize
+ * @param[in] input_wf WeightFormat of input.
+ * @param[in] output_wf WeightFormat of output.
+ */
+ void configure(const ITensor *input, ITensor *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref NEReorderLayer
+ *
+ * Similar to @ref NEReorderLayer::configure()
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ std::unique_ptr<NEReorderKernel> _reorder_kernel; /**< Reorder layer kernel */
+};
+} // namespace arm_compute
+#endif /* ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEREORDERLAYER */
diff --git a/cmake/Options.cmake b/cmake/Options.cmake
index 170dad9f69..e2aa2bfbff 100644
--- a/cmake/Options.cmake
+++ b/cmake/Options.cmake
@@ -66,9 +66,8 @@ option(ENABLE_NCHW_KERNELS "" ON)
option(ARM_COMPUTE_GRAPH_ENABLED "" ON)
option(ARM_COMPUTE_ENABLE_SVEF32MM "" ON)
option(ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS "" ON)
-option(ENABLE_SVE "" ON)
-option(ARM_COMPUTE_ENABLE_SVE "" ON)
option(ENABLE_BF16_VALIDATION "" OFF)
+option(ENABLE_SVE_VALIDATION "" OFF)
if(ENABLE_NEON)
add_definitions(-DENABLE_NEON)
@@ -112,19 +111,10 @@ endif()
if(ARM_COMPUTE_GRAPH_ENABLED)
add_definitions(-DARM_COMPUTE_GRAPH_ENABLED)
endif()
-if(ARM_COMPUTE_ENABLE_BF16)
- add_definitions(-DARM_COMPUTE_ENABLE_BF16)
-endif()
if(ARM_COMPUTE_ENABLE_SVEF32MM)
add_definitions(-DARM_COMPUTE_ENABLE_SVEF32MM)
endif()
if(ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS)
add_definitions(-DARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS)
endif()
-if(ENABLE_SVE)
- add_definitions(-DENABLE_SVE)
-endif()
-if(ARM_COMPUTE_ENABLE_SVE)
- add_definitions(-DARM_COMPUTE_ENABLE_SVE)
-endif()
add_definitions(-D_GLIBCXX_USE_NANOSLEEP) \ No newline at end of file
diff --git a/filelist.json b/filelist.json
index e62520dc46..52e29ef9bb 100644
--- a/filelist.json
+++ b/filelist.json
@@ -2077,6 +2077,14 @@
]
}
},
+ "Reorder": {
+ "files": {
+ "common": [
+ "src/runtime/NEON/functions/NEReorder.cpp",
+ "src/core/NEON/kernels/NEReorderKernel.cpp"
+ ]
+ }
+ },
"Reverse": {
"files": {
"common": [
diff --git a/src/BUILD.bazel b/src/BUILD.bazel
index e0140addb7..6e73f2eba6 100644
--- a/src/BUILD.bazel
+++ b/src/BUILD.bazel
@@ -416,6 +416,7 @@ filegroup(
"core/NEON/kernels/NEROIPoolingLayerKernel.cpp",
"core/NEON/kernels/NERangeKernel.cpp",
"core/NEON/kernels/NEReductionOperationKernel.cpp",
+ "core/NEON/kernels/NEReorderKernel.cpp",
"core/NEON/kernels/NEReorgLayerKernel.cpp",
"core/NEON/kernels/NEReverseKernel.cpp",
"core/NEON/kernels/NESelectKernel.cpp",
@@ -953,6 +954,7 @@ filegroup(
"runtime/NEON/functions/NERange.cpp",
"runtime/NEON/functions/NEReduceMean.cpp",
"runtime/NEON/functions/NEReductionOperation.cpp",
+ "runtime/NEON/functions/NEReorder.cpp",
"runtime/NEON/functions/NEReorgLayer.cpp",
"runtime/NEON/functions/NEReshapeLayer.cpp",
"runtime/NEON/functions/NEReverse.cpp",
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 28028e85ef..35d1d9966e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -408,6 +408,7 @@ target_sources(
core/NEON/kernels/NEROIPoolingLayerKernel.cpp
core/NEON/kernels/NERangeKernel.cpp
core/NEON/kernels/NEReductionOperationKernel.cpp
+ core/NEON/kernels/NEReorderKernel.cpp
core/NEON/kernels/NEReorgLayerKernel.cpp
core/NEON/kernels/NEReverseKernel.cpp
core/NEON/kernels/NESelectKernel.cpp
@@ -945,6 +946,7 @@ target_sources(
runtime/NEON/functions/NERange.cpp
runtime/NEON/functions/NEReduceMean.cpp
runtime/NEON/functions/NEReductionOperation.cpp
+ runtime/NEON/functions/NEReorder.cpp
runtime/NEON/functions/NEReorgLayer.cpp
runtime/NEON/functions/NEReshapeLayer.cpp
runtime/NEON/functions/NEReverse.cpp
diff --git a/src/core/NEON/NEKernels.h b/src/core/NEON/NEKernels.h
index 12a1bb9a11..75016b0db1 100644
--- a/src/core/NEON/NEKernels.h
+++ b/src/core/NEON/NEKernels.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2022 Arm Limited.
+ * Copyright (c) 2016-2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -54,6 +54,7 @@
#include "src/core/NEON/kernels/NEROIPoolingLayerKernel.h"
#include "src/core/NEON/kernels/NERangeKernel.h"
#include "src/core/NEON/kernels/NEReductionOperationKernel.h"
+#include "src/core/NEON/kernels/NEReorderKernel.h"
#include "src/core/NEON/kernels/NEReorgLayerKernel.h"
#include "src/core/NEON/kernels/NEReverseKernel.h"
#include "src/core/NEON/kernels/NESelectKernel.h"
diff --git a/src/core/NEON/kernels/NEReorderKernel.cpp b/src/core/NEON/kernels/NEReorderKernel.cpp
new file mode 100644
index 0000000000..c09745604f
--- /dev/null
+++ b/src/core/NEON/kernels/NEReorderKernel.cpp
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2023 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 "src/core/NEON/kernels/NEReorderKernel.h"
+#include "src/common/utils/Log.h"
+#include "src/core/NEON/kernels/arm_gemm/transform.hpp"
+#include "arm_compute/core/Helpers.h"
+#include "arm_compute/core/Validate.h"
+
+namespace arm_compute
+{
+
+void NEReorderKernel::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);
+ switch(_input->info()->data_type())
+ {
+ case DataType::F32:
+ {
+ const int ksize_rows_elements = _xmax * _ksize;
+ const int jump_rows = ksize_rows_elements * window.x().start();
+ const int k_start = window.x().start() * _ksize;
+ const int k_end = std::min(window.x().end() * _ksize, _kmax);
+ const int stride = _kmax;
+ if(k_start < k_end)
+ {
+
+ switch(_output_wf)
+ {
+ case WeightFormat::OHWIo4:
+ {
+ arm_gemm::Transform<4, 1, true, arm_gemm::VLType::None>(reinterpret_cast<float *>(_output->buffer()) + jump_rows, reinterpret_cast<float *>(_input->buffer()), stride, k_start, k_end, 0, _xmax);
+ break;
+ }
+#if defined(ARM_COMPUTE_ENABLE_SVE)
+ case WeightFormat::OHWIo8:
+ {
+ arm_gemm::Transform<1, 1, true, arm_gemm::VLType::SVE>(reinterpret_cast<float *>(_output->buffer()) + jump_rows, reinterpret_cast<float *>(_input->buffer()), stride, k_start, k_end, 0, _xmax);
+ break;
+ }
+#endif /* ARM_COMPUTE_ENABLE_SVE */
+ default:
+ {
+ ARM_COMPUTE_ERROR("Unsupported data type!");
+ break;
+ }
+ }
+ }
+ break;
+ }
+ default:
+ ARM_COMPUTE_ERROR("Unsupported data type!");
+ }
+}
+
+NEReorderKernel::NEReorderKernel()
+ : _input(nullptr), _output(nullptr), _ksize(0), _kmax(0), _xmax(0), _input_wf(WeightFormat::ANY), _output_wf(WeightFormat::ANY)
+{
+}
+
+void NEReorderKernel::configure(const ITensor *input, ITensor *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf)
+{
+ ARM_COMPUTE_LOG_PARAMS(input, output, input_wf, output_wf);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_ERROR_THROW_ON(validate(input->info(), output->info(), input_wf, output_wf));
+
+ // Set variables
+ _input = input;
+ _output = output;
+ _input_wf = input_wf;
+ _output_wf = output_wf;
+
+ // Setting parameters for transform
+ auto dims = input->info()->num_dimensions();
+ switch(dims)
+ {
+ case 2:
+ {
+ _xmax = input->info()->dimension(0); // Number of columns in input matrix
+ _kmax = input->info()->dimension(1); // Number of rows in input matrix
+ break;
+ }
+ case 4:
+ {
+ _xmax = input->info()->dimension(2); // Number of columns in input matrix
+ _kmax = input->info()->dimension(3); // Number of rows in input matrix
+ break;
+ }
+ default:
+ {
+ ARM_COMPUTE_ERROR("Only 2 or 4 dimensions supported.");
+ }
+ }
+
+ // Configure kernel window
+ // Window size is set by rows / _ksize
+ Window win;
+ int window_size = 0;
+ switch(_output_wf)
+ {
+#if defined(ARM_COMPUTE_ENABLE_SVE)
+ case WeightFormat::OHWIo8:
+ {
+ _ksize = 8;
+ window_size = _kmax / _ksize;
+ break;
+ }
+#endif /* ARM_COMPUTE_ENABLE_SVE */
+ case WeightFormat::OHWIo4:
+ {
+ _ksize = 4;
+ window_size = _kmax / _ksize;
+ break;
+ }
+ default:
+ {
+ ARM_COMPUTE_ERROR("Unsupported weight format.");
+ break;
+ }
+ }
+ if(_kmax % _ksize != 0)
+ {
+ window_size += 1;
+ }
+
+ win.set(Window::DimX, Window::Dimension(0, window_size, 1));
+
+ INEKernel::configure(win);
+}
+
+Status NEReorderKernel::validate(const ITensorInfo *input, const ITensorInfo *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::UNKNOWN);
+ if(output->tensor_shape().total_size() != 0)
+ {
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input, output);
+ // Only input WeightFormat OHWI supported
+ ARM_COMPUTE_RETURN_ERROR_ON(input_wf != arm_compute::WeightFormat::OHWI);
+ int input_x_dim;
+ int input_k_dim;
+ int output_x_dim;
+ int output_k_dim;
+ auto dims = output->num_dimensions();
+ switch(dims)
+ {
+ case 2:
+ {
+ input_x_dim = input->dimension(0); // Number of columns in input matrix
+ input_k_dim = input->dimension(1); // Number of rows in input matrix
+ output_x_dim = output->dimension(0); // Number of columns in output matrix
+ output_k_dim = output->dimension(1); // Number of rows in output matrix
+ break;
+ }
+ case 4:
+ {
+ input_x_dim = input->dimension(2); // Number of columns in input matrix
+ input_k_dim = input->dimension(3); // Number of rows in input matrix
+ output_x_dim = output->dimension(2); // Number of columns in output matrix
+ output_k_dim = output->dimension(3); // Number of rows in output matrix
+ break;
+ }
+ default:
+ {
+ ARM_COMPUTE_RETURN_ERROR_MSG("Only 2 or 4 dimensions supported.");
+ }
+ }
+
+ int ksize;
+ switch(output_wf)
+ {
+ case WeightFormat::OHWIo8:
+ {
+ ksize = 8;
+ break;
+ }
+ case WeightFormat::OHWIo4:
+ {
+ ksize = 4;
+ break;
+ }
+ default:
+ {
+ ARM_COMPUTE_RETURN_ERROR_MSG("Unsupported weight format.");
+ break;
+ }
+ }
+
+ // output k_dim needs to be same as input but multiple of ksize
+ int32_t rnd_up_input_kdim = arm_compute::ceil_to_multiple<int32_t, int32_t>(input_k_dim, ksize);
+ ARM_COMPUTE_RETURN_ERROR_ON(rnd_up_input_kdim != output_k_dim);
+ // output x_dim needs to be same as input
+ ARM_COMPUTE_RETURN_ERROR_ON(input_x_dim != output_x_dim);
+
+ }
+ return Status{};
+}
+
+} // namespace arm_compute
diff --git a/src/core/NEON/kernels/NEReorderKernel.h b/src/core/NEON/kernels/NEReorderKernel.h
new file mode 100644
index 0000000000..e744ff9e52
--- /dev/null
+++ b/src/core/NEON/kernels/NEReorderKernel.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2023 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 ACL_SRC_CORE_NEON_KERNELS_NEREORDERKERNEL
+#define ACL_SRC_CORE_NEON_KERNELS_NEREORDERKERNEL
+
+#include "src/core/NEON/INEKernel.h"
+#include "arm_compute/core/Types.h"
+
+namespace arm_compute
+{
+
+/** Interface kernel to reorder tensor into blocked format. */
+class NEReorderKernel : public INEKernel
+{
+public:
+
+ const char *name() const override
+ {
+ return "NEReorderKernel";
+ }
+
+ /** Default constructor */
+ NEReorderKernel();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEReorderKernel(const NEReorderKernel &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEReorderKernel &operator=(const NEReorderKernel &) = delete;
+ /** Allow instances of this class to be moved */
+ NEReorderKernel(NEReorderKernel &&) = default;
+ /** Allow instances of this class to be moved */
+ NEReorderKernel &operator=(NEReorderKernel &&) = default;
+ /** Default destructor */
+ ~NEReorderKernel() = default;
+
+ /** Initialise the kernel's input and outputs.
+ *
+ * @param[in] input Source tensor with 2 or 4 dimensions. Data types supported: F32.
+ * @param[out] output Destination tensor. Data type supported: same as @p input. Shape same as @p input expect last dimension which needs to be multiple of blocking parameter _ksize.
+ * @param[in] input_wf WeightFormat of input.
+ * @param[in] output_wf WeightFormat of output.
+ */
+ void configure(const ITensor *input, ITensor *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref NEReorderKernel
+ *
+ * @param[in] input Source tensor with 2 or 4 dimensions. Data types supported: F32.
+ * @param[in] output Destination tensor. Data type supported: same as @p input. Shape same as @p input expect last dimension which needs to be multiple of blocking parameter _ksize.
+ * @param[in] input_wf WeightFormat of input.
+ * @param[in] output_wf WeightFormat of output.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf);
+
+ // Inherited methods overridden:
+ void run(const Window &window, const ThreadInfo &info) override;
+
+
+/*****************************************************************************/
+
+private:
+ const ITensor *_input{nullptr}; // Input tensor
+ ITensor *_output{nullptr}; // Output tensor
+ int32_t _ksize{0}; // Blocking parameter, how many rows kernel reorders on each call
+ int32_t _kmax{0}; // Rows in input tensor
+ int32_t _xmax{0}; // Columns in input tensor
+ WeightFormat _input_wf{WeightFormat::UNSPECIFIED}; // WeightFormat of input tensor
+ WeightFormat _output_wf{WeightFormat::UNSPECIFIED}; // WeightFormat of output tensor
+};
+
+} // namespace arm_compute
+#endif /* ACL_SRC_CORE_NEON_KERNELS_NEREORDERKERNEL */
diff --git a/src/runtime/NEON/functions/NEReorder.cpp b/src/runtime/NEON/functions/NEReorder.cpp
new file mode 100644
index 0000000000..f9bbeba90c
--- /dev/null
+++ b/src/runtime/NEON/functions/NEReorder.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2023 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/NEScheduler.h"
+#include "arm_compute/runtime/NEON/functions/NEReorderLayer.h"
+
+namespace arm_compute
+{
+
+NEReorderLayer::NEReorderLayer()
+ : _reorder_kernel(std::make_unique<NEReorderKernel>())
+{
+}
+
+void NEReorderLayer::configure(const ITensor *input, ITensor *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf)
+{
+ auto k = std::make_unique<NEReorderKernel>();
+ k->configure(input, output, input_wf, output_wf);
+ _reorder_kernel = std::move(k);
+}
+
+void NEReorderLayer::run()
+{
+ // Run Reorder
+ NEScheduler::get().schedule(_reorder_kernel.get(), Window::DimX);
+}
+
+Status NEReorderLayer::validate(const ITensorInfo *input, const ITensorInfo *output, arm_compute::WeightFormat input_wf, arm_compute::WeightFormat output_wf)
+{
+ return NEReorderKernel::validate(input, output, input_wf, output_wf);
+}
+
+} // namespace arm_compute \ No newline at end of file
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
index 8122652991..606f403f38 100644
--- a/tests/BUILD.bazel
+++ b/tests/BUILD.bazel
@@ -106,6 +106,13 @@ cc_binary(
"ARM_COMPUTE_ENABLE_BF16",
],
"//conditions:default": [],
+ }) +
+ select({
+ "//:sve_validation_flag": [
+ "ENABLE_SVE",
+ "ARM_COMPUTE_ENABLE_SVE",
+ ],
+ "//conditions:default": [],
})
)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 163ab82e91..c4b12e770a 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -107,6 +107,7 @@ target_sources(
validation/reference/DepthwiseConvolutionLayer.cpp
validation/reference/FullyConnectedLayer.cpp
validation/reference/ConvolutionLayer.cpp
+ validation/reference/Reorder.cpp
framework/Framework.cpp
framework/Utils.cpp
framework/Exceptions.cpp
diff --git a/tests/datasets/ReorderLayerDataset.h b/tests/datasets/ReorderLayerDataset.h
new file mode 100644
index 0000000000..8e1a8422b2
--- /dev/null
+++ b/tests/datasets/ReorderLayerDataset.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2023 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 ACL_TESTS_DATASETS_REORDERLAYERDATASET
+#define ACL_TESTS_DATASETS_REORDERLAYERDATASET
+
+#include "arm_compute/core/TensorShape.h"
+#include "arm_compute/core/Types.h"
+#include "utils/TypePrinter.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace datasets
+{
+/** [ReorderLayer datasets] **/
+class ReorderLayerDataset
+{
+public:
+ using type = std::tuple<TensorShape, TensorShape, WeightFormat, WeightFormat>;
+
+ struct iterator
+ {
+ iterator(std::vector<TensorShape>::const_iterator in_it,
+ std::vector<TensorShape>::const_iterator out_it,
+ std::vector<WeightFormat>::const_iterator _wf_in_it,
+ std::vector<WeightFormat>::const_iterator _wf_out_it)
+ : _in_it{ std::move(in_it) },
+ _out_it{ std::move(out_it) },
+ _wf_in_it{ std::move(_wf_in_it) },
+ _wf_out_it{ std::move(_wf_out_it) }
+ {
+ }
+
+ std::string description() const
+ {
+ std::stringstream description;
+ description << "In=" << *_in_it << ":";
+ description << "Out=" << *_out_it << ":";
+ description << "Wf_In=" << *_wf_in_it << ":";
+ description << "Wf_Out=" << *_wf_out_it;
+ return description.str();
+ }
+
+ ReorderLayerDataset::type operator*() const
+ {
+ return std::make_tuple(*_in_it, *_out_it, *_wf_in_it, *_wf_out_it);
+ }
+
+ iterator &operator++()
+ {
+ ++_in_it;
+ ++_out_it;
+ ++_wf_in_it;
+ ++_wf_out_it;
+
+ return *this;
+ }
+
+ private:
+ std::vector<TensorShape>::const_iterator _in_it;
+ std::vector<TensorShape>::const_iterator _out_it;
+ std::vector<WeightFormat>::const_iterator _wf_in_it;
+ std::vector<WeightFormat>::const_iterator _wf_out_it;
+ };
+
+ iterator begin() const
+ {
+ return iterator(_in_shapes.begin(), _out_shapes.begin(), _in_wfs.begin(), _out_wfs.begin());
+ }
+
+ int size() const
+ {
+ return std::min(_in_shapes.size(), std::min(_out_shapes.size(), std::min(_in_wfs.size(), _out_wfs.size())));
+ }
+
+ void add_config(TensorShape in, TensorShape out, WeightFormat in_wf, WeightFormat out_wf)
+ {
+ _in_shapes.emplace_back(std::move(in));
+ _out_shapes.emplace_back(std::move(out));
+ _in_wfs.emplace_back(std::move(in_wf));
+ _out_wfs.emplace_back(std::move(out_wf));
+ }
+
+ // protected:
+ ReorderLayerDataset() = default;
+ ReorderLayerDataset(ReorderLayerDataset &&) = default;
+
+ private:
+ std::vector<TensorShape> _in_shapes{};
+ std::vector<TensorShape> _out_shapes{};
+ std::vector<WeightFormat> _in_wfs{};
+ std::vector<WeightFormat> _out_wfs{};
+};
+
+/** [ReorderLayer datasets] **/
+
+class ReorderLayerDatasetBlock4 final : public ReorderLayerDataset
+{
+ public:
+ ReorderLayerDatasetBlock4()
+ {
+ add_config(TensorShape(10U, 9U), TensorShape(10U, 12U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(16U, 16U), TensorShape(16U, 16U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(10U, 511U), TensorShape(10U, 512U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(234U, 301U), TensorShape(234U, 304U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(1024U, 1024U), TensorShape(1024U, 1024U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(10U, 9U, 1U, 1U), TensorShape(10U, 12U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(16U, 16U, 1U, 1U), TensorShape(16U, 16U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(10U, 511U, 1U, 1U), TensorShape(10U, 512U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(234U, 301U, 1U, 1U), TensorShape(234U, 304U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ add_config(TensorShape(1024U, 1024U, 1U, 1U), TensorShape(1024U, 1024U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4);
+ }
+};
+
+class ReorderLayerDatasetBlock8 final : public ReorderLayerDataset
+{
+ public:
+ ReorderLayerDatasetBlock8()
+ {
+ add_config(TensorShape(10U, 9U), TensorShape(10U, 16U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(16U, 16U), TensorShape(16U, 16U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(10U, 511U), TensorShape(10U, 512U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(234U, 301U), TensorShape(234U, 304U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(1024U, 1024U), TensorShape(1024U, 1024U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(10U, 9U, 1U, 1U), TensorShape(10U, 16U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(16U, 16U, 1U, 1U), TensorShape(16U, 16U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(10U, 511U, 1U, 1U), TensorShape(10U, 512U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(234U, 301U, 1U, 1U), TensorShape(234U, 304U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ add_config(TensorShape(1024U, 1024U, 1U, 1U), TensorShape(1024U, 1024U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8);
+ }
+};
+
+} // namespace datasets
+} // namespace test
+} // namespace arm_compute
+#endif /* ACL_TESTS_DATASETS_REORDERLAYERDATASET */
diff --git a/tests/validation/CMakeLists.txt b/tests/validation/CMakeLists.txt
index eef062b5f9..448e96c4f9 100644
--- a/tests/validation/CMakeLists.txt
+++ b/tests/validation/CMakeLists.txt
@@ -138,6 +138,7 @@ if(ENABLE_NEON)
NEON/FullyConnectedLayer.cpp
NEON/ConvolutionLayer.cpp
NEON/StridedSlice.cpp
+ NEON/ReorderLayer.cpp
NEON/UNIT/DynamicTensor.cpp
NEON/UNIT/TensorAllocator.cpp
NEON/UNIT/MemoryManager.cpp
diff --git a/tests/validation/NEON/ReorderLayer.cpp b/tests/validation/NEON/ReorderLayer.cpp
new file mode 100644
index 0000000000..89d860fa4f
--- /dev/null
+++ b/tests/validation/NEON/ReorderLayer.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2023 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/NEReorderLayer.h"
+#include "arm_compute/runtime/Tensor.h"
+#include "tests/NEON/Accessor.h"
+#include "tests/datasets/ReorderLayerDataset.h"
+#include "tests/datasets/ShapeDatasets.h"
+#include "tests/framework/Macros.h"
+#include "tests/framework/datasets/Datasets.h"
+#include "tests/validation/Validation.h"
+#include "tests/validation/fixtures/ReorderFixture.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+TEST_SUITE(NEON)
+TEST_SUITE(ReorderLayer)
+
+template <typename T>
+using NEReorderLayerAlias = ReorderValidationFixture<Tensor, Accessor, NEReorderLayer, T>;
+
+TEST_SUITE(FP32)
+#if defined(ARM_COMPUTE_ENABLE_SVE)
+FIXTURE_DATA_TEST_CASE(RunBlock8, NEReorderLayerAlias<float>, framework::DatasetMode::ALL, combine(datasets::ReorderLayerDatasetBlock8(), framework::dataset::make("DataType", DataType::F32)))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+#endif // ARM_COMPUTE_ENABLE_SVE
+FIXTURE_DATA_TEST_CASE(RunBlock4, NEReorderLayerAlias<float>, framework::DatasetMode::ALL, combine(datasets::ReorderLayerDatasetBlock4(), framework::dataset::make("DataType", DataType::F32)))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+
+TEST_SUITE_END() // FP32
+
+TEST_SUITE_END() // ReorderLayer
+TEST_SUITE_END() // NEON
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/validation/fixtures/ReorderFixture.h b/tests/validation/fixtures/ReorderFixture.h
new file mode 100644
index 0000000000..bb3e3730df
--- /dev/null
+++ b/tests/validation/fixtures/ReorderFixture.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2023 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 ACL_TESTS_VALIDATION_FIXTURES_REORDERFIXTURE
+#define ACL_TESTS_VALIDATION_FIXTURES_REORDERFIXTURE
+
+#include "arm_compute/core/TensorShape.h"
+#include "arm_compute/core/Types.h"
+#include "tests/AssetsLibrary.h"
+#include "tests/Globals.h"
+#include "tests/IAccessor.h"
+#include "tests/framework/Asserts.h"
+#include "tests/framework/Fixture.h"
+#include "tests/validation/reference/Reorder.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+/** [ReorderLayer fixture] **/
+template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
+class ReorderValidationFixture : public framework::Fixture
+{
+public:
+ template <typename...>
+ void setup(TensorShape input_shape, TensorShape output_shape, WeightFormat input_wf, WeightFormat output_wf, DataType data_type)
+ {
+ _target = compute_target(input_shape, output_shape, input_wf, output_wf, data_type);
+ _reference = compute_reference(input_shape, output_shape, output_wf, data_type);
+ }
+
+ protected:
+ template <typename U>
+ void fill(U &&tensor)
+ {
+ library->fill_tensor_uniform(tensor, 0);
+ }
+
+ TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, WeightFormat input_wf, WeightFormat output_wf, DataType data_type)
+ {
+ // Create tensors
+ TensorType src = create_tensor<TensorType>(input_shape, data_type);
+ TensorType dst = create_tensor<TensorType>(output_shape, data_type);
+
+ // Create and configure function
+ FunctionType reorder;
+
+ reorder.configure(&src, &dst, input_wf, output_wf);
+
+ ARM_COMPUTE_ASSERT(src.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(dst.info()->is_resizable());
+
+ // Allocate tensors
+ src.allocator()->allocate();
+ dst.allocator()->allocate();
+
+ ARM_COMPUTE_ASSERT(!src.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(!dst.info()->is_resizable());
+
+ // Fill tensors
+ fill(AccessorType(src));
+
+ // Compute function
+ reorder.run();
+
+ return dst;
+ }
+
+ SimpleTensor<T> compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, WeightFormat output_wf, DataType data_type)
+ {
+ // Create reference
+ SimpleTensor<T> src{ input_shape, data_type };
+
+ // Fill reference
+ fill(src);
+
+ return reference::reorder_layer<T>(src, output_shape, output_wf);
+ }
+
+ TensorType _target{};
+ SimpleTensor<T> _reference{};
+};
+/** [ReorderLayer fixture] **/
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
+#endif /* ACL_TESTS_VALIDATION_FIXTURES_REORDERFIXTURE */
diff --git a/tests/validation/reference/Reorder.cpp b/tests/validation/reference/Reorder.cpp
new file mode 100644
index 0000000000..8abb372596
--- /dev/null
+++ b/tests/validation/reference/Reorder.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2023 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 "Reorder.h"
+#include "src/core/NEON/kernels/arm_gemm/utils.hpp"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace reference
+{
+
+/*
+ * Generic transform.
+ *
+ * Assuming the untransposed case, this works by first reading <BlockBy>
+ * consecutive values from the first input row. This same number of values
+ * are then read from the next <IntBy-1> rows. Now return to the first
+ * input row and repeat.
+ *
+ * Need to cope with the work requested in either dimension not actually
+ * being a multiple of the block sizes.
+ */
+template <unsigned int tIntBy, unsigned int BlockBy, bool Transposed, size_t TOutSize, size_t TInSize, typename d_type, arm_gemm::VLType vlt>
+struct Transform_ref
+{
+ template <typename TOut, typename TIn>
+ static void Transform(TOut &out, const TIn in, const int stride,
+ const int y0, const int ymax, const int x0, const int xmax)
+ {
+ // NOTE: This code is disabled to avoid the call to get_vector_length(), so templated transforms will not be
+ // correct for SVE. This is not an issue as we have specializations for all SVE cases.
+ // For SVE cases we multiply the interleave factor by the vector length.
+ // const unsigned int IntBy = tIntBy * (vlt == VLType::SVE ? get_vector_length<TOut>() / BlockBy : 1);
+ const unsigned int IntBy = tIntBy;
+ int out_index = 0;
+
+ const int n_whole_y_blocks = (ymax - y0) / IntBy;
+ const int y_remainders = (ymax - y0) % IntBy;
+ const int n_y_blocks = n_whole_y_blocks + (y_remainders ? 1 : 0);
+
+ const int n_whole_x_blocks = (xmax - x0) / BlockBy;
+ const int x_remainders = (xmax - x0) % BlockBy;
+ const int n_x_blocks = n_whole_x_blocks + (x_remainders ? 1 : 0);
+
+ // "Y" loop: advance down the rows of the source IntBy rows at a time.
+ // Set up fill_rows to show the number rows to copy from, and blank_rows
+ // for the number of blank rows to add.
+ for(int y_block = 0; y_block < n_y_blocks; y_block++)
+ {
+ const int fill_rows = (y_block < n_whole_y_blocks) ? IntBy : y_remainders;
+ const int blank_rows = IntBy - fill_rows;
+
+ const int y_base = y0 + (y_block * IntBy);
+
+ // So now advance along this block of rows, BlockBy columns at a time.
+ for(int x_block = 0; x_block < n_x_blocks; x_block++)
+ {
+ const int fill_cols = (x_block < n_whole_x_blocks) ? BlockBy : x_remainders;
+ const int blank_cols = BlockBy - fill_cols;
+
+ const int x_base = x0 + (x_block * BlockBy);
+
+ for(int row = 0; row < fill_rows; row++)
+ {
+ for(int col = 0; col < fill_cols; col++)
+ {
+ // In-range copy. If it's transposed, we reverse the sense of rows and columns here.
+ if(Transposed)
+ {
+ out[out_index] = in[(x_base + col) * stride + y_base + row];
+ out_index++;
+ }
+ else
+ {
+ out[out_index] = in[(y_base + row) * stride + x_base + col];
+ out_index++;
+ }
+ }
+ // "col" tail - row is in range but column is out of range.
+ for(int col = 0; col < blank_cols; col++)
+ {
+ out[out_index] = 0;
+ out_index++;
+ }
+ }
+ // "row" tail - row is out of range so fill with zeros always.
+ const d_type zeroval = 0;
+ const int pads = blank_rows * (fill_cols + blank_cols);
+
+ for(int i = 0; i < pads; i++)
+ {
+ out[out_index] = zeroval;
+ }
+
+ out_index += pads;
+ }
+ }
+ }
+};
+
+template <typename T>
+SimpleTensor<T> reorder_layer(const SimpleTensor<T> &src, const TensorShape &output_shape, WeightFormat output_wf)
+{
+ SimpleTensor<T> dst{ output_shape, src.data_type() };
+ const int cols = src.shape()[0];
+ const int rows = src.shape()[1];
+
+ switch(output_wf)
+ {
+ case WeightFormat::OHWIo4:
+ {
+ Transform_ref<4, 1, true, sizeof(float), sizeof(float), float, arm_gemm::VLType::None>::Transform<SimpleTensor<T> &, SimpleTensor<T>>(dst, src, rows, 0, rows, 0, cols);
+ break;
+ }
+ case WeightFormat::OHWIo8:
+ {
+ Transform_ref<8, 1, true, sizeof(float), sizeof(float), float, arm_gemm::VLType::None>::Transform<SimpleTensor<T> &, SimpleTensor<T>>(dst, src, rows, 0, rows, 0, cols);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return dst;
+}
+
+template SimpleTensor<float> reorder_layer(const SimpleTensor<float> &src, const TensorShape &output_shape, WeightFormat output_wf);
+
+} // namespace reference
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/validation/reference/Reorder.h b/tests/validation/reference/Reorder.h
new file mode 100644
index 0000000000..94ee5078f8
--- /dev/null
+++ b/tests/validation/reference/Reorder.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2023 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 ACL_TESTS_VALIDATION_REFERENCE_REORDER
+#define ACL_TESTS_VALIDATION_REFERENCE_REORDER
+
+#include "tests/SimpleTensor.h"
+#include "tests/Types.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace reference
+{
+template <typename T>
+SimpleTensor<T> reorder_layer(const SimpleTensor<T> &src, const TensorShape &output_shape, WeightFormat output_wf);
+} // namespace reference
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
+#endif /* ACL_TESTS_VALIDATION_REFERENCE_REORDER */