From 26c9d1a787bccbe0b6c6749b80e2f5030395bda6 Mon Sep 17 00:00:00 2001 From: Adnan AlSinan Date: Wed, 7 Sep 2022 13:54:53 +0100 Subject: Add test for NEGEMM to test a batched matrix multiplication with variable input tensors - Add a test for CPU to batched matrix multiplication with variable input tensors - Disable assembly kernel when using _reshape_b_only_on_first_run flag Resolves COMPMID-5501 Signed-off-by: Adnan AlSinan Change-Id: If96b182584617806a9dfe597dbfaf05241b123c2 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8234 Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- tests/validation/NEON/GEMM.cpp | 24 ++++++++++++++---------- tests/validation/fixtures/GEMMFixture.h | 5 ++--- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'tests/validation') diff --git a/tests/validation/NEON/GEMM.cpp b/tests/validation/NEON/GEMM.cpp index 5f6e75b705..0e07371281 100644 --- a/tests/validation/NEON/GEMM.cpp +++ b/tests/validation/NEON/GEMM.cpp @@ -319,7 +319,7 @@ template using NEGEMMFixture = GEMMValidationFixture; template -using NEGEMMFixtureDisabledC = GEMMValidationFixture; +using NEBatchedMatMulFixture = GEMMValidationFixture; TEST_SUITE(Float) DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(framework::dataset::make("In0", { TensorShape(21U, 13U), @@ -379,10 +379,12 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture, framework::DatasetMode::N // Validate output validate(Accessor(_target), _reference, tolerance_f); } -TEST_SUITE(DisabledC) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixtureDisabledC, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("ReshapeWeights", { true, false })), +TEST_SUITE(BATCHED_MATMUL) + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEBatchedMatMulFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallBatchedMatMulDataset(), + framework::dataset::make("ReshapeWeights", { false })), framework::dataset::make("DataType", DataType::F32))) { // Validate output @@ -390,16 +392,18 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixtureDisabledC, framework::Datas } TEST_SUITE_END() -TEST_SUITE(BatchedGEMMDisabledC) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixtureDisabledC, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallBatchedGEMMDataset(), - framework::dataset::make("ReshapeWeights", { true, false })), - - framework::dataset::make("DataType", DataType::F32))) +#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEBatchedMatMulFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallBatchedMatMulDataset(), + framework::dataset::make("ReshapeWeights", { false })), + framework::dataset::make("DataType", DataType::F16))) { // Validate output - validate(Accessor(_target), _reference, tolerance_f); + validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16); } TEST_SUITE_END() +#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ +TEST_SUITE_END() TEST_SUITE_END() TEST_SUITE_END() diff --git a/tests/validation/fixtures/GEMMFixture.h b/tests/validation/fixtures/GEMMFixture.h index 0682337c82..5dc2711753 100644 --- a/tests/validation/fixtures/GEMMFixture.h +++ b/tests/validation/fixtures/GEMMFixture.h @@ -152,7 +152,6 @@ protected: DataType data_type) { TensorShape shape_a_to_use = shape_a; - if(reinterpret_input_as_3d) { // Collapse the second and third dimension if the input is 3D @@ -213,13 +212,13 @@ protected: reference::gemm((pretranspose_a) ? a_transposed : a, (pretranspose_b) ? b_transposed : b, c, alpha, disable_c ? 0.f : beta); fill((pretranspose_a) ? a_transposed : a, 3); fill((pretranspose_b) ? b_transposed : b, 4); - fill(c , 5); + fill(c, 5); } // Setting beta to 0 will effectively disable C for the // computation of the reference: alpha * A * B + 0 * C // Use transposed tensors if boolean enabled else use original tensors - auto r = reference::gemm((pretranspose_a) ? a_transposed : a, (pretranspose_b) ? b_transposed : b, c, alpha, disable_c ? 0.f : beta); + auto r = reference::gemm((pretranspose_a) ? a_transposed : a, (pretranspose_b) ? b_transposed : b, c, alpha, disable_c ? 0.f : beta); return r; } -- cgit v1.2.1