From 30902ed3befd225cb3a6915223d0941949b8d265 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 14 Nov 2017 15:32:57 +0000 Subject: COMPMID-617: Add validation methods to ML CL functions. Adds validation support to: - CLDirectConvolution - CLNormalizationLayer - CLSoftmaxLayer Change-Id: I9bd1e925e6db057c799169405f82ed21d20b87ee Reviewed-on: http://mpd-gerrit.cambridge.arm.com/95939 Reviewed-by: Anthony Barbier Tested-by: Kaizen --- tests/validation/CL/DirectConvolutionLayer.cpp | 67 ++++++++++++++++++++++++++ tests/validation/CL/NormalizationLayer.cpp | 32 ++++++++++++ tests/validation/CL/SoftmaxLayer.cpp | 31 ++++++++++++ 3 files changed, 130 insertions(+) (limited to 'tests') diff --git a/tests/validation/CL/DirectConvolutionLayer.cpp b/tests/validation/CL/DirectConvolutionLayer.cpp index 2986369d9b..08d53d5af3 100644 --- a/tests/validation/CL/DirectConvolutionLayer.cpp +++ b/tests/validation/CL/DirectConvolutionLayer.cpp @@ -79,6 +79,73 @@ TEST_SUITE(DirectConvolutionLayer) //TODO(COMPMID-415): Configuration tests? +// *INDENT-OFF* +// clang-format off +DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip( + framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Mismatching data type input/weights + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Mismatching input feature maps + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Unsupported kernel width + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Non-rectangular weights dimensions + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Invalid weights dimensions + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Invalid stride + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Invalid biases size + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Invalid biases dimensions + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Invalid output size + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), + }), + framework::dataset::make("WeightsInfo",{ TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F16, 0), + TensorInfo(TensorShape(3U, 3U, 3U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(9U, 9U, 2U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(5U, 3U, 2U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(3U, 3U, 2U, 4U, 3U), 1, DataType::F32, 0), + TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32, 0), + })), + framework::dataset::make("BiasesInfo",{ TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(3U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U, 2U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(4U), 1, DataType::F32, 0), + })), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(26U, 11U, 4U), 1, DataType::F32, 0), + TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, 0), + })), + framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(3, 3, 0, 0), + PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(1, 1, 0, 0), + PadStrideInfo(1, 1, 0, 0), + })), + framework::dataset::make("Expected", { true, true, true, true, true, true, true, true, true, false })), + input_info, weights_info, biases_info, output_info, conv_info, expected) +{ + bool is_error = bool(CLDirectConvolutionLayer::validate(&input_info, &weights_info, &biases_info, &output_info, conv_info)); + ARM_COMPUTE_EXPECT(is_error == expected, framework::LogLevel::ERRORS); +} +// clang-format on +// *INDENT-ON* + template using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture; diff --git a/tests/validation/CL/NormalizationLayer.cpp b/tests/validation/CL/NormalizationLayer.cpp index 18f0c37ab6..caf7e2a753 100644 --- a/tests/validation/CL/NormalizationLayer.cpp +++ b/tests/validation/CL/NormalizationLayer.cpp @@ -67,6 +67,38 @@ TEST_SUITE(NormalizationLayer) //TODO(COMPMID-415): Missing configuration? +// *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, 0), // Mismatching data type input/output + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Mismatching shapes + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Even normalization + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Non implemented IN_MAP_2D + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 4), // Mismatching fixed point position + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), + }), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16, 0), + TensorInfo(TensorShape(27U, 11U, 2U), 1, DataType::F32, 0), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 3), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), + })), + framework::dataset::make("NormInfo", { NormalizationLayerInfo(NormType::IN_MAP_1D, 5), + NormalizationLayerInfo(NormType::IN_MAP_1D, 5), + NormalizationLayerInfo(NormType::IN_MAP_1D, 4), + NormalizationLayerInfo(NormType::IN_MAP_2D, 5), + NormalizationLayerInfo(NormType::IN_MAP_1D, 5), + NormalizationLayerInfo(NormType::IN_MAP_1D, 5), + })), + framework::dataset::make("Expected", { true, true, true, true, true, false })), + input_info, output_info, norm_info, expected) +{ + ARM_COMPUTE_EXPECT(bool(CLNormalizationLayer::validate(&input_info, &output_info, norm_info)) == expected, framework::LogLevel::ERRORS); +} +// clang-format on +// *INDENT-ON* + template using CLNormalizationLayerFixture = NormalizationValidationFixture; diff --git a/tests/validation/CL/SoftmaxLayer.cpp b/tests/validation/CL/SoftmaxLayer.cpp index a06aa7bbca..b935ef55a0 100644 --- a/tests/validation/CL/SoftmaxLayer.cpp +++ b/tests/validation/CL/SoftmaxLayer.cpp @@ -110,6 +110,37 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datase validate(dst.info()->padding(), padding_dst); } +// *INDENT-OFF* +// clang-format off +DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip( + framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data types + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 2), // Mismatching fixed point + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8, // Invalid output quantization info + QuantizationInfo(1.f/256, 12)), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 3), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8, + QuantizationInfo(1.f/256, 12)), + }), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(27U, 11U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 3), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8, + QuantizationInfo(1.f/256, 12)), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 3), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8, + QuantizationInfo(1.f/256, 0)), + })), + framework::dataset::make("Expected", { true, true, true, true, false, false, false })), + input_info, output_info, expected) +{ + ARM_COMPUTE_EXPECT(bool(CLSoftmaxLayer::validate(&input_info, &output_info)) == expected, framework::LogLevel::ERRORS); +} +// clang-format on +// *INDENT-ON* + template using CLSoftmaxLayerFixture = SoftmaxValidationFixture; -- cgit v1.2.1