From 0d27b2ee8d811d66693555ac1e7be44d93e662e2 Mon Sep 17 00:00:00 2001 From: Jakub Sujak Date: Thu, 24 Aug 2023 14:01:20 +0100 Subject: Remove legacy PostOps code PostOps was the experimental interface for Dynamic Fusion. It is now replaced by the new Dynamic Fusion interface with code generation using the Compute Kernel Writer. Resolves: COMPMID-6190 Change-Id: I813b48facef2fd6f3aee332588886b4f9b3d33d8 Signed-off-by: Jakub Sujak Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10219 Benchmark: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: SiCong Li Comments-Addressed: Arm Jenkins --- tests/validation/CL/ConvolutionLayer.cpp | 291 +------------- tests/validation/CL/GEMMMatrixMultiplyNative.cpp | 244 +----------- tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp | 421 +-------------------- .../CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp | 294 +------------- 4 files changed, 23 insertions(+), 1227 deletions(-) (limited to 'tests/validation/CL') diff --git a/tests/validation/CL/ConvolutionLayer.cpp b/tests/validation/CL/ConvolutionLayer.cpp index bced540d2a..986d76708d 100644 --- a/tests/validation/CL/ConvolutionLayer.cpp +++ b/tests/validation/CL/ConvolutionLayer.cpp @@ -22,7 +22,6 @@ * SOFTWARE. */ #include "arm_compute/core/Types.h" -#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" @@ -69,53 +68,30 @@ constexpr float tolerance_num = 0.07f; /**< T const auto CNNDataTypes = framework::dataset::make("DataType", { DataType::F16, - DataType::F32, - DataType::QASYMM8, - DataType::QASYMM8_SIGNED, + DataType::F32, + DataType::QASYMM8, + DataType::QASYMM8_SIGNED, }); /** Grouped CNN data types */ const auto GroupedCNNDataTypes = framework::dataset::make("DataType", { DataType::F16, - DataType::F32 + DataType::F32 }); -const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", +const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", { ActivationLayerInfo(), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f), + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) }); const auto ActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo", { ActivationLayerInfo(), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) }); - -bool is_post_op_list_valid_in_gemmconv(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &output_shape, DataType data_type, DataLayout data_layout, - const PadStrideInfo &conv_info, const experimental::PostOpList &post_ops) -{ - const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); - const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); - const int idx_kernels = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES); - - const auto dilation = Size2D(1U, 1U); - const unsigned int num_groups = 1U; - - TensorInfo input_info(input_shape, 1, data_type, data_layout); - TensorInfo weights_info(weights_shape, 1, data_type, data_layout); - - TensorInfo output_info(output_shape, 1, data_type, data_layout); - - WeightsInfo w_info(false, weights_info.dimension(idx_width), weights_info.dimension(idx_height), weights_info.dimension(idx_kernels)); - - const auto status = CLGEMMConvolutionLayer::validate(&input_info.clone()->set_is_resizable(true), - &weights_info.clone()->set_is_resizable(true), nullptr, &output_info.clone()->set_is_resizable(true), - conv_info, w_info, dilation, ActivationLayerInfo(), num_groups, post_ops); - return bool(status); -} } // namespace TEST_SUITE(CL) @@ -207,72 +183,6 @@ DATA_TEST_CASE(ValidateConvolutionMethod, framework::DatasetMode::ALL, zip(zip(z enable_fast_math); ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); } - -DATA_TEST_CASE(ValidatePostOpSupportInConvolutionMethod, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip( - framework::dataset::make("InputInfo", { TensorInfo(TensorShape(2U, 17U, 31U), 1, DataType::F32, DataLayout::NHWC), // Select GEMM - TensorInfo(TensorShape(17U, 31U, 32U), 1, DataType::F32, DataLayout::NCHW), // Select WINOGRAD - TensorInfo(TensorShape(27U, 27U, 48U), 1, DataType::F32, DataLayout::NCHW), // Select Direct - TensorInfo(TensorShape(27U, 27U, 48U), 1, DataType::F32, DataLayout::NCHW), // Select FFT - }), - framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(2U, 1U, 1U, 19U), 1, DataType::F32, DataLayout::NHWC), - TensorInfo(TensorShape(5U, 5U, 32U, 19U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(5U, 5U, 48U, 128U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(11U, 11U, 48U, 24), 1, DataType::F32, DataLayout::NCHW), - })), - framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(19U, 17U, 31U), 1, DataType::F32, DataLayout::NHWC), - TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(27U, 27U, 128U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(27U, 27U, 24U), 1, DataType::F32, DataLayout::NCHW), - })), - framework::dataset::make("ConvInfo", { PadStrideInfo(1U, 1U, 0U, 0U), - PadStrideInfo(1U, 1U, 2U, 2U), - PadStrideInfo(1U, 1U, 2U, 2U), - PadStrideInfo(1U, 1U, 5U, 5U), - })), - framework::dataset::make("EnableFastMath", { false, true, false, false})), - framework::dataset::make("ExpectedMethod",{ ConvolutionMethod::GEMM, - ConvolutionMethod::WINOGRAD, - ConvolutionMethod::DIRECT, - ConvolutionMethod::FFT, - })), - framework::dataset::make("PostOpSupported",{ true, false, false, false - })), - input_info, weights_info, output_info, conv_info, enable_fast_math, expected_method, post_op_supported) -{ - const int idx_width = get_data_layout_dimension_index(input_info.data_layout(), DataLayoutDimension::WIDTH); - const int idx_height = get_data_layout_dimension_index(input_info.data_layout(), DataLayoutDimension::HEIGHT); - const int idx_kernels = get_data_layout_dimension_index(input_info.data_layout(), DataLayoutDimension::BATCHES); - - const auto dilation = Size2D(1U, 1U); - const unsigned int num_groups = 1U; - - WeightsInfo w_info(false, weights_info.dimension(idx_width), weights_info.dimension(idx_height), weights_info.dimension(idx_kernels)); - - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - - ConvolutionMethod actual_method = CLConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true), - &weights_info.clone()->set_is_resizable(true), - &output_info.clone()->set_is_resizable(true), conv_info, - WeightsInfo(), - ActivationLayerInfo(), - GPUTarget::BIFROST, - dilation, - enable_fast_math); - ARM_COMPUTE_EXPECT(actual_method == expected_method, framework::LogLevel::ERRORS); - const auto is_valid = CLConvolutionLayer::validate(&input_info.clone()->set_is_resizable(true), - &weights_info.clone()->set_is_resizable(true), - nullptr, - &output_info.clone()->set_is_resizable(true), - conv_info, - w_info, - dilation, - ActivationLayerInfo(), - enable_fast_math, - num_groups, - post_ops); - ARM_COMPUTE_EXPECT( bool(is_valid) == post_op_supported, framework::LogLevel::ERRORS); -} // clang-format on // *INDENT-ON* TEST_SUITE_END() // ConvolutionLayer @@ -285,167 +195,11 @@ using CLGEMMConvolutionLayerMixedDataLayoutFixture = ConvolutionValidationFixtur template using CLConvolutionValidationWithPaddingFixture = ConvolutionValidationWithPaddingFixture; -TEST_SUITE(ValidateFusedPostOpsConfigs) -TEST_SUITE(Invalid) -TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const auto data_layout = DataLayout::NHWC; - const auto conv_info = PadStrideInfo(1, 1, 0, 0); - const auto input_shape = TensorShape(16U, 14U, 12U, 2U); - const auto weights_shape = TensorShape(16U, 1U, 1U, 24U); - - const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info); - - const TensorShape post_op_arg0_shape(output_shape); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - auto post_op_arg1_info = post_op_arg_info.clone(); - - // Unsupported sequence of post ops - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>( - post_op_arg1_info.get(), - 0, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(OnlyNHWCIsSupported, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const auto data_layout = DataLayout::NCHW; - const auto conv_info = PadStrideInfo(1, 1, 0, 0); - const auto input_shape = TensorShape(14U, 12U, 16U, 2U); - const auto weights_shape = TensorShape(1U, 1U, 16U, 24U); - - const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info); - - const TensorShape post_op_arg0_shape(output_shape); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(OnlyFloatingTypeIsSupported, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::QASYMM8; - const auto data_layout = DataLayout::NHWC; - const auto conv_info = PadStrideInfo(1, 1, 0, 0); - const auto input_shape = TensorShape(16U, 14U, 12U, 2U); - const auto weights_shape = TensorShape(16U, 1U, 1U, 24U); - - const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info); - - const TensorShape post_op_arg0_shape(output_shape); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(OnlyConv1x1Stride1IsSupported_UnsupportedKernelSize, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const auto data_layout = DataLayout::NHWC; - const auto conv_info = PadStrideInfo(1, 1, 0, 0); - const auto input_shape = TensorShape(16U, 14U, 12U, 2U); - const auto weights_shape = TensorShape(16U, 3U, 3U, 24U); - - const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info); - - const TensorShape post_op_arg0_shape(output_shape); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(OnlyConv1x1Stride1IsSupported_UnsupportedStride, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const auto data_layout = DataLayout::NHWC; - const auto conv_info = PadStrideInfo(3, 3, 0, 0); - const auto input_shape = TensorShape(16U, 14U, 12U, 2U); - const auto weights_shape = TensorShape(16U, 1U, 1U, 24U); - - const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info); - - const TensorShape post_op_arg0_shape(output_shape); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Invalid -TEST_SUITE(Valid) -TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const auto data_layout = DataLayout::NHWC; - const auto conv_info = PadStrideInfo(1, 1, 0, 0); - const auto input_shape = TensorShape(16U, 14U, 12U, 2U); - const auto weights_shape = TensorShape(16U, 1U, 1U, 24U); - - const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info); - - experimental::PostOpList post_ops{}; - - ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(SupportedPostOps, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const auto data_layout = DataLayout::NHWC; - const auto conv_info = PadStrideInfo(1, 1, 0, 0); - const auto input_shape = TensorShape(16U, 14U, 12U, 2U); - const auto weights_shape = TensorShape(16U, 1U, 1U, 24U); - - const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info); - - TensorShape post_op_arg0_shape(output_shape); - post_op_arg0_shape[1] = 1; // Broadcast in "Y" (second) dimension - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Valid -TEST_SUITE_END() // ValidateFusedPostOps TEST_SUITE(Float) TEST_SUITE(FP16) FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("ReshapeWeights", { true })), - framework::dataset::make("DataType", - DataType::F16)), - framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("ReshapeWeights", { true })), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), ActivationFunctionsSmallDataset)) { // Validate output @@ -456,10 +210,7 @@ TEST_SUITE_END() // FP16 TEST_SUITE(FP32) FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("ReshapeWeights", { true })), - framework::dataset::make("DataType", - DataType::F32)), - framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("ReshapeWeights", { true })), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), ActivationFunctionsSmallDataset)) { // Validate output @@ -503,16 +254,16 @@ using CLGEMMConvolutionLayerQuantizedMixedDataLayoutFixture = ConvolutionValidat template using CLGEMMConvolutionLayerQuantizedPerChannelFixture = ConvolutionValidationQuantizedPerChannelFixture; -const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", +const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", { ActivationLayerInfo(), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) }); const auto QuantizedActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo", { ActivationLayerInfo(), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) }); TEST_SUITE(Quantized) @@ -520,8 +271,8 @@ TEST_SUITE(Quantized) const auto QuantizationData = framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10), - QuantizationInfo(0.3f, 3), - QuantizationInfo(1.1f, 10), + QuantizationInfo(0.3f, 3), + QuantizationInfo(1.1f, 10), }); TEST_SUITE(QASYMM8) @@ -637,9 +388,7 @@ TEST_SUITE(Float) TEST_SUITE(FP32) FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(), - framework::dataset::make("ReshapeWeights", { true })), - framework::dataset::make("DataType", DataType::F32)), - framework::dataset::make("DataLayout", { DataLayout::NCHW })), + framework::dataset::make("ReshapeWeights", { true })), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("DataLayout", { DataLayout::NCHW })), ActivationFunctionsSmallDataset)) { // Validate output @@ -661,9 +410,7 @@ TEST_SUITE_END() // FP32 TEST_SUITE(FP16) FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(), - framework::dataset::make("ReshapeWeights", { true })), - framework::dataset::make("DataType", DataType::F16)), - framework::dataset::make("DataLayout", { DataLayout::NCHW })), + framework::dataset::make("ReshapeWeights", { true })), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("DataLayout", { DataLayout::NCHW })), ActivationFunctionsSmallDataset)) { // Validate output diff --git a/tests/validation/CL/GEMMMatrixMultiplyNative.cpp b/tests/validation/CL/GEMMMatrixMultiplyNative.cpp index 7f63a03371..0ddf43766f 100644 --- a/tests/validation/CL/GEMMMatrixMultiplyNative.cpp +++ b/tests/validation/CL/GEMMMatrixMultiplyNative.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022 Arm Limited. + * Copyright (c) 2019-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -53,11 +53,6 @@ using CLGEMMMatrixMultiplyNative = CLSynthetizeOperator using CLGEMMMatrixMultiplyNativeFixture = GEMMMatrixMultiplyNativeValidationFixture; -// Fixture for CLGEMMMatrixMultiplyNative with post ops -template -using CLGEMMMatrixMultiplyNativeWithPostOpsFixture = - GEMMMatrixMultiplyNativeWithPostOpsValidationFixture; - // Fixture for CLGEMMMatrixMultiplyNative3D template using CLGEMMMatrixMultiplyNative3DFixture = GEMMMatrixMultiplyNative3DValidationFixture; @@ -146,105 +141,6 @@ const auto boundary_handling_cases = combine(combine(combine(combine(combine(com broadcast_bias_values), framework::dataset::make("Activation", ActivationLayerInfo())); -/** Post Ops */ -using PostOpArgBroadcast = CLGEMMMatrixMultiplyNativeWithPostOpsFixture::PostOpArgBroadcast; -experimental::PostOpList post_ops_1() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(true, true, false), // If broadcast in dims 0, 1 and 2 - 0, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -experimental::PostOpList post_ops_2() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - std::make_tuple(false, true, true), // If broadcast in dims 0, 1 and 2 - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -experimental::PostOpList post_ops_3() -{ - experimental::PostOpList post_ops{}; - // post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - post_ops.push_back_op>( - std::make_tuple(false, false, false), // If broadcast in dims 0, 1 and 2 - 1, - ConvertPolicy::SATURATE); - return post_ops; -} -// To test that the output of the main op is the first parameter in prelu post op -experimental::PostOpList post_ops_4() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(false, false, true), // If true, broadcast in corresponding dim: 0, 1 or 2 - 0, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -// To test that the output of the main op is the second parameter in prelu post op i.e. it is the alpha_param -experimental::PostOpList post_ops_5() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(false, false, false), // If true, broadcast in corresponding dim: 0, 1 or 2 - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -/** Different Post Op Lists */ -const auto post_op_lists = framework::dataset::make("post_op_lists", { - post_ops_1(), - post_ops_2(), - post_ops_3(), - post_ops_4(), - post_ops_5() - } ); - -bool is_post_op_list_valid(unsigned int m, unsigned int n, unsigned int k, unsigned int batch, DataType data_type, const experimental::PostOpList& post_ops) -{ - const auto lhs_info = GEMMLHSMatrixInfo(4,4,1,false,true); - const auto rhs_info = GEMMRHSMatrixInfo(4,4,1,true,true,false); - - // Create TensorInfo for post op arguments - TensorInfo input0_info(TensorShape(k, m, batch), 1, data_type); - TensorInfo input1_info(TensorShape(n, k, batch), 1, data_type); - TensorInfo input2_info(TensorShape(n), 1, data_type); - TensorInfo output_info(TensorShape(n, m, batch), 1, data_type); - - GEMMKernelInfo gemm_info(m, n, k, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, - false /**< reinterpret the input as 3D */, - true /**< Flag used to broadcast the bias addition */, - false /**< wider accumm */, - false /**< has pad y */, - ActivationLayerInfo::ActivationFunction::IDENTITY, - 1 /**< Multiplication factor for the width of the 1xW transposed block */, - 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, - lhs_info, - rhs_info, - 0 /**< Offset to be added to each element of the matrix A */, - 0 /**< Offset to be added to each element of the matrix B */, - post_ops); - return bool(ClGemmMatrixMultiplyNativeKernel::validate(&input0_info.clone()->set_is_resizable(true), - &input1_info.clone()->set_is_resizable(true), - &input2_info.clone()->set_is_resizable(true), - &output_info.clone()->set_is_resizable(true),1.f,1.f, - lhs_info, - rhs_info, - gemm_info)); -} - /** Configuration test */ void validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value, unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, bool broadcast_bias, DataType data_type, const ActivationLayerInfo &act_info) { @@ -295,119 +191,6 @@ void validate_configuration(unsigned int m_value, unsigned int n_value, unsigned TEST_SUITE(CL) TEST_SUITE(GEMMMatrixMultiplyNative) -TEST_SUITE(ValidateFusedPostOpsConfigs) -TEST_SUITE(Invalid) -TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 17; - const unsigned int n = 1; - const unsigned int k = 13; - const unsigned int batch = 2; - TensorShape post_op_arg0_shape(n, m, batch); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - auto post_op_arg1_info = post_op_arg_info.clone(); - - // Unsupported sequence of post ops - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>( - post_op_arg1_info.get(), - 0, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(OutputWidened, framework::DatasetMode::ALL) -{ - // Invalid broadcast: post op tensors "widen" the output tensor - const auto data_type = DataType::F32; - const unsigned int m = 1; - const unsigned int n = 18; - const unsigned int k = 13; - const unsigned int batch = 2; - TensorShape post_op_arg_shape(n, m + 1, batch); // output's Y dimension (m) is "widened", which is not allowed - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInXDimOnly, framework::DatasetMode::ALL) -{ - // Invalid broadcast: post op tensors broadcast in the first dimension (X) only - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, m, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Invalid -TEST_SUITE(Valid) -TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - experimental::PostOpList post_ops{}; - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInYDimOnly, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(n, 1, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInBothXandYDims, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, 1, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInAllDims, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, 1, 1); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Valid -TEST_SUITE_END() // ValidateFusedPostOps TEST_SUITE(Float) TEST_SUITE(FP32) DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(combine(combine( @@ -541,31 +324,6 @@ FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyNative3DFixture, f validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyNativeWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - framework::dataset::make("M0", { 4 })), - n0_values_precommit), - k0_values_precommit), - framework::dataset::make("DataType", DataType::F32)), - framework::dataset::make("alpha", {1.0f} )), - framework::dataset::make("beta", {1.0f} )), - framework::dataset::make("broadcast_bias", { false, true } )), - framework::dataset::make("Activation", { ActivationLayerInfo() })), - post_op_lists) - ) -{ - // Validate output - validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); -} - -TEST_SUITE_END() // FusedPostOps - TEST_SUITE_END() // FP32 TEST_SUITE_END() // Float TEST_SUITE_END() // GEMMMatrixMulipltyNative diff --git a/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp b/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp index cdd89670fa..b06e4bf213 100644 --- a/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp +++ b/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022 Arm Limited. + * Copyright (c) 2018-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,7 +23,6 @@ */ #include "arm_compute/core/KernelDescriptors.h" #include "arm_compute/core/Types.h" -#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" @@ -62,21 +61,11 @@ using CLGEMMMatrixMultiplyReshaped = CLSynthetizeOperator using CLGEMMMatrixMultiplyReshapedFixture = GEMMMatrixMultiplyReshapedValidationFixture; -// Fixture for CLGEMMMatrixMultiplyReshaped with post ops -template -using CLGEMMMatrixMultiplyReshapedWithPostOpsFixture = - GEMMMatrixMultiplyReshapedWithPostOpsValidationFixture; - // Fixture for CLGEMMMatrixMultiplyReshaped mixed precision template using CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture = GEMMMatrixMultiplyReshapedValidationFixture; -// Fixture for CLGEMMMatrixMultiplyReshaped mixed precision with post ops -template -using CLGEMMMatrixMultiplyReshapedMixedPrecisionWithPostOpsFixture = - GEMMMatrixMultiplyReshapedWithPostOpsValidationFixture; - // Fixture for CLGEMMMatrixMultiplyReshaped3D template using CLGEMMMatrixMultiplyReshaped3DFixture = GEMMMatrixMultiplyReshaped3DValidationFixture; @@ -184,108 +173,6 @@ const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { /** LHS transposed values */ const auto lhs_transpose_values = framework::dataset::make("lhs_transpose", { false, true } ); -/** Post Ops */ -using PostOpArgBroadcast = CLGEMMMatrixMultiplyReshapedWithPostOpsFixture::PostOpArgBroadcast; -experimental::PostOpList post_ops_1() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(true, true, false), // If broadcast in dims 0, 1 and 2 - 0, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -experimental::PostOpList post_ops_2() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - std::make_tuple(false, true, true), // If broadcast in dims 0, 1 and 2 - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -experimental::PostOpList post_ops_3() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - post_ops.push_back_op>( - std::make_tuple(false, false, true), // If broadcast in dims 0, 1 and 2 - 1, - ConvertPolicy::SATURATE); - return post_ops; -} -// To test that the output of the main op is the first parameter in prelu post op -experimental::PostOpList post_ops_4() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(false, false, true), // If true, broadcast in corresponding dim: 0, 1 or 2 - 0, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -// To test that the output of the main op is the second parameter in prelu post op i.e. it is the alpha_param -experimental::PostOpList post_ops_5() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(false, false, false), // If true, broadcast in corresponding dim: 0, 1 or 2 - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -/** Different Post Op Lists */ -const auto post_op_lists = framework::dataset::make("post_op_lists", { - post_ops_1(), - post_ops_2(), - post_ops_3(), - post_ops_4(), - post_ops_5() - } ); - -bool is_post_op_list_valid(unsigned int m, unsigned int n, unsigned int k, unsigned int batch, DataType data_type, const experimental::PostOpList& post_ops) -{ - const auto lhs_info = GEMMLHSMatrixInfo(4,4,1,false,true); - const auto rhs_info = GEMMRHSMatrixInfo(4,4,1,true,true,false); - - // Create TensorInfo for post op arguments - TensorInfo input0_info(TensorShape(k, m, batch), 1, data_type); - TensorInfo input1_info(TensorShape(n, k, batch), 1, data_type); - TensorInfo input2_info(TensorShape(n), 1, data_type); - TensorInfo output_info(TensorShape(n, m, batch), 1, data_type); - - const TensorInfo reshaped_input0_info = input0_info.clone()->set_tensor_shape(misc::shape_calculator::compute_lhs_reshaped_shape(input0_info, lhs_info)); - const TensorInfo reshaped_input1_info = input1_info.clone()->set_tensor_shape(misc::shape_calculator::compute_rhs_reshaped_shape(input1_info, rhs_info)); - - GEMMKernelInfo gemm_info(m, n, k, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, - false /**< reinterpret the input as 3D */, - true /**< Flag used to broadcast the bias addition */, - false /**< wider accumm */, - false /**< has pad y */, - ActivationLayerInfo::ActivationFunction::IDENTITY, - 1 /**< Multiplication factor for the width of the 1xW transposed block */, - 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, - lhs_info, - rhs_info, - 0 /**< Offset to be added to each element of the matrix A */, - 0 /**< Offset to be added to each element of the matrix B */, - post_ops); - return bool(ClGemmMatrixMultiplyReshapedKernel::validate(&reshaped_input0_info.clone()->set_is_resizable(true), - &reshaped_input1_info.clone()->set_is_resizable(true), - &input2_info.clone()->set_is_resizable(true), - &output_info.clone()->set_is_resizable(true),1.f,1.f, - lhs_info, - rhs_info, - gemm_info)); -} - } // namespace TEST_SUITE(CL) @@ -450,119 +337,7 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zi rhs_info, gemm_info)) == expected, framework::LogLevel::ERRORS); } -TEST_SUITE(ValidateFusedPostOpsConfigs) -TEST_SUITE(Invalid) -TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 17; - const unsigned int n = 1; - const unsigned int k = 13; - const unsigned int batch = 2; - TensorShape post_op_arg0_shape(n, m, batch); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - auto post_op_arg1_info = post_op_arg_info.clone(); - - // Unsupported sequence of post ops - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>( - post_op_arg1_info.get(), - 0, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(OutputWidened, framework::DatasetMode::ALL) -{ - // Invalid broadcast: post op tensors "widen" the output tensor - const auto data_type = DataType::F32; - const unsigned int m = 17; - const unsigned int n = 1; - const unsigned int k = 13; - const unsigned int batch = 2; - TensorShape post_op_arg_shape(n + 4, m, batch); // output's X dimension (n) is "widened", which is not allowed - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInXDimOnly, framework::DatasetMode::ALL) -{ - // Invalid broadcast: post op tensors broadcast in the first dimension (X) only - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, m, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Invalid -TEST_SUITE(Valid) -TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - experimental::PostOpList post_ops{}; - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInYDimOnly, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(n, 1, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInBothXandYDims, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, 1, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInAllDims, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, 1, 1); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Valid -TEST_SUITE_END() // ValidateFusedPostOps + TEST_SUITE(Float) TEST_SUITE(FP32) @@ -697,44 +472,6 @@ FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture, framework::ARM_COMPUTE_PRINT_INFO(); } } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - m0_values_precommit), - n0_values_precommit), - k0_values_precommit), - v0_values_precommit), - h0_values_precommit), - framework::dataset::make("interleave_lhs", { false })), - framework::dataset::make("interleave_rhs", { false })), - framework::dataset::make("export_to_cl_image_rhs", false)), - framework::dataset::make("DataType", DataType::F32)), - a_values_precommit), - beta_values_precommit), - framework::dataset::make("broadcast_bias", { true } )), - lhs_transpose_values), - act_values), - post_op_lists) - ) -{ - // Validate output - if(validate_result) - { - validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); - } - else - { - ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); - framework::ARM_COMPUTE_PRINT_INFO(); - } -} - -TEST_SUITE_END() // FusedPostOps TEST_SUITE(ExportToCLImage) DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( @@ -1002,44 +739,6 @@ FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture, framework::ARM_COMPUTE_PRINT_INFO(); } } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - m0_values_precommit), - n0_values_precommit), - k0_values_precommit), - v0_values_precommit), - h0_values_precommit), - framework::dataset::make("interleave_lhs", { false })), - framework::dataset::make("interleave_rhs", { false })), - framework::dataset::make("export_to_cl_image_rhs", true)), - framework::dataset::make("DataType", DataType::F32)), - a_values_precommit), - beta_values_precommit), - framework::dataset::make("broadcast_bias", { true } )), - lhs_transpose_values), - act_values), - post_op_lists) - ) -{ - // Validate output only if validate() is successful - if(validate_result) - { - validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); - } - else - { - ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); - framework::ARM_COMPUTE_PRINT_INFO(); - } -} - -TEST_SUITE_END() // FusedPostOps TEST_SUITE_END() // ExportToCLImage TEST_SUITE_END() // FP32 @@ -1178,45 +877,6 @@ FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture, } } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - m0_values_precommit), - n0_values_precommit), - k0_values_precommit), - v0_values_precommit), - h0_values_precommit), - framework::dataset::make("interleave_lhs", { false })), - framework::dataset::make("interleave_rhs", { false })), - framework::dataset::make("export_to_cl_image_rhs", false)), - framework::dataset::make("DataType", DataType::F16)), - a_values_precommit), - beta_values_precommit), - framework::dataset::make("broadcast_bias", { true } )), - lhs_transpose_values), - act_values), - post_op_lists) - ) -{ - // Validate output - if(validate_result) - { - validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); - } - else - { - ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); - framework::ARM_COMPUTE_PRINT_INFO(); - } -} - -TEST_SUITE_END() // FusedPostOps - TEST_SUITE(ExportToCLImage) DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported @@ -1483,44 +1143,6 @@ FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture, framework::ARM_COMPUTE_PRINT_INFO(); } } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - m0_values_precommit), - n0_values_precommit), - k0_values_precommit), - v0_values_precommit), - h0_values_precommit), - framework::dataset::make("interleave_lhs", { false })), - framework::dataset::make("interleave_rhs", { false })), - framework::dataset::make("export_to_cl_image_rhs", true)), - framework::dataset::make("DataType", DataType::F16)), - a_values_precommit), - beta_values_precommit), - framework::dataset::make("broadcast_bias", { true } )), - lhs_transpose_values), - act_values), - post_op_lists) - ) -{ - // Validate output only if validate() is successful - if(validate_result) - { - validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); - } - else - { - ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); - framework::ARM_COMPUTE_PRINT_INFO(); - } -} - -TEST_SUITE_END() // FusedPostOps TEST_SUITE_END() // ExportToCLImage TEST_SUITE_END() // FP16 @@ -1659,45 +1281,6 @@ FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionF } } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - m0_values_precommit), - n0_values_precommit), - k0_values_precommit), - v0_values_precommit), - h0_values_precommit), - framework::dataset::make("interleave_lhs", { false })), - framework::dataset::make("interleave_rhs", { false })), - framework::dataset::make("export_to_cl_image_rhs", { true, false })), - framework::dataset::make("DataType", DataType::F16)), - a_values_precommit), - beta_values_precommit), - framework::dataset::make("broadcast_bias", { true } )), - lhs_transpose_values), - act_values), - post_op_lists) - ) -{ - // Validate output - if(validate_result) - { - validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); - } - else - { - ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); - framework::ARM_COMPUTE_PRINT_INFO(); - } -} - -TEST_SUITE_END() // FusedPostOps - TEST_SUITE_END() // MixedPrecision TEST_SUITE_END() // Float TEST_SUITE_END() // GEMMMatrixMultiplyReshaped diff --git a/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp b/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp index 53038c8177..dafc8dc5ec 100644 --- a/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp +++ b/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022 Arm Limited. + * Copyright (c) 2019-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,7 +23,6 @@ */ #include "arm_compute/core/KernelDescriptors.h" #include "arm_compute/core/Types.h" -#include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" @@ -62,11 +61,6 @@ using CLGEMMMatrixMultiplyReshapedOnlyRHSFixture = GEMMMatrixMultiplyReshapedOnl template using CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture = GEMMMatrixMultiplyReshapedOnlyRHS3DValidationFixture; -// Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS with post ops -template -using CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture = - GEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsValidationFixture; - namespace { // *INDENT-OFF* @@ -164,106 +158,6 @@ const auto boundary_handling_cases = combine(combine(combine(combine(combine(com broadcast_bias_values), framework::dataset::make("Activation", ActivationLayerInfo())); -/** Post Ops */ -using PostOpArgBroadcast = CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture::PostOpArgBroadcast; -experimental::PostOpList post_ops_1() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(true, true, false), // If broadcast in dims 0, 1 and 2 - 0, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -experimental::PostOpList post_ops_2() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - std::make_tuple(false, true, true), // If broadcast in dims 0, 1 and 2 - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -experimental::PostOpList post_ops_3() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - post_ops.push_back_op>( - std::make_tuple(false, false, true), // If broadcast in dims 0, 1 and 2 - 1, - ConvertPolicy::SATURATE); - return post_ops; -} -// To test that the output of the main op is the first parameter in prelu post op -experimental::PostOpList post_ops_4() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(false, false, true), // If true, broadcast in corresponding dim: 0, 1 or 2 - 0, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -// To test that the output of the main op is the second parameter in prelu post op i.e. it is the alpha_param -experimental::PostOpList post_ops_5() -{ - experimental::PostOpList post_ops{}; - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); - post_ops.push_back_op>( - std::make_tuple(false, false, false), // If true, broadcast in corresponding dim: 0, 1 or 2 - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); - return post_ops; -} -/** Different Post Op Lists */ -const auto post_op_lists = framework::dataset::make("post_op_lists", { - post_ops_1(), - post_ops_2(), - post_ops_3(), - post_ops_4(), - post_ops_5() - } ); - - bool is_post_op_list_valid(unsigned int m, unsigned int n, unsigned int k, unsigned int batch, DataType data_type, const experimental::PostOpList& post_ops) -{ - const auto lhs_info = GEMMLHSMatrixInfo(4,4,1,false,true); - const auto rhs_info = GEMMRHSMatrixInfo(4,4,1,true,true,false); - - // Create TensorInfo for post op arguments - TensorInfo input0_info(TensorShape(k, m, batch), 1, data_type); - TensorInfo input1_info(TensorShape(n, k, batch), 1, data_type); - TensorInfo input2_info(TensorShape(n), 1, data_type); - TensorInfo output_info(TensorShape(n, m, batch), 1, data_type); - - const TensorInfo reshaped_input1_info = input1_info.clone()->set_tensor_shape(misc::shape_calculator::compute_rhs_reshaped_shape(input1_info, rhs_info)); - - GEMMKernelInfo gemm_info(m, n, k, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, - false /**< reinterpret the input as 3D */, - true /**< Flag used to broadcast the bias addition */, - false /**< wider accumm */, - false /**< has pad y */, - ActivationLayerInfo::ActivationFunction::IDENTITY, - 1 /**< Multiplication factor for the width of the 1xW transposed block */, - 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, - lhs_info, - rhs_info, - 0 /**< Offset to be added to each element of the matrix A */, - 0 /**< Offset to be added to each element of the matrix B */, - post_ops); - return bool(ClGemmMatrixMultiplyReshapedOnlyRhsKernel::validate(&input0_info.clone()->set_is_resizable(true), - &reshaped_input1_info.clone()->set_is_resizable(true), - &input2_info.clone()->set_is_resizable(true), - &output_info.clone()->set_is_resizable(true),1.f,1.f, - lhs_info, - rhs_info, - gemm_info)); -} /** Configuration test */ bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value, unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value, @@ -370,119 +264,6 @@ b_value, m0_value, n0_value, k0_value, broadcast_bias, input_as_3d, depth_output ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS); } -TEST_SUITE(ValidateFusedPostOpsConfigs) -TEST_SUITE(Invalid) -TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 17; - const unsigned int n = 1; - const unsigned int k = 13; - const unsigned int batch = 2; - TensorShape post_op_arg0_shape(n, m, batch); - TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); - auto post_op_arg1_info = post_op_arg_info.clone(); - - // Unsupported sequence of post ops - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( - &post_op_arg_info, - 1, - ConvertPolicy::SATURATE); - post_ops.push_back_op>( - post_op_arg1_info.get(), - 0, - ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(OutputWidened, framework::DatasetMode::ALL) -{ - // Invalid broadcast: post op tensors "widen" the output tensor - const auto data_type = DataType::F32; - const unsigned int m = 17; - const unsigned int n = 1; - const unsigned int k = 1; - const unsigned int batch = 1; - TensorShape post_op_arg_shape(n, m, batch + 4); // output's batch dimension is "widened", which is not allowed - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInXDimOnly, framework::DatasetMode::ALL) -{ - // Invalid broadcast: post op tensors broadcast in the first dimension (X) only - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, m, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Invalid -TEST_SUITE(Valid) -TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - experimental::PostOpList post_ops{}; - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInYDimOnly, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(n, 1, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInBothXandYDims, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, 1, batch); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_CASE(BroadcastInAllDims, framework::DatasetMode::ALL) -{ - const auto data_type = DataType::F32; - const unsigned int m = 22; - const unsigned int n = 16; - const unsigned int k = 15; - const unsigned int batch = 3; - TensorShape post_op_arg_shape(1, 1, 1); - TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); - experimental::PostOpList post_ops{}; - post_ops.push_back_op>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); - - ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); -} -TEST_SUITE_END() // Valid -TEST_SUITE_END() // ValidateFusedPostOps TEST_SUITE(Float) TEST_SUITE(FP32) @@ -684,43 +465,6 @@ FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixtur } } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - m0_values_precommit), - n0_values_precommit), - k0_values_precommit), - framework::dataset::make("H0", {1})), - framework::dataset::make("interleave_rhs", { true })), - t_values_rhs), - framework::dataset::make("export_to_cl_image_rhs", {false, true})), - framework::dataset::make("DataType", DataType::F32)), - a_values), - beta_values), - framework::dataset::make("broadcast_bias", { false } )), - act_values), - post_op_lists) - ) -{ - // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension - if(validate_result) - { - validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); - } - else - { - ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); - framework::ARM_COMPUTE_PRINT_INFO(); - } -} - -TEST_SUITE_END() // FusedPostOps - TEST_SUITE_END() // FP32 TEST_SUITE(FP16) @@ -849,42 +593,6 @@ FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixtur framework::ARM_COMPUTE_PRINT_INFO(); } } -TEST_SUITE(FusedPostOps) - -FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - m_values, - n_values), - k_values), - b_values), - m0_values_precommit), - n0_values_precommit), - k0_values_precommit), - framework::dataset::make("H0", {1})), - framework::dataset::make("interleave_rhs", { true })), - t_values_rhs), - framework::dataset::make("export_to_cl_image_rhs", true)), - framework::dataset::make("DataType", DataType::F16)), - a_values), - beta_values), - framework::dataset::make("broadcast_bias", { false } )), - act_values), - post_op_lists) - ) -{ - // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension - if(validate_result) - { - validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); - } - else - { - ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); - framework::ARM_COMPUTE_PRINT_INFO(); - } -} - -TEST_SUITE_END() // FusedPostOps TEST_SUITE_END() // FP16 -- cgit v1.2.1