From c63b722591ff23c8c6fe5fb8ef8c8516d40f03aa Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Wed, 30 Jun 2021 08:39:44 +0000 Subject: Revert "Rework OpenCL Depthwise Convolution" This reverts commit 561c176598cd14245e2e7918fdf136d1c888d1da. Reason for revert: Change-Id: I6f2d61c27520439bb538e9265736532104b24cf8 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5127 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- tests/validation/CL/DepthwiseConvolutionLayer.cpp | 5 +- .../CL/DepthwiseConvolutionLayerNative.cpp | 179 +++------------------ .../fixtures/DepthwiseConvolutionLayerFixture.h | 58 +++---- 3 files changed, 39 insertions(+), 203 deletions(-) (limited to 'tests') diff --git a/tests/validation/CL/DepthwiseConvolutionLayer.cpp b/tests/validation/CL/DepthwiseConvolutionLayer.cpp index e6bf8801bb..c88f7c1624 100644 --- a/tests/validation/CL/DepthwiseConvolutionLayer.cpp +++ b/tests/validation/CL/DepthwiseConvolutionLayer.cpp @@ -48,12 +48,13 @@ constexpr RelativeTolerance tolerance_f32(0.01f); /**< constexpr AbsoluteTolerance tolerance_qasymm8(0); /**< Tolerance value for comparing reference's output against implementation's output for DataType::QASYMM8 */ constexpr float tolerance_num = 0.05f; /**< Tolerance number */ -const auto depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 5 }); +const auto depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 2, 5 }); const auto large_depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 2, 5, 8 }); //Activation Functions const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", { + ActivationLayerInfo(), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.f, 0.f) }); @@ -354,7 +355,7 @@ FIXTURE_DATA_TEST_CASE_NEW(RunMixedDataLayout, CLDepthwiseConvolutionLayerMixedD framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("DataLayout", DataLayout::NHWC)), - framework::dataset::make("ActivationInfo", ActivationLayerInfo()))) + framework::dataset::make("ActivationInfo", ActivationLayerInfo()))) { validate(CLAccessor(_target), _reference, tolerance_f32); } diff --git a/tests/validation/CL/DepthwiseConvolutionLayerNative.cpp b/tests/validation/CL/DepthwiseConvolutionLayerNative.cpp index f565255719..f640ee2b18 100644 --- a/tests/validation/CL/DepthwiseConvolutionLayerNative.cpp +++ b/tests/validation/CL/DepthwiseConvolutionLayerNative.cpp @@ -62,7 +62,7 @@ RelativeTolerance rel_tolerance_f16(half_float::half(0.01f)); constexpr float abs_tolerance_f16(0.03f); /** Width values to test - Precommit */ -const auto width_values_precommit = framework::dataset::make("width", { 1U, 33U } ); +const auto width_values_precommit = framework::dataset::make("width", { 1U, 17U, 32U } ); /** Width values to test - Nightly */ const auto width_values_nightly = framework::dataset::make("width", { 53U, 47U } ); @@ -79,12 +79,6 @@ const auto channel_values_precommit = framework::dataset::make("channels", { 15U /** Channel values to test - Nightly */ const auto channel_values_nightly = framework::dataset::make("channels", { 33U, 19U }); -/** Channel values to test with cl_image support - Precommit */ -const auto channel_values_export_to_cl_image_precommit = framework::dataset::make("channels", { 16U }); - -/** Channel values to test with cl_image support - Nightly */ -const auto channel_values_export_to_cl_image_nightly = framework::dataset::make("channels", { 32U }); - /** Batch values to test - Precommit */ const auto batch_values_precommit = framework::dataset::make("batch", { 1U, 2U }); @@ -121,17 +115,11 @@ const auto n0_values_precommit = framework::dataset::make("N0", {2, 4}); /** N0 values to test - Nightly */ const auto n0_values_nightly = framework::dataset::make("N0", {3, 8}); -/** N0 values to test with cl_image support - Precommit */ -const auto n0_values_export_to_cl_image_precommit = framework::dataset::make("N0", {4}); - -/** N0 values to test with cl_image support - Nightly */ -const auto n0_values_export_to_cl_image_nightly = framework::dataset::make("N0", {8}); - /** Activation values to test */ const auto act_values = framework::dataset::make("Activation", { ActivationLayerInfo(), - ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.0f, 0.5f), + ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 8.f, 2.f), }); } // namespace @@ -141,7 +129,7 @@ TEST_SUITE(DepthwiseConvolutionLayerNative) TEST_SUITE(Float) TEST_SUITE(FP32) FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_precommit, height_values_precommit), channel_values_precommit), @@ -154,15 +142,14 @@ FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_nightly, height_values_nightly), channel_values_nightly), @@ -175,79 +162,16 @@ FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - width_values_precommit, - height_values_precommit), - channel_values_export_to_cl_image_precommit), - batch_values_precommit), - kernel_sz_values_precommit), - framework::dataset::make("depth_multiplier", 1)), - dilation_values), - stride_values), - padding_valid_values), - framework::dataset::make("DataType", DataType::F32)), - data_layout_values), - act_values), - n0_values_export_to_cl_image_precommit), - framework::dataset::make("ExportToCLImage", true))) -{ - // Validate output - if(_validate_output) - { - // Validate output - 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(); - } -} - -FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - width_values_nightly, - height_values_nightly), - channel_values_export_to_cl_image_nightly), - batch_values_nightly), - kernel_sz_values_nightly), - framework::dataset::make("depth_multiplier", 1)), - dilation_values), - stride_values), - padding_valid_values), - framework::dataset::make("DataType", DataType::F32)), - data_layout_values), - act_values), - n0_values_export_to_cl_image_nightly), - framework::dataset::make("ExportToCLImage", true))) -{ - // Validate output - if(_validate_output) - { - // Validate output - 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() // ExportWeightsToCLImage TEST_SUITE_END() // FP32 TEST_SUITE(FP16) FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_precommit, height_values_precommit), channel_values_precommit), @@ -260,15 +184,14 @@ FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_nightly, height_values_nightly), channel_values_nightly), @@ -281,80 +204,18 @@ FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - width_values_precommit, - height_values_precommit), - channel_values_export_to_cl_image_precommit), - batch_values_precommit), - kernel_sz_values_precommit), - framework::dataset::make("depth_multiplier", 1)), - dilation_values), - stride_values), - padding_valid_values), - framework::dataset::make("DataType", DataType::F16)), - data_layout_values), - act_values), - n0_values_export_to_cl_image_precommit), - framework::dataset::make("ExportToCLImage", true))) -{ - // Validate output - if(_validate_output) - { - // Validate output - 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(); - } -} - -FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( - width_values_nightly, - height_values_nightly), - channel_values_export_to_cl_image_nightly), - batch_values_nightly), - kernel_sz_values_nightly), - framework::dataset::make("depth_multiplier", 1)), - dilation_values), - stride_values), - padding_valid_values), - framework::dataset::make("DataType", DataType::F16)), - data_layout_values), - act_values), - n0_values_export_to_cl_image_nightly), - framework::dataset::make("ExportToCLImage", true))) -{ - // Validate output - if(_validate_output) - { - // Validate output - 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() // ExportWeightsToCLImage TEST_SUITE_END() // FP16 TEST_SUITE_END() // Float TEST_SUITE(DepthMultiplier) TEST_SUITE(Float) TEST_SUITE(FP32) FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_precommit, height_values_precommit), channel_values_precommit), @@ -367,15 +228,14 @@ FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_nightly, height_values_nightly), channel_values_nightly), @@ -388,8 +248,7 @@ FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::ALL, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_precommit, height_values_precommit), channel_values_precommit), @@ -411,15 +270,14 @@ FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( width_values_nightly, height_values_nightly), channel_values_nightly), @@ -432,8 +290,7 @@ FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture void setup(size_t width, size_t height, size_t channel, size_t batch, Size2D kernel_size, size_t depth_multiplier, Size2D dilation, Size2D stride, bool padding_valid, DataType data_type, - DataLayout data_layout, const ActivationLayerInfo &act_info, unsigned int n0, bool export_to_cl_image) + DataLayout data_layout, const ActivationLayerInfo &act_info, unsigned int n0) { - _dilation = dilation; - _depth_multiplier = depth_multiplier; - _data_type = data_type; - _data_layout = data_layout; - _act_info = act_info; - _n0 = n0; - _export_to_cl_image = export_to_cl_image; + _dilation = dilation; + _depth_multiplier = depth_multiplier; + _data_type = data_type; + _data_layout = data_layout; + _act_info = act_info; + _n0 = n0; _input_shape = TensorShape(width, height, channel, batch); _weights_shape = TensorShape(kernel_size.width, kernel_size.height, channel * _depth_multiplier); @@ -415,11 +414,11 @@ public: if(padding_valid) { - _conv_info = calculate_same_pad(_input_shape, _weights_shape, PadStrideInfo(stride.width, stride.height), DataLayout::NCHW, _dilation); + _conv_info = PadStrideInfo(); } else { - _conv_info = PadStrideInfo(stride.width, stride.height); + _conv_info = calculate_same_pad(_input_shape, _weights_shape, PadStrideInfo(stride.width, stride.height), DataLayout::NCHW, _dilation); } } @@ -440,26 +439,14 @@ public: _biases = create_tensor(_biases_shape, _data_type, 1, QuantizationInfo(), _data_layout); _target = create_tensor(TensorShape(), _data_type, 1, QuantizationInfo(), _data_layout); - DWCComputeKernelInfo dwc_info; - dwc_info.n0 = _n0; - dwc_info.m0 = _conv_info.stride().first == 1 && _dilation.x() == 1 ? 8 : 1; - dwc_info.export_weights_to_cl_image = _export_to_cl_image; + DWCWeightsKernelInfo dwc_weights_info; + dwc_weights_info.n0 = _n0; -#if defined(ARM_COMPUTE_OPENCL_ENABLED) - if(_export_to_cl_image) - { - _validate_output |= image2d_from_buffer_supported(CLKernelLibrary::get().get_device()); - _validate_output |= (get_cl_image_pitch_alignment(CLKernelLibrary::get().get_device()) != 0); - } -#endif // ARM_COMPUTE_OPENCL_ENABLED - - const ConvolutionInfo conv_kernel_info - { - _conv_info, _depth_multiplier, _act_info, _dilation - }; + DWCKernelInfo dwc_info; + dwc_info.activation_info = _act_info; // Create Depthwise Convolution configure function - _dwc.configure(&_src, &_weights, &_biases, &_target, dwc_info, conv_kernel_info); + _dwc.configure(&_src, &_weights, &_biases, &_target, dwc_weights_info, dwc_info, _conv_info, _depth_multiplier, _dilation); ARM_COMPUTE_ASSERT(_src.info()->is_resizable()); ARM_COMPUTE_ASSERT(_weights.info()->is_resizable()); @@ -469,8 +456,7 @@ public: void allocate_and_run_target() { - add_padding_x({ &_src, &_biases, &_target }, _data_layout); - add_padding_x({ &_weights }, _data_layout, _export_to_cl_image); // Don't add left padding if cl image will be used + add_padding_x({ &_src, &_weights, &_biases, &_target }, _data_layout); // Allocate tensors _src.allocator()->allocate(); @@ -493,10 +479,7 @@ public: _target.info()->set_data_layout(_data_layout == DataLayout::NCHW ? DataLayout::NHWC : DataLayout::NCHW); // Compute function - if(_validate_output) - { - _dwc.run(); - } + _dwc.run(); // Reinstating original data layout for the test suite to properly check the values _target.info()->set_data_layout(_data_layout); @@ -514,10 +497,7 @@ public: const ConvolutionInfo info{ _conv_info, _depth_multiplier, _act_info, _dilation }; const TensorShape dst_shape = compute_depthwise_convolution_shape(TensorInfo(_input_shape, 1, _data_type), TensorInfo(_weights_shape, 1, _data_type), info); - if(_validate_output) - { - _reference = reference::activation_layer(reference::depthwise_convolution(src, weights, biases, dst_shape, _conv_info, _depth_multiplier, _dilation), _act_info); - } + _reference = reference::activation_layer(reference::depthwise_convolution(src, weights, biases, dst_shape, _conv_info, _depth_multiplier, _dilation), _act_info); } protected: @@ -561,8 +541,6 @@ protected: Size2D _dilation{}; unsigned int _depth_multiplier{}; unsigned int _n0{}; - bool _export_to_cl_image{}; - bool _validate_output{ true }; }; template -- cgit v1.2.1