From e572dff7adc334a98ac4a0326d66037451d5d079 Mon Sep 17 00:00:00 2001 From: Freddie Liardet Date: Mon, 16 May 2022 14:09:10 +0100 Subject: Add GemmLowp MMUL Reshaped Only Rhs Support for QASYMM8/QASYMM8_SIGNED This patch introduces a GEMMLowp routine that is optimized for Arm(R) Mali(TM)-G715 and Arm(R) Mali(TM)-G615 Resolves: COMPMID-5398 Signed-off-by: Freddie Liardet Signed-off-by: Gunes Bayir Change-Id: I8d06453645688f3658b6c7c06f1ebc25a2505661 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7932 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: SiCong Li Reviewed-by: Pablo Marquez Tello Benchmark: Arm Jenkins --- .../GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL.cpp | 206 +++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 tests/validation/CL/GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL.cpp (limited to 'tests/validation/CL/GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL.cpp') diff --git a/tests/validation/CL/GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL.cpp b/tests/validation/CL/GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL.cpp new file mode 100644 index 0000000000..a0d13c3e39 --- /dev/null +++ b/tests/validation/CL/GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL.cpp @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2022 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/functions/CLCast.h" +#include "arm_compute/runtime/CL/functions/CLReductionOperation.h" +#include "src/gpu/cl/kernels/ClGemmLowpMatrixMultiplyReshapedOnlyRhsMMULKernel.h" +#include "src/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h" +#include "tests/CL/CLAccessor.h" +#include "tests/CL/Helper.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/fixtures/GEMMLowpFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +using namespace arm_compute::opencl::kernels; + +// Create function for CLGEMMReshapeRHSMatrixKernel +using CLGEMMReshapeRHSMatrix = CLSynthetizeOperator; + +// Create function for CLGEMMLowpMatrixMultiplyReshapedOnlyRHSKernel +using CLGEMMLowpMatrixMultiplyReshapedOnlyRHS = CLSynthetizeOperator; + +// Fixture for CLGEMMLowpMatrixMultiplyReshapedOnlyRHS +using CLGEMMLowpMatrixMultiplyReshapedOnlyRHSMMULFixture = + GEMMLowpMatrixMultiplyReshapedOnlyRHSMMULValidationFixture; + +// Fixture for CLGEMMLowpMatrixMultiplyReshapedOnlyRHS +using CLGEMMLowpMatrixMultiplyReshapedOnlyRHSMMULOutputStageFixtureSigned = + GEMMLowpMatrixMultiplyReshapedOnlyRHSMMULOutputStageValidationFixture; + +using CLGEMMLowpMatrixMultiplyReshapedOnlyRHSMMULOutputStageFixtureUnsigned = + GEMMLowpMatrixMultiplyReshapedOnlyRHSMMULOutputStageValidationFixture; + +namespace +{ +// *INDENT-OFF* +// clang-format off + +/** M values to test */ +const auto m_values = framework::dataset::make("M", {16, 49}); + +/** N values to test */ +const auto n_values = framework::dataset::make("N", {16, 259}); + +/** K values to test */ +const auto k_values = framework::dataset::make("K", {192}); + +/** Batch size values to test */ +const auto b_values = framework::dataset::make("batch_size", {1, 2}); + +/** M0 values to test - Precommit */ +const auto m0 = framework::dataset::make("M0", {1, 2, 4}); + +/** N0 values to test - Precommit */ +const auto n0 = framework::dataset::make("N0", { 1, 4, 8}); + +/** K0 values to test - Precommit */ +const auto k0 = framework::dataset::make("K0", { 4 }); + +/** H0 values to test - Precommit */ +const auto h0 = framework::dataset::make("H0", 1); + +/** Interleave values to test with RHS matrix */ +const auto i_values_rhs = framework::dataset::make("interleave_rhs", { false }); + +/** Transpose values to test with RHS matrix */ +const auto t_values_rhs = framework::dataset::make("transpose_rhs", { true }); + +const auto broadcast_bias = framework::dataset::make("broadcast_bias", {true, false}); + +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL) +FIXTURE_DATA_TEST_CASE(Signed, CLGEMMLowpMatrixMultiplyReshapedOnlyRHSMMULFixture, framework::DatasetMode::ALL, + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + m_values, + n_values), + k_values), + b_values), + m0), + n0), + k0), + h0), + i_values_rhs), + t_values_rhs), + framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED }))) +{ + // Validate output + if(arm_matrix_multiply_supported(CLKernelLibrary::get().get_device())) + { + validate(CLAccessor(_target), _reference); + } + else + { + ARM_COMPUTE_TEST_INFO("cl_arm_matrix_multiply not supported. TEST skipped"); + framework::ARM_COMPUTE_PRINT_INFO(); + } +} +FIXTURE_DATA_TEST_CASE(Unsigned, CLGEMMLowpMatrixMultiplyReshapedOnlyRHSMMULFixture, framework::DatasetMode::ALL, + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + m_values, + n_values), + k_values), + b_values), + m0), + n0), + k0), + h0), + i_values_rhs), + t_values_rhs), + framework::dataset::make("DataType", { DataType::QASYMM8}))) +{ + // Validate output + if(arm_matrix_multiply_supported(CLKernelLibrary::get().get_device())) + { + validate(CLAccessor(_target), _reference); + } + else + { + ARM_COMPUTE_TEST_INFO("cl_arm_matrix_multiply not supported. TEST skipped"); + framework::ARM_COMPUTE_PRINT_INFO(); + } +} +FIXTURE_DATA_TEST_CASE(OutputStageSigned, CLGEMMLowpMatrixMultiplyReshapedOnlyRHSMMULOutputStageFixtureSigned, framework::DatasetMode::ALL, + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + m_values, + n_values), + k_values), + b_values), + m0), + n0), + k0), + h0), + i_values_rhs), + t_values_rhs), + broadcast_bias), + framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED}))) +{ + // Validate output + if(arm_matrix_multiply_supported(CLKernelLibrary::get().get_device())) + { + validate(CLAccessor(_target), _reference); + } + else + { + ARM_COMPUTE_TEST_INFO("cl_arm_matrix_multiply not supported. TEST skipped"); + framework::ARM_COMPUTE_PRINT_INFO(); + } +} +FIXTURE_DATA_TEST_CASE(OutputStageUnsigned, CLGEMMLowpMatrixMultiplyReshapedOnlyRHSMMULOutputStageFixtureUnsigned, framework::DatasetMode::ALL, + combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( + m_values, + n_values), + k_values), + b_values), + m0), + n0), + k0), + h0), + i_values_rhs), + t_values_rhs), + broadcast_bias), + framework::dataset::make("DataType", { DataType::QASYMM8}))) +{ + // Validate output + if(arm_matrix_multiply_supported(CLKernelLibrary::get().get_device())) + { + validate(CLAccessor(_target), _reference); + } + else + { + ARM_COMPUTE_TEST_INFO("cl_arm_matrix_multiply not supported. TEST skipped"); + framework::ARM_COMPUTE_PRINT_INFO(); + } +} +TEST_SUITE_END() // GEMMLowpMatrixMultiplyReshapedOnlyRhsMMUL +TEST_SUITE_END() // CL +} // namespace validation +} // namespace test +} // namespace arm_compute \ No newline at end of file -- cgit v1.2.1