aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference/Im2Col.cpp
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2018-08-20 18:03:27 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commitfb62908bd8148bd347bd204e881156f8ebf7835d (patch)
tree78843eb937bb64f5e3439b8367f9cb6d7140d7b2 /tests/validation/reference/Im2Col.cpp
parent66cbafb26261fbf091b799d1e5d0600fb08ee513 (diff)
downloadComputeLibrary-fb62908bd8148bd347bd204e881156f8ebf7835d.tar.gz
COMPMID-1494 Optimise NEON im2col and weights reshape for NHWC
Change-Id: I99ebae61024a7bce9d17292a02c28626ae6c29d5 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/144872 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'tests/validation/reference/Im2Col.cpp')
-rw-r--r--tests/validation/reference/Im2Col.cpp66
1 files changed, 5 insertions, 61 deletions
diff --git a/tests/validation/reference/Im2Col.cpp b/tests/validation/reference/Im2Col.cpp
index 0c41d88f3e..076b2aba07 100644
--- a/tests/validation/reference/Im2Col.cpp
+++ b/tests/validation/reference/Im2Col.cpp
@@ -93,52 +93,6 @@ template <typename T>
void im2col_nhwc(const SimpleTensor<T> &src, SimpleTensor<T> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias)
{
ARM_COMPUTE_ERROR_ON(src.data_layout() != DataLayout::NHWC);
- const int pad_x = conv_info.pad().first;
- const int pad_y = conv_info.pad().second;
- const int stride_x = conv_info.stride().first;
- const int stride_y = conv_info.stride().second;
- const int kernel_width = kernel_dims.width;
- const int kernel_height = kernel_dims.height;
- const int src_width = src.shape().y();
- const int src_height = src.shape().z();
- const int src_depth = src.shape().x();
- const int batches = src.shape().total_size_upper(3);
- const int pad_val = is_data_type_quantized_asymmetric(src.data_type()) ? src.quantization_info().offset : 0;
- int dst_idx = 0;
-
- const int lasty = src_height + (kernel_height > 1 ? pad_y : 0) - kernel_height;
- const int lastx = src_width + (kernel_width > 1 ? pad_x : 0) - kernel_width;
-
- for(int b = 0; b < batches; ++b)
- {
- for(int y = -pad_y; y <= lasty; y += stride_y)
- {
- for(int x = -pad_x; x <= lastx; x += stride_x)
- {
- for(int z = 0; z < src_depth; ++z)
- {
- for(int patch_y = y; patch_y < (y + kernel_height); ++patch_y)
- {
- for(int patch_x = x; patch_x < (x + kernel_width); ++patch_x)
- {
- dst[dst_idx++] = tensor_elem_at(src, Coordinates(z, patch_x, patch_y, b), BorderMode::CONSTANT, static_cast<T>(pad_val));
- }
- }
- }
-
- if(has_bias)
- {
- dst[dst_idx++] = static_cast<T>(1);
- }
- }
- }
- }
-}
-
-template <typename T>
-void im2col_nhwc_channel_first(const SimpleTensor<T> &src, SimpleTensor<T> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias)
-{
- ARM_COMPUTE_ERROR_ON(src.data_layout() != DataLayout::NHWC);
const int stride_x = conv_info.stride().first;
const int stride_y = conv_info.stride().second;
const int kernel_width = kernel_dims.width;
@@ -185,7 +139,7 @@ void im2col_nhwc_channel_first(const SimpleTensor<T> &src, SimpleTensor<T> &dst,
}
template <typename T>
-void im2col(const SimpleTensor<T> &src, SimpleTensor<T> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const unsigned int num_groups, bool channels_first_output_nhwc)
+void im2col(const SimpleTensor<T> &src, SimpleTensor<T> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const unsigned int num_groups)
{
switch(src.data_layout())
{
@@ -196,14 +150,7 @@ void im2col(const SimpleTensor<T> &src, SimpleTensor<T> &dst, const Size2D &kern
}
case DataLayout::NHWC:
{
- if(channels_first_output_nhwc)
- {
- im2col_nhwc_channel_first(src, dst, kernel_dims, conv_info, has_bias);
- }
- else
- {
- im2col_nhwc(src, dst, kernel_dims, conv_info, has_bias);
- }
+ im2col_nhwc(src, dst, kernel_dims, conv_info, has_bias);
break;
}
default:
@@ -214,12 +161,9 @@ void im2col(const SimpleTensor<T> &src, SimpleTensor<T> &dst, const Size2D &kern
}
}
-template void im2col(const SimpleTensor<uint8_t> &src, SimpleTensor<uint8_t> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, unsigned int num_groups,
- bool channels_first_output_nhwc);
-template void im2col(const SimpleTensor<half> &src, SimpleTensor<half> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, unsigned int num_groups,
- bool channels_first_output_nhwc);
-template void im2col(const SimpleTensor<float> &src, SimpleTensor<float> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, unsigned int num_groups,
- bool channels_first_output_nhwc);
+template void im2col(const SimpleTensor<uint8_t> &src, SimpleTensor<uint8_t> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, unsigned int num_groups);
+template void im2col(const SimpleTensor<half> &src, SimpleTensor<half> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, unsigned int num_groups);
+template void im2col(const SimpleTensor<float> &src, SimpleTensor<float> &dst, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, unsigned int num_groups);
} // namespace reference
} // namespace validation
} // namespace test