From a77c6d774053672b7bf0261e1a7a229bb6be5f21 Mon Sep 17 00:00:00 2001 From: Ramy Elgammal Date: Thu, 8 Sep 2022 11:30:08 +0100 Subject: Add test for ClGemmLowpMatrixMultiplyCore to test a batched matrix multiplication with variable input tensors Resolves: COMPMID-5506 Signed-off-by: Ramy Elgammal Change-Id: I8345a3b7a83ef46f9ec7a77197cc65c933ec9ac6 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8239 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Benchmark: Arm Jenkins --- tests/validation/fixtures/GEMMLowpFixture.h | 37 ++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'tests/validation/fixtures/GEMMLowpFixture.h') diff --git a/tests/validation/fixtures/GEMMLowpFixture.h b/tests/validation/fixtures/GEMMLowpFixture.h index 6d073cd361..f1ec81aae6 100644 --- a/tests/validation/fixtures/GEMMLowpFixture.h +++ b/tests/validation/fixtures/GEMMLowpFixture.h @@ -26,8 +26,8 @@ #include "arm_compute/core/utils/quantization/AsymmHelpers.h" #include "tests/framework/Fixture.h" -#include "tests/validation/reference/GEMMLowp.h" #include "tests/validation/Validation.h" +#include "tests/validation/reference/GEMMLowp.h" namespace arm_compute { @@ -85,7 +85,7 @@ void fill(U &&tensor, int i) } } -template +template TensorType compute_gemmlowp_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_output, int32_t a_offset, int32_t b_offset, GEMMLowpOutputStageInfo output_stage = GEMMLowpOutputStageInfo(), DataType data_type_a = DataType::QASYMM8, DataType data_type_b = DataType::QASYMM8, QuantizationInfo b_qinfo = QuantizationInfo(), bool reshape_b_only_on_first_run = false) @@ -146,12 +146,25 @@ TensorType compute_gemmlowp_target(const TensorShape &shape_a, const TensorShape ARM_COMPUTE_ASSERT(!bias.info()->is_resizable()); fill(AccessorType(bias), 2); } + + // Run with variable inputs. + if(run_twice) + { + gemmlowp.run(); + fill(AccessorType(a), 3); // Fill tensors with new seed after run + fill(AccessorType(b), 4); + if(is_fused) + { + fill(AccessorType(bias), 5); + } + } + // Compute GEMM function gemmlowp.run(); return output; } -template +template SimpleTensor compute_gemmlowp_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_output, int32_t a_offset, int32_t b_offset, DataType data_type_a = DataType::QASYMM8, DataType data_type_b = DataType::QASYMM8, QuantizationInfo b_qinfo = QuantizationInfo()) { @@ -196,11 +209,19 @@ SimpleTensor compute_gemmlowp_reference(const TensorShape &shape_a, con transpose_matrix(b, b_transposed); } + // Run with variable inputs. + if(run_twice) + { + reference::gemmlowp_matrix_multiply_core((pretranspose_A ? a_transposed : a), (pretranspose_B ? b_transposed : b), shape_output, a_offset, b_offset); + fill((pretranspose_A) ? a_transposed : a, 3); + fill((pretranspose_B) ? b_transposed : b, 4); + } + return reference::gemmlowp_matrix_multiply_core((pretranspose_A ? a_transposed : a), (pretranspose_B ? b_transposed : b), shape_output, a_offset, b_offset); } } -template +template class GEMMLowpMatrixMultiplyCoreValidationFixture : public framework::Fixture { public: @@ -214,12 +235,12 @@ public: protected: TensorType compute_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_output, int32_t a_offset, int32_t b_offset) { - return compute_gemmlowp_target(shape_a, shape_b, shape_output, a_offset, b_offset); + return compute_gemmlowp_target(shape_a, shape_b, shape_output, a_offset, b_offset); } SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_output, int32_t a_offset, int32_t b_offset) { - return compute_gemmlowp_reference(shape_a, shape_b, shape_output, a_offset, b_offset); + return compute_gemmlowp_reference(shape_a, shape_b, shape_output, a_offset, b_offset); } TensorType _target{}; @@ -1395,7 +1416,7 @@ public: broadcast_bias ? 1 : m, broadcast_bias ? 1 : batch_size); - _target = compute_target(lhs_shape, rhs_shape, bias_shape, lhs_info, rhs_info, data_type, output_stage, a_offset, b_offset); + _target = compute_target(lhs_shape, rhs_shape, bias_shape, lhs_info, rhs_info, data_type, output_stage, a_offset, b_offset); if(gemm_validated == true) { _reference = compute_reference(lhs_shape, rhs_shape, bias_shape, data_type, output_stage, a_offset, b_offset); @@ -1584,7 +1605,7 @@ public: const TensorShape lhs_shape(k, m, batch_size); const TensorShape rhs_shape(n, k, batch_size); - _target = compute_target(lhs_shape, rhs_shape, lhs_info, rhs_info, data_type); + _target = compute_target(lhs_shape, rhs_shape, lhs_info, rhs_info, data_type); if(gemm_validated == true) { _reference = compute_reference(lhs_shape, rhs_shape, data_type); -- cgit v1.2.1