From 6f9313477f6a158210479996523c210452d4f07a Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Tue, 15 Sep 2020 14:17:41 +0100 Subject: COMPMID-3671: Extend cl image support to f16 in CLGEMMMatrixMultiplyReshapedKernel Resolves: COMPMID-3671, COMPMID-3672 - Extend cl image support to f16 in CLGEMMMatrixMultiplyReshapedKernel - Extend cl image support to f16 in CLGEMMMatrixMultiplyReshapedOnlyRHSKernel - Change the interface of create_image2d_from_buffer - Extend test Change-Id: I27363be71fa515fbf71aa4be5ed0d6c730f38f34 Signed-off-by: Gian Marco Iodice Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3992 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp | 273 ++++++++++++++++++++- 1 file changed, 268 insertions(+), 5 deletions(-) (limited to 'tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp') diff --git a/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp b/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp index d7853f3ea7..98149ce149 100644 --- a/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp +++ b/tests/validation/CL/GEMMMatrixMultiplyReshaped.cpp @@ -139,13 +139,13 @@ const auto a_values_nightly = framework::dataset::make("alpha", {1.0f} ); const auto beta_values_nightly = framework::dataset::make("beta", {1.0f} ); /** M0 values to test - Nightly */ -const auto m0_values_nightly = framework::dataset::make("M0", { 2, 3, 4, 8 }); +const auto m0_values_nightly = framework::dataset::make("M0", { 8 }); /** N0 values to test - Nightly */ -const auto n0_values_nightly = framework::dataset::make("N0", { 2, 3, 4, 8 }); +const auto n0_values_nightly = framework::dataset::make("N0", { 8 }); /** K0 values to test - Nightly */ -const auto k0_values_nightly = framework::dataset::make("K0", { 2, 3, 4, 8 }); +const auto k0_values_nightly = framework::dataset::make("K0", { 4 }); /** N0 values to test with export to OpenCL image object - Nightly */ const auto n0_export_to_cl_image_values_nightly = framework::dataset::make("N0", { 4, 8, 16 }); @@ -154,10 +154,10 @@ const auto n0_export_to_cl_image_values_nightly = framework::dataset::make("N0", const auto k0_export_to_cl_image_values_nightly = framework::dataset::make("K0", { 4, 8, 16 }); /** V0 values to test - Nightly */ -const auto v0_values_nightly = framework::dataset::make("V0", 1, 4); +const auto v0_values_nightly = framework::dataset::make("V0", 1, 3); /** H0 values to test - Nightly */ -const auto h0_values_nightly = framework::dataset::make("H0", 1, 4); +const auto h0_values_nightly = framework::dataset::make("H0", 1, 3); /** Interleave values to test with LHS matrix */ const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false }); @@ -886,6 +886,269 @@ FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture, // Validate output validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); } + +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 + TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported + TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported + TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect k0 + TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect n0 + + }), + framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F16), + + })), + framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F16), + TensorInfo(TensorShape(64U), 1, DataType::F16), + TensorInfo(TensorShape(64U), 1, DataType::F16), + TensorInfo(TensorShape(64U), 1, DataType::F16), + TensorInfo(TensorShape(64U), 1, DataType::F16), + + })), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), + + })), + framework::dataset::make("LHSMInfo",{ + GEMMLHSMatrixInfo(4, 4, 1, false, true), + GEMMLHSMatrixInfo(4, 8, 1, false, true), + GEMMLHSMatrixInfo(4, 4, 1, false, true), + GEMMLHSMatrixInfo(4, 2, 1, false, false), + GEMMLHSMatrixInfo(4, 4, 1, false, false), + + })), + framework::dataset::make("RHSMInfo",{ + GEMMRHSMatrixInfo(4, 4, 1, true, true, true), + GEMMRHSMatrixInfo(4, 8, 1, true, true, true), + GEMMRHSMatrixInfo(8, 4, 1, true, true, true), + GEMMRHSMatrixInfo(4, 2, 1, true, false, true), + GEMMRHSMatrixInfo(2, 4, 1, true, false, true), + })), + framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**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)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS); +} + +FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture, framework::DatasetMode::ALL, + 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), + i_values_lhs), + i_values_rhs), + framework::dataset::make("export_to_cl_image_rhs", true)), + framework::dataset::make("DataType", DataType::F16)), + a_values_precommit), + beta_values_precommit), + broadcast_bias_values), + lhs_transpose_values), + act_values)) +{ + // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension + if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) + { + 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(RunLarge, CLGEMMMatrixMultiplyReshapedFixture, framework::DatasetMode::NIGHTLY, + 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_nightly), + n0_export_to_cl_image_values_nightly), + k0_export_to_cl_image_values_nightly), + v0_values_nightly), + h0_values_nightly), + i_values_lhs), + i_values_rhs), + framework::dataset::make("export_to_cl_image_rhs", true)), + framework::dataset::make("DataType", DataType::F16)), + a_values_nightly), + beta_values_nightly), + broadcast_bias_values), + lhs_transpose_values), + act_values)) +{ + // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension + if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) + { + 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(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture, framework::DatasetMode::ALL, + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + m_w_values, + m_h_values), + n_values), + k_values), + b_values), + m0_values_precommit), + n0_values_precommit), + k0_values_precommit), + v0_values_precommit), + h0_values_precommit), + i_values_lhs), + i_values_rhs), + framework::dataset::make("export_to_cl_image_rhs", true)), + framework::dataset::make("DataType", DataType::F16)), + a_values_precommit), + beta_values_precommit), + lhs_transpose_values), + act_values)) +{ + // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension + if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) + { + 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(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture, framework::DatasetMode::NIGHTLY, + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + m_w_values, + m_h_values), + n_values), + k_values), + b_values), + m0_values_nightly), + n0_export_to_cl_image_values_nightly), + k0_export_to_cl_image_values_nightly), + v0_values_nightly), + h0_values_nightly), + i_values_lhs), + i_values_rhs), + framework::dataset::make("export_to_cl_image_rhs", true)), + framework::dataset::make("DataType", DataType::F16)), + a_values_nightly), + beta_values_nightly), + lhs_transpose_values), + act_values)) +{ + // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension + if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) + { + 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() // ExportToCLImage TEST_SUITE_END() // FP16 TEST_SUITE(MixedPrecision) -- cgit v1.2.1