aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2018-03-15 17:58:20 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:49:16 +0000
commit2d9de0a3fa6ad858e70040124f362799a962bb6a (patch)
tree0a055c5100438a929b3b04945821665d2fef8751 /tests
parented99f411d52949720a4d64d91664cd71e46b79d5 (diff)
downloadComputeLibrary-2d9de0a3fa6ad858e70040124f362799a962bb6a.tar.gz
COMPMID-1009 Support 4x4 output tile for Winograd Filter Transform on OpenCL.
Change-Id: I68c6453e0f192de659582404f109a89616b9fbb9 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/124811 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/CL/Winograd.cpp37
-rw-r--r--tests/validation/fixtures/WinogradLayerFixture.h16
-rw-r--r--tests/validation/reference/Winograd.cpp116
-rw-r--r--tests/validation/reference/Winograd.h2
4 files changed, 105 insertions, 66 deletions
diff --git a/tests/validation/CL/Winograd.cpp b/tests/validation/CL/Winograd.cpp
index aa668fa575..07a52f8ebc 100644
--- a/tests/validation/CL/Winograd.cpp
+++ b/tests/validation/CL/Winograd.cpp
@@ -147,12 +147,12 @@ TEST_SUITE_END() // InputTransform
TEST_SUITE(FilterTransform)
// *INDENT-OFF*
// clang-format off
-DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(
+DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
framework::dataset::make("InputInfo",{
TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F16), // F16 not supported
TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported
TensorInfo(TensorShape(5U, 5U, 5U, 3U), 1, DataType::F32), // Kernel size not supported
- TensorInfo(TensorShape(3U, 3U), 1, DataType::F32), // valid
+ TensorInfo(TensorShape(3U, 3U), 1, DataType::F32), // Output tile not supported
TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F32), // valid
TensorInfo(TensorShape(3U, 3U, 37U, 2U), 1, DataType::F32), // valid
TensorInfo(TensorShape(3U, 3U, 37U, 22U), 1, DataType::F32) // valid
@@ -164,12 +164,21 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(
TensorInfo(TensorShape(1U, 1U, 16U), 1, DataType::F32),
TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32),
TensorInfo(TensorShape(2U, 37U, 16U), 1, DataType::F32),
- TensorInfo(TensorShape(22U, 37U, 16U), 1, DataType::F32)
+ TensorInfo(TensorShape(22U, 37U, 36U), 1, DataType::F32)
})),
- framework::dataset::make("Expected", { false, false, false, true, true, true, true })),
- input_info, output_info, expected)
+ framework::dataset::make("OutputTile", {
+ Size2D(2U, 2U),
+ Size2D(2U, 2U),
+ Size2D(2U, 2U),
+ Size2D(3U, 3U),
+ Size2D(2U, 2U),
+ Size2D(2U, 2U),
+ Size2D(4U, 4U)
+ })),
+ framework::dataset::make("Expected", { false, false, false, false, true, true, true })),
+ input_info, output_info, output_tile, expected)
{
- ARM_COMPUTE_EXPECT(bool(CLWinogradFilterTransformKernel::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false))) == expected, framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(bool(CLWinogradFilterTransformKernel::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), output_tile)) == expected, framework::LogLevel::ERRORS);
}
// clang-format on
// *INDENT-ON*
@@ -177,13 +186,14 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(
using CLWinogradFilterTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradFilterTransformKernel, 0>;
using CLWinogradFilterTransformFixture = WinogradFilterTransformValidationFixture<CLTensor, CLAccessor, CLWinogradFilterTransform, float>;
-DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallWinogradFilterTransformDataset(), datasets::LargeWinogradFilterTransformDataset()),
+DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallWinogradFilterTransformDataset(), datasets::LargeWinogradFilterTransformDataset()),
+ framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })),
framework::dataset::make("DataType", { DataType::F32 })),
- shape_a, is_nchw_format, data_type)
+ shape_a, is_nchw_format, output_tile, data_type)
{
ARM_COMPUTE_UNUSED(is_nchw_format);
- TensorShape shape_b = compute_winograd_filter_transform_shape(TensorInfo(shape_a, 1, data_type));
+ TensorShape shape_b = compute_winograd_filter_transform_shape(TensorInfo(shape_a, 1, data_type), output_tile);
// Create tensors
CLTensor a = create_tensor<CLTensor>(shape_a, data_type);
@@ -194,16 +204,19 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::da
// Create and configure function
CLWinogradFilterTransform winograd_filter_transform;
- winograd_filter_transform.configure(&a, &b);
+ winograd_filter_transform.configure(&a, &b, output_tile);
}
-FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::ALL, combine(datasets::SmallWinogradFilterTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
+FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallWinogradFilterTransformDataset(), framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })),
+ framework::dataset::make("DataType", { DataType::F32 })))
{
// Validate output
validate(CLAccessor(_target), _reference, tolerance_f32);
}
-FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeWinogradFilterTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
+FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradFilterTransformDataset(),
+ framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })),
+ framework::dataset::make("DataType", { DataType::F32 })))
{
// Validate output
validate(CLAccessor(_target), _reference, tolerance_f32);
diff --git a/tests/validation/fixtures/WinogradLayerFixture.h b/tests/validation/fixtures/WinogradLayerFixture.h
index 9811c28008..c427f8d20e 100644
--- a/tests/validation/fixtures/WinogradLayerFixture.h
+++ b/tests/validation/fixtures/WinogradLayerFixture.h
@@ -225,12 +225,12 @@ class WinogradFilterTransformValidationFixture : public framework::Fixture
{
public:
template <typename...>
- void setup(TensorShape input_shape, bool is_nchw_format, DataType data_type)
+ void setup(TensorShape input_shape, bool is_nchw_format, Size2D output_tile, DataType data_type)
{
- TensorShape output_shape = compute_winograd_filter_transform_shape(TensorInfo(input_shape, 1, data_type));
+ TensorShape output_shape = compute_winograd_filter_transform_shape(TensorInfo(input_shape, 1, data_type), output_tile);
- _target = compute_target(input_shape, output_shape, is_nchw_format, data_type);
- _reference = compute_reference(input_shape, output_shape, is_nchw_format, data_type);
+ _target = compute_target(input_shape, output_shape, is_nchw_format, output_tile, data_type);
+ _reference = compute_reference(input_shape, output_shape, is_nchw_format, output_tile, data_type);
}
protected:
@@ -254,7 +254,7 @@ protected:
}
}
- TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, bool is_nchw_format, DataType data_type)
+ TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, bool is_nchw_format, const Size2D &output_tile, DataType data_type)
{
ARM_COMPUTE_UNUSED(is_nchw_format);
@@ -264,7 +264,7 @@ protected:
// Create and configure function
FunctionType filter_transform;
- filter_transform.configure(&src, &dst);
+ filter_transform.configure(&src, &dst, output_tile);
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
@@ -284,7 +284,7 @@ protected:
return dst;
}
- SimpleTensor<T> compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, bool is_nchw_format, DataType data_type)
+ SimpleTensor<T> compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, bool is_nchw_format, const Size2D &output_tile, DataType data_type)
{
ARM_COMPUTE_UNUSED(is_nchw_format);
@@ -294,7 +294,7 @@ protected:
// Fill reference
fill(src, 0, -1.f, 1.f);
- return reference::winograd_filter_transform<T>(src, output_shape);
+ return reference::winograd_filter_transform<T>(src, output_shape, output_tile);
}
TensorType _target{};
diff --git a/tests/validation/reference/Winograd.cpp b/tests/validation/reference/Winograd.cpp
index c760663b22..ad0dcbd958 100644
--- a/tests/validation/reference/Winograd.cpp
+++ b/tests/validation/reference/Winograd.cpp
@@ -39,40 +39,74 @@ namespace reference
namespace
{
template <typename T>
-void winograd_filter_transform3x3(const SimpleTensor<T> &in, SimpleTensor<T> &out)
+void winograd_filter_transform3x3(const SimpleTensor<T> &in, SimpleTensor<T> &out, const Size2D &output_tile)
{
+ const bool is_2x2 = (output_tile.width == 2);
+ const unsigned int transf_side = is_2x2 ? 4u : 6u;
+
// Simple tensor for the 3x3 input tile
SimpleTensor<T> input_tile{ TensorShape(3u, 3u), in.data_type(), 1 };
// Simple tensor for the transformation matrix
- SimpleTensor<T> trans_matrix{ TensorShape(3u, 4u), in.data_type(), 1 };
+ SimpleTensor<T> trans_matrix{ TensorShape(3u, transf_side), in.data_type(), 1 };
// Simple tensor for the transformation matrix transpose
- SimpleTensor<T> trans_matrix_transposed{ TensorShape(4u, 3u), in.data_type(), 1 };
+ SimpleTensor<T> trans_matrix_transposed{ TensorShape(transf_side, 3u), in.data_type(), 1 };
- // Simple tensor for the 4x3 temporary tile
- SimpleTensor<T> tmp_tile{ TensorShape(3u, 4u), in.data_type(), 1 };
+ // Simple tensor for the 3xSide temporary tile
+ SimpleTensor<T> tmp_tile{ TensorShape(3u, transf_side), in.data_type(), 1 };
- // Simple tensor for the 4x4 output tile
- SimpleTensor<T> output_tile{ TensorShape(4u, 4u), in.data_type(), 1 };
+ // Simple tensor for the SidexSide output tile
+ SimpleTensor<T> transf_tile{ TensorShape(transf_side, transf_side), in.data_type(), 1 };
- // Initialize transformation matrix
- // 1 | 0 | 0
- // 0.5 | 0.5 | 0.5
- // 0.5 |-0.5 | 0.5
- // 0 | 0 | 1
- trans_matrix[0 + 0 * 3] = 1.0f;
- trans_matrix[1 + 0 * 3] = 0.0f;
- trans_matrix[2 + 0 * 3] = 0.0f;
- trans_matrix[0 + 1 * 3] = 0.5f;
- trans_matrix[1 + 1 * 3] = 0.5f;
- trans_matrix[2 + 1 * 3] = 0.5f;
- trans_matrix[0 + 2 * 3] = 0.5f;
- trans_matrix[1 + 2 * 3] = -0.5f;
- trans_matrix[2 + 2 * 3] = 0.5f;
- trans_matrix[0 + 3 * 3] = 0.0f;
- trans_matrix[1 + 3 * 3] = 0.0f;
- trans_matrix[2 + 3 * 3] = 1.0f;
+ if(is_2x2)
+ {
+ // Initialize 3x4 transformation matrix
+ // 1 | 0 | 0
+ // 0.5 | 0.5 | 0.5
+ // 0.5 |-0.5 | 0.5
+ // 0 | 0 | 1
+ trans_matrix[0 + 0 * 3] = 1.0f;
+ trans_matrix[1 + 0 * 3] = 0.0f;
+ trans_matrix[2 + 0 * 3] = 0.0f;
+ trans_matrix[0 + 1 * 3] = 0.5f;
+ trans_matrix[1 + 1 * 3] = 0.5f;
+ trans_matrix[2 + 1 * 3] = 0.5f;
+ trans_matrix[0 + 2 * 3] = 0.5f;
+ trans_matrix[1 + 2 * 3] = -0.5f;
+ trans_matrix[2 + 2 * 3] = 0.5f;
+ trans_matrix[0 + 3 * 3] = 0.0f;
+ trans_matrix[1 + 3 * 3] = 0.0f;
+ trans_matrix[2 + 3 * 3] = 1.0f;
+ }
+ else
+ {
+ // Initialize 3x6 transformation matrix
+ // 1/4 | 0 | 0
+ // -1/6 | -1/6 | -1/6
+ // -1/6 | 1/6 | -1/6
+ // 1/24 | 1/12 | 1/6
+ // 1/24 | -1/12 | 1/6
+ // 0 | 0 | 1
+ trans_matrix[0 + 0 * 3] = 1.0f / 4.0f;
+ trans_matrix[1 + 0 * 3] = 0.0f;
+ trans_matrix[2 + 0 * 3] = 0.0f;
+ trans_matrix[0 + 1 * 3] = -1.0f / 6.0f;
+ trans_matrix[1 + 1 * 3] = -1.0f / 6.0f;
+ trans_matrix[2 + 1 * 3] = -1.0f / 6.0f;
+ trans_matrix[0 + 2 * 3] = -1.0f / 6.0f;
+ trans_matrix[1 + 2 * 3] = 1.0f / 6.0f;
+ trans_matrix[2 + 2 * 3] = -1.0f / 6.0f;
+ trans_matrix[0 + 3 * 3] = 1.0f / 24.0f;
+ trans_matrix[1 + 3 * 3] = 1.0f / 12.0f;
+ trans_matrix[2 + 3 * 3] = 1.0f / 6.0f;
+ trans_matrix[0 + 4 * 3] = 1.0f / 24.0f;
+ trans_matrix[1 + 4 * 3] = -1.0f / 12.0f;
+ trans_matrix[2 + 4 * 3] = 1.0f / 6.0f;
+ trans_matrix[0 + 5 * 3] = 0.0f;
+ trans_matrix[1 + 5 * 3] = 0.0f;
+ trans_matrix[2 + 5 * 3] = 1.0f;
+ }
// Transpose the transformation matrix
transpose_matrix(trans_matrix, trans_matrix_transposed);
@@ -94,26 +128,18 @@ void winograd_filter_transform3x3(const SimpleTensor<T> &in, SimpleTensor<T> &ou
matrix_multiply(trans_matrix, input_tile, tmp_tile);
// Second transformation
- matrix_multiply(tmp_tile, trans_matrix_transposed, output_tile);
+ matrix_multiply(tmp_tile, trans_matrix_transposed, transf_tile);
// Store the 4x4 output tile across the 16 channels
- const int output_offset = w + z * num_filters;
- out[output_offset + 0 * num_filters * num_channels] = output_tile[0 + 0 * 4];
- out[output_offset + 1 * num_filters * num_channels] = output_tile[1 + 0 * 4];
- out[output_offset + 2 * num_filters * num_channels] = output_tile[2 + 0 * 4];
- out[output_offset + 3 * num_filters * num_channels] = output_tile[3 + 0 * 4];
- out[output_offset + 4 * num_filters * num_channels] = output_tile[0 + 1 * 4];
- out[output_offset + 5 * num_filters * num_channels] = output_tile[1 + 1 * 4];
- out[output_offset + 6 * num_filters * num_channels] = output_tile[2 + 1 * 4];
- out[output_offset + 7 * num_filters * num_channels] = output_tile[3 + 1 * 4];
- out[output_offset + 8 * num_filters * num_channels] = output_tile[0 + 2 * 4];
- out[output_offset + 9 * num_filters * num_channels] = output_tile[1 + 2 * 4];
- out[output_offset + 10 * num_filters * num_channels] = output_tile[2 + 2 * 4];
- out[output_offset + 11 * num_filters * num_channels] = output_tile[3 + 2 * 4];
- out[output_offset + 12 * num_filters * num_channels] = output_tile[0 + 3 * 4];
- out[output_offset + 13 * num_filters * num_channels] = output_tile[1 + 3 * 4];
- out[output_offset + 14 * num_filters * num_channels] = output_tile[2 + 3 * 4];
- out[output_offset + 15 * num_filters * num_channels] = output_tile[3 + 3 * 4];
+ const int output_offset = w + z * num_filters;
+
+ for(unsigned int out_h = 0, out_pos = 0; out_h < transf_side; ++out_h)
+ {
+ for(unsigned int out_w = 0; out_w < transf_side; ++out_w, ++out_pos)
+ {
+ out[output_offset + out_pos * num_filters * num_channels] = transf_tile[out_w + out_h * transf_side];
+ }
+ }
}
}
}
@@ -314,7 +340,7 @@ SimpleTensor<T> winograd_input_transform(const SimpleTensor<T> &src, const Tenso
}
template <typename T>
-SimpleTensor<T> winograd_filter_transform(const SimpleTensor<T> &in, const TensorShape &output_shape)
+SimpleTensor<T> winograd_filter_transform(const SimpleTensor<T> &in, const TensorShape &output_shape, const Size2D &output_tile)
{
ARM_COMPUTE_ERROR_ON_MSG(in.data_layout() != DataLayout::NCHW, "Only supported NCHW data format");
@@ -324,7 +350,7 @@ SimpleTensor<T> winograd_filter_transform(const SimpleTensor<T> &in, const Tenso
switch(in.shape()[0])
{
case 3:
- winograd_filter_transform3x3(in, out);
+ winograd_filter_transform3x3(in, out, output_tile);
break;
default:
ARM_COMPUTE_ERROR("Only supported 3x3 kernel");
@@ -358,7 +384,7 @@ SimpleTensor<T> winograd_output_transform(const SimpleTensor<T> &in, const Tenso
}
template SimpleTensor<float> winograd_input_transform(const SimpleTensor<float> &src, const TensorShape &dst_shape, const PadStrideInfo &conv_info, const Size2D &kernel_dims);
-template SimpleTensor<float> winograd_filter_transform(const SimpleTensor<float> &in, const TensorShape &output_shape);
+template SimpleTensor<float> winograd_filter_transform(const SimpleTensor<float> &in, const TensorShape &output_shape, const Size2D &output_tile);
template SimpleTensor<float> winograd_output_transform(const SimpleTensor<float> &in, const TensorShape &output_shape, const Size2D &kernel_dims, const Size2D &num_tiles);
} // namespace reference
} // namespace validation
diff --git a/tests/validation/reference/Winograd.h b/tests/validation/reference/Winograd.h
index fa1a7f3f61..62e136b09d 100644
--- a/tests/validation/reference/Winograd.h
+++ b/tests/validation/reference/Winograd.h
@@ -40,7 +40,7 @@ template <typename T>
SimpleTensor<T> winograd_input_transform(const SimpleTensor<T> &src, const TensorShape &dst_shape, const PadStrideInfo &conv_info, const Size2D &kernel_dims);
template <typename T>
-SimpleTensor<T> winograd_filter_transform(const SimpleTensor<T> &in, const TensorShape &output_shape);
+SimpleTensor<T> winograd_filter_transform(const SimpleTensor<T> &in, const TensorShape &output_shape, const Size2D &output_tile);
template <typename T>
SimpleTensor<T> winograd_output_transform(const SimpleTensor<T> &in, const TensorShape &output_shape, const Size2D &kernel_dims, const Size2D &num_tiles);