diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/validation/CL/Convolution3D.cpp | 275 | ||||
-rw-r--r-- | tests/validation/fixtures/DirectConvolution3DFixture.h | 8 |
2 files changed, 279 insertions, 4 deletions
diff --git a/tests/validation/CL/Convolution3D.cpp b/tests/validation/CL/Convolution3D.cpp new file mode 100644 index 0000000000..75e2e99b03 --- /dev/null +++ b/tests/validation/CL/Convolution3D.cpp @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2021 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/CL/CLTensor.h" +#include "arm_compute/runtime/CL/functions/CLConv3D.h" +#include "arm_compute/runtime/FunctionDescriptors.h" +#include "tests/CL/CLAccessor.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DirectConvolution3DFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +RelativeTolerance<half> tolerance_fp16(half(0.2)); /**< Tolerance for floating point tests */ +RelativeTolerance<float> tolerance_fp32(0.05f); /**< Tolerance for floating point tests */ +constexpr float abs_tolerance_f32(0.0001f); /**< Absolute tolerance for FP32 tests*/ +constexpr float tolerance_num = 0.07f; /**< Tolerance number */ +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(DirectConvolution3D) + +// *INDENT-OFF* +// clang-format off +DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip( + framework::dataset::make("InputShape", { TensorShape(27U, 13U, 5U, 3U), // Unsupported data layout + TensorShape(27U, 13U, 5U, 3U), // Unsupported activation enabled + TensorShape(27U, 13U, 5U, 3U), // Mismatching data type + TensorShape(27U, 13U, 5U, 3U), // Unsupported data type + TensorShape(27U, 13U, 5U, 3U), // Mismatching input feature maps + TensorShape(27U, 13U, 5U, 3U), // Mismatching output feature maps + TensorShape(27U, 13U, 5U, 3U), // Mismatching bias shape + TensorShape(27U, 13U, 5U, 3U), // Unsupported number of weights dimensions + TensorShape(27U, 13U, 5U, 3U), // Unsupported number of biases dimensions + TensorShape(27U, 13U, 5U, 3U), // Mismatching output shape + TensorShape(27U, 13U, 5U, 3U) + }), + framework::dataset::make("WeightsShape", { TensorShape(4U, 27U, 3U, 3U, 3U), + TensorShape(4U, 27U, 3U, 3U, 3U), + TensorShape(4U, 27U, 3U, 3U, 3U), + TensorShape(4U, 27U, 3U, 3U, 3U), + TensorShape(4U, 32U, 3U, 3U, 3U), + TensorShape(8U, 27U, 3U, 3U, 3U), + TensorShape(4U, 27U, 3U, 3U, 3U), + TensorShape(4U, 27U, 3U, 3U, 3U, 2U), + TensorShape(4U, 27U, 3U, 3U, 3U), + TensorShape(4U, 27U, 3U, 3U, 3U), + TensorShape(4U, 27U, 3U, 3U, 3U) + })), + framework::dataset::make("BiasesShape", { TensorShape(4U), + TensorShape(4U), + TensorShape(4U), + TensorShape(4U), + TensorShape(4U), + TensorShape(4U), + TensorShape(8U), + TensorShape(4U), + TensorShape(4U), + TensorShape(4U), + TensorShape(4U) + })), + framework::dataset::make("OutputShape", { TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U, 2U), + TensorShape(4U, 11U, 5U, 3U), + TensorShape(4U, 13U, 5U, 3U) + })), + framework::dataset::make("Conv3dInfo", { Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false), + Conv3dInfo(Size3D(1U, 1U, 1U), Padding3D(1U, 1U, 1U), ActivationLayerInfo(), Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false) + })), + framework::dataset::make("SrcDataType", { DataType::F32, + DataType::F32, + DataType::F32, + DataType::QASYMM8, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32 + })), + framework::dataset::make("WeightsDataType", { DataType::F32, + DataType::F32, + DataType::F16, + DataType::QASYMM8, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32, + DataType::F32 + })), + framework::dataset::make("DataLayout", { DataLayout::NCDHW, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC, + DataLayout::NDHWC + })), + framework::dataset::make("Expected", { false, false, false, false, false, false, false, false, false, false, true })), + input_shape, weights_shape, biases_shape, output_shape, conv3d_info, src_data_type, weights_data_type, data_layout, expected) +{ + TensorInfo input_info = TensorInfo(input_shape, 1, src_data_type); + TensorInfo weights_info = TensorInfo(weights_shape, 1, weights_data_type); + TensorInfo biases_info = TensorInfo(biases_shape, 1, src_data_type); + TensorInfo output_info = TensorInfo(output_shape, 1, src_data_type); + + input_info.set_data_layout(data_layout); + weights_info.set_data_layout(data_layout); + biases_info.set_data_layout(data_layout); + output_info.set_data_layout(data_layout); + + bool is_valid = bool(CLConv3D::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &biases_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv3d_info)); + ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); +} + +template <typename T> +using CLDirectConvolution3DFixture = DirectConvolution3DValidationFixture<CLTensor, CLAccessor, CLConv3D, T>; + +TEST_SUITE(NDHWC) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolution3DFixture<half>, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip( + framework::dataset::make("InputShape", { TensorShape(7U, 5U, 3U, 13U, 3U), + TensorShape(15U, 7U, 11U, 7U), + TensorShape(19U, 5U, 16U, 4U), + TensorShape(13U, 5U, 17U, 2U) + }), + framework::dataset::make("StrideX", { 1, 3, 2, 1 })), + framework::dataset::make("StrideY", { 2, 1, 3, 1 })), + framework::dataset::make("StrideZ", { 3, 2, 1, 1 })), + framework::dataset::make("PadX", { 0, 2, 1, 0 })), + framework::dataset::make("PadY", { 1, 0, 2, 0 })), + framework::dataset::make("PadZ", { 2, 1, 0, 0 })), + framework::dataset::make("KernelWidth", { 3, 7, 5, 1 })), + framework::dataset::make("KernelHeight", { 5, 3, 7, 1 })), + framework::dataset::make("KernelDepth", { 7, 5, 3, 1 })), + framework::dataset::make("NumKernels", { 5, 3, 1, 11 })), + framework::dataset::make("HasBias", { true, true, true, false })), + framework::dataset::make("Activation", ActivationLayerInfo())), + framework::dataset::make("DataType", DataType::F16)), + framework::dataset::make("DataLayout", DataLayout::NDHWC))) +{ + validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolution3DFixture<half>, framework::DatasetMode::NIGHTLY, + combine(combine(combine(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip( + framework::dataset::make("InputShape", { TensorShape(400U, 400U, 200U, 11U) }), + framework::dataset::make("StrideX", { 1 })), + framework::dataset::make("StrideY", { 1 })), + framework::dataset::make("StrideZ", { 1 })), + framework::dataset::make("PadX", { 1 })), + framework::dataset::make("PadY", { 1 })), + framework::dataset::make("PadZ", { 1 })), + framework::dataset::make("KernelWidth", { 5 })), + framework::dataset::make("KernelHeight", { 5 })), + framework::dataset::make("KernelDepth", { 5 })), + framework::dataset::make("NumKernels", { 300 })), + framework::dataset::make("HasBias", { true })), + framework::dataset::make("Activation", ActivationLayerInfo())), + framework::dataset::make("DataType", DataType::F16)), + framework::dataset::make("DataLayout", DataLayout::NDHWC))) +{ + validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); +} + +TEST_SUITE_END() // FP16 + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolution3DFixture<float>, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip( + framework::dataset::make("InputShape", { TensorShape(7U, 5U, 3U, 13U, 3U), + TensorShape(15U, 7U, 11U, 7U), + TensorShape(19U, 5U, 16U, 4U), + TensorShape(13U, 5U, 17U, 2U) + }), + framework::dataset::make("StrideX", { 1, 3, 2, 1 })), + framework::dataset::make("StrideY", { 2, 1, 3, 1 })), + framework::dataset::make("StrideZ", { 3, 2, 1, 1 })), + framework::dataset::make("PadX", { 0, 2, 1, 0 })), + framework::dataset::make("PadY", { 1, 0, 2, 0 })), + framework::dataset::make("PadZ", { 2, 1, 0, 0 })), + framework::dataset::make("KernelWidth", { 3, 7, 5, 1 })), + framework::dataset::make("KernelHeight", { 5, 3, 7, 1 })), + framework::dataset::make("KernelDepth", { 7, 5, 3, 1 })), + framework::dataset::make("NumKernels", { 5, 3, 1, 11 })), + framework::dataset::make("HasBias", { true, true, true, false })), + framework::dataset::make("Activation", ActivationLayerInfo())), + framework::dataset::make("DataType", DataType::F32)), + framework::dataset::make("DataLayout", DataLayout::NDHWC))) +{ + validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolution3DFixture<float>, framework::DatasetMode::NIGHTLY, + combine(combine(combine(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip( + framework::dataset::make("InputShape", { TensorShape(400U, 400U, 200U, 11U) }), + framework::dataset::make("StrideX", { 1 })), + framework::dataset::make("StrideY", { 1 })), + framework::dataset::make("StrideZ", { 1 })), + framework::dataset::make("PadX", { 1 })), + framework::dataset::make("PadY", { 1 })), + framework::dataset::make("PadZ", { 1 })), + framework::dataset::make("KernelWidth", { 9 })), + framework::dataset::make("KernelHeight", { 9 })), + framework::dataset::make("KernelDepth", { 9 })), + framework::dataset::make("NumKernels", { 300 })), + framework::dataset::make("HasBias", { true })), + framework::dataset::make("Activation", ActivationLayerInfo())), + framework::dataset::make("DataType", DataType::F32)), + framework::dataset::make("DataLayout", DataLayout::NDHWC))) +{ + validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); +} + +// clang-format on +// *INDENT-ON* +TEST_SUITE_END() // FP32 +TEST_SUITE_END() // NDHWC +TEST_SUITE_END() // DirectConvolution3D +TEST_SUITE_END() // CL + +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/fixtures/DirectConvolution3DFixture.h b/tests/validation/fixtures/DirectConvolution3DFixture.h index 717f6f281e..3a675ac6d3 100644 --- a/tests/validation/fixtures/DirectConvolution3DFixture.h +++ b/tests/validation/fixtures/DirectConvolution3DFixture.h @@ -41,12 +41,12 @@ class DirectConvolution3DValidationGenericFixture : public framework::Fixture { public: template <typename...> - void setup(TensorShape input_shape, int stride_x, int stride_y, int stride_z, int pad_x, int pad_y, int pad_z, unsigned int kernel_width, int kernel_height, int kernel_depth, - unsigned int num_kernels, bool has_bias, ActivationLayerInfo act_info, DataType data_type, DataLayout data_layout) + void setup(const TensorShape &input_shape, int stride_x, int stride_y, int stride_z, int pad_x, int pad_y, int pad_z, unsigned int kernel_width, int kernel_height, int kernel_depth, + unsigned int num_kernels, bool has_bias, const ActivationLayerInfo &act_info, const DataType &data_type, const DataLayout &data_layout) { ARM_COMPUTE_ERROR_ON(data_layout != DataLayout::NDHWC); - TensorShape weights_shape(num_kernels, input_shape[0], kernel_width, kernel_height, kernel_depth); + const TensorShape weights_shape(num_kernels, input_shape[0], kernel_width, kernel_height, kernel_depth); const TensorShape bias_shape(num_kernels); const Conv3dInfo conv3d_info(Size3D(stride_x, stride_y, stride_z), Padding3D(pad_x, pad_y, pad_z), act_info, Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false); const TensorShape output_shape = compute_conv3d_shape(input_shape, weights_shape, conv3d_info); @@ -78,7 +78,7 @@ protected: } } - TensorType compute_target(TensorShape input_shape, TensorShape weights_shape, const TensorShape &bias_shape, TensorShape output_shape, const Conv3dInfo &conv3d_info, + TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const Conv3dInfo &conv3d_info, bool has_bias, const DataType &data_type, const DataLayout &data_layout) { // Create tensors |