diff --git a/test/common/cpu_info.cpp b/test/common/cpu_info.cpp index 99770295e31174403b070aeb5ba8bc858bfa6abf..172a9937eeb8041acdf14b1de204b2611981fe63 100644 --- a/test/common/cpu_info.cpp +++ b/test/common/cpu_info.cpp @@ -243,10 +243,18 @@ bool cpu_has_dotprod() { return CpuInfo::current().has_dotprod; } +bool cpu_has_dotprod_and_fp16() { + return cpu_has_dotprod() && cpu_has_fp16(); +} + bool cpu_has_i8mm() { return CpuInfo::current().has_i8mm; } +bool cpu_has_i8mm_and_fp16() { + return cpu_has_i8mm() && cpu_has_fp16(); +} + bool cpu_has_fp16() { return CpuInfo::current().has_fp16; } diff --git a/test/common/cpu_info.hpp b/test/common/cpu_info.hpp index 298a358a7bb2cab80b2f9082791178d36b8de358..e9fe86012c844fe3e872ea6f9ea2c45e4f58582c 100644 --- a/test/common/cpu_info.hpp +++ b/test/common/cpu_info.hpp @@ -1,5 +1,5 @@ // -// SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates +// SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its affiliates // // SPDX-License-Identifier: Apache-2.0 // @@ -14,9 +14,15 @@ bool cpu_has_advsimd(); /// Returns a value indicating whether the current CPU supports FEAT_DotProd. bool cpu_has_dotprod(); +/// Returns a value indicating whether the current CPU supports FEAT_DotProd and FEAT_FP16. +bool cpu_has_dotprod_and_fp16(); + /// Returns a value indicating whether the current CPU supports FEAT_I8MM. bool cpu_has_i8mm(); +/// Returns a value indicating whether the current CPU supports FEAT_I8MM and FEAT_FP16. +bool cpu_has_i8mm_and_fp16(); + /// Returns a value indicating whether the current CPU supports FEAT_FP16. bool cpu_has_fp16(); diff --git a/test/common/int4.cpp b/test/common/int4.cpp index 2dbcd07cdd114f1f47370f9e5c3af7e62a028c29..ff64de2045dcf356fcd2d4b69ee198448dddf700 100644 --- a/test/common/int4.cpp +++ b/test/common/int4.cpp @@ -12,7 +12,6 @@ #include "kai/kai_common.h" #include "test/common/memory.hpp" -#include "test/common/round.hpp" namespace kai::test { diff --git a/test/common/matmul_test_common.cpp b/test/common/matmul_test_common.cpp index 91853deaf136c83898a54e231ef26d0c5da50d6a..371f792035f635bb2f22c78db08bd531d9d72d75 100644 --- a/test/common/matmul_test_common.cpp +++ b/test/common/matmul_test_common.cpp @@ -6,8 +6,7 @@ #include "matmul_test_common.hpp" -#include -#include +#include namespace kai::test { @@ -34,4 +33,20 @@ void PrintTo(const MatrixPortion& portion, std::ostream* os) { << "__PortionHeight_" << static_cast(portion.height() * 1000) // << "__PortionWidth_" << static_cast(portion.width() * 1000); } + +std::string test_description( + const std::string_view& name, const MatMulShape& shape, const MatrixPortion& portion, bool bias) { + std::ostringstream os; + + os << "Method_" << name << "__"; + PrintTo(shape, &os); + os << "__"; + PrintTo(portion, &os); + if (bias) { + os << "__Bias"; + } + + return os.str(); +} + } // namespace kai::test diff --git a/test/common/matmul_test_common.hpp b/test/common/matmul_test_common.hpp index 030f17875a91af041733516fd756e4b876c210a6..9b576d8eab739bd97eb59b5250392b400227d51e 100644 --- a/test/common/matmul_test_common.hpp +++ b/test/common/matmul_test_common.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -486,9 +487,16 @@ struct MatMulMethod { /// Matrix multiplication test information. using MatMulTestParams = std::tuple; +using MatMulTestPortionedParams = std::tuple; +using MatMulTestPortionedParamsWithBias = std::tuple; /// Prints the test information. void PrintTo(const MatMulTestParams& param, std::ostream* os); void PrintTo(const MatMulShape& shape, std::ostream* os); void PrintTo(const MatrixPortion& portion, std::ostream* os); + +/// Generate test information. +std::string test_description( + const std::string_view& name, const MatMulShape& shape, const MatrixPortion& portion, bool bias); + } // namespace kai::test diff --git a/test/common/test_suite.hpp b/test/common/test_suite.hpp index 3c71c48cf150e8a1bf959666125ae1f8b7ce5878..5432e9acb8975b4af7371000b5149f19f0a0637c 100644 --- a/test/common/test_suite.hpp +++ b/test/common/test_suite.hpp @@ -6,14 +6,9 @@ #pragma once -#include - #include #include #include -#include - -#include "matrix_portion.hpp" // clang-format off #define UKERNEL_MATMUL_VARIANT(name) \ @@ -71,35 +66,5 @@ struct UkernelPackVariant { UkernelVariant ukernel; P pack_interface; }; -/// Matrix multiplication shape. -struct MatMulShape { - size_t m{}; ///< LHS height. - size_t n{}; ///< RHS width. - size_t k{}; ///< LHS width and RHS height. - - struct Hash { - size_t operator()(const kai::test::MatMulShape& shape) const { - return // - (std::hash{}(shape.m) << 0) ^ // - (std::hash{}(shape.n) << 1) ^ // - (std::hash{}(shape.k) << 2); - } - }; - -private: - friend bool operator==(const MatMulShape& lhs, const MatMulShape& rhs) { - return // - lhs.m == rhs.m && // - lhs.n == rhs.n && // - lhs.k == rhs.k; - } -}; - -/// Matrix multiplication test information. -using MatMulTestParams = std::tuple; -using MatMulTestPortionedParams = std::tuple; -using MatMulTestPortionedParamsWithBias = std::tuple; - -class UkernelVariantTest : public ::testing::TestWithParam {}; } // namespace kai::test diff --git a/test/tests/matmul_clamp_f16_bf16p_bf16p_test.cpp b/test/tests/matmul_clamp_f16_bf16p_bf16p_test.cpp index 09a4ee1e9d7898385abfea26c6cee1ce7751cfd9..2363ace778c6df4bc0adb58be37f2923ab32b818 100644 --- a/test/tests/matmul_clamp_f16_bf16p_bf16p_test.cpp +++ b/test/tests/matmul_clamp_f16_bf16p_bf16p_test.cpp @@ -4,14 +4,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include #include #include #include -#include #include #include #include diff --git a/test/tests/matmul_clamp_f16_qai8dxp_qsi4cxp_test.cpp b/test/tests/matmul_clamp_f16_qai8dxp_qsi4cxp_test.cpp index 1b8bc29ad65583f8bee665d131974a367dadf9ba..de55cecf184655bc49e116c44cd262dee24282b1 100644 --- a/test/tests/matmul_clamp_f16_qai8dxp_qsi4cxp_test.cpp +++ b/test/tests/matmul_clamp_f16_qai8dxp_qsi4cxp_test.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -28,6 +27,7 @@ #include "test/common/data_format.hpp" #include "test/common/float16.hpp" #include "test/common/int4.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" @@ -42,9 +42,6 @@ namespace kai::test { -static auto cpu_has_dotprod_and_fp16 = []() { return cpu_has_dotprod() && cpu_has_fp16(); }; -static auto cpu_has_i8mm_and_fp16 = []() { return cpu_has_i8mm() && cpu_has_fp16(); }; - static const std::array, 4> variants_kai_matmul_clamp_f16_qai8dxp_qsi4cxp = {{ {UKERNEL_MATMUL_VARIANT(clamp_f16_qai8dxp1x4_qsi4cxp4x4_1x4_neon_dotprod), @@ -225,14 +222,7 @@ INSTANTIATE_TEST_SUITE_P( const auto portion = std::get<2>(info.param); const auto has_bias = std::get<3>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000) // - << (has_bias ? "__Bias" : ""); - return sstream.str(); + return test_description(name, shape, portion, has_bias); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f16_qai8dxp_qsi8cxp_test.cpp b/test/tests/matmul_clamp_f16_qai8dxp_qsi8cxp_test.cpp index 043c217e132dd00336c3d2df2fefa8ec5f2ebc42..0500d8f60f4a9a0b933986c2f14b671aa9413dd5 100644 --- a/test/tests/matmul_clamp_f16_qai8dxp_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_f16_qai8dxp_qsi8cxp_test.cpp @@ -28,6 +28,7 @@ #include "test/common/cpu_info.hpp" #include "test/common/data_format.hpp" #include "test/common/float16.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" @@ -42,9 +43,6 @@ namespace kai::test { -static auto cpu_has_dotprod_and_fp16 = []() { return cpu_has_dotprod() && cpu_has_fp16(); }; -static auto cpu_has_i8mm_and_fp16 = []() { return cpu_has_i8mm() && cpu_has_fp16(); }; - static const std::array, 4> variants_kai_matmul_clamp_f16_qai8dxp_qsi8cxp = {{ {UKERNEL_MATMUL_VARIANT(clamp_f16_qai8dxp1x4_qsi8cxp4x4_1x4_neon_dotprod), @@ -219,14 +217,7 @@ INSTANTIATE_TEST_SUITE_P( const auto portion = std::get<2>(info.param); const auto has_bias = std::get<3>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000) // - << (has_bias ? "__Bias" : ""); - return sstream.str(); + return test_description(name, shape, portion, has_bias); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f16_qsi8d32p_qai4c32p_test.cpp b/test/tests/matmul_clamp_f16_qsi8d32p_qai4c32p_test.cpp index 376f78d05d0b030c8ccda776e9021b45679dc43a..de6c3a9061584dbbb0720adce93f36f0ab72540a 100644 --- a/test/tests/matmul_clamp_f16_qsi8d32p_qai4c32p_test.cpp +++ b/test/tests/matmul_clamp_f16_qsi8d32p_qai4c32p_test.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -26,7 +25,7 @@ #include "test/common/data_format.hpp" #include "test/common/float16.hpp" #include "test/common/int4.hpp" -#include "test/common/matrix_portion.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" #include "test/common/test_suite.hpp" @@ -39,9 +38,6 @@ namespace kai::test { -static auto cpu_has_dotprod_and_fp16 = []() { return cpu_has_dotprod() && cpu_has_fp16(); }; -static auto cpu_has_i8mm_and_fp16 = []() { return cpu_has_i8mm() && cpu_has_fp16(); }; - static const std::array, 2> variants_kai_matmul_clamp_f16_qsi8d32p_qai4c32p = { {{UKERNEL_MATMUL_VARIANT(clamp_f16_qsi8d32p1x8_qai4c32p4x8_1x4_neon_dotprod), @@ -231,14 +227,7 @@ INSTANTIATE_TEST_SUITE_P( const auto portion = std::get<2>(info.param); const auto has_bias = std::get<3>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000) // - << (has_bias ? "__Bias" : ""); - return sstream.str(); + return test_description(name, shape, portion, has_bias); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f32_bf16p_bf16p_test.cpp b/test/tests/matmul_clamp_f32_bf16p_bf16p_test.cpp index be38ca16cedb5a80ff0e83ba98fc6d4fa0e661f6..2b4ca71382a9ecbc2eb6e56cd33061caac242825 100644 --- a/test/tests/matmul_clamp_f32_bf16p_bf16p_test.cpp +++ b/test/tests/matmul_clamp_f32_bf16p_bf16p_test.cpp @@ -4,7 +4,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include diff --git a/test/tests/matmul_clamp_f32_f32_f32p_test.cpp b/test/tests/matmul_clamp_f32_f32_f32p_test.cpp index 9842e9fb60f6f42a3f6d3fd28e6dd2ee1351e81f..c80e42addf28b638042dff0939bee4c185c62e38 100644 --- a/test/tests/matmul_clamp_f32_f32_f32p_test.cpp +++ b/test/tests/matmul_clamp_f32_f32_f32p_test.cpp @@ -26,6 +26,8 @@ #include "test/common/buffer.hpp" #include "test/common/cpu_info.hpp" #include "test/common/data_type.hpp" +#include "test/common/matmul_test_common.hpp" +#include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/test_suite.hpp" #include "test/reference/clamp.hpp" @@ -98,11 +100,12 @@ Buffer fill_random(size_t length, uint32_t seed) { } } // namespace -class MatMulTest_f32_f32_f32p : public ::testing::TestWithParam {}; +class MatMulTest_f32_f32_f32p : public ::testing::TestWithParam {}; TEST_P(MatMulTest_f32_f32_f32p, EndToEnd) // NOLINT(google-readability-avoid-underscore-in-googletest-name) { - const auto& [variant_idx, matmul_shape] = GetParam(); + // No portion testing done at the moment, so skip the parameter + const auto& [variant_idx, matmul_shape, _] = GetParam(); const auto& ukernel_variant = ukernel_variants.at(variant_idx); if (ukernel_variant.fn_is_supported && !ukernel_variant.fn_is_supported()) { @@ -195,15 +198,17 @@ INSTANTIATE_TEST_SUITE_P( MatMulShape{1, 7, 74}, // MatMulShape{1, 800, 64}, // MatMulShape{1, 512, 130} // + ), + testing::Values( // + MatrixPortion(0.0, 0.0, 1.0, 1.0) // )), [](const auto& info) { const auto variant_idx = std::get<0>(info.param); const std::string name{ukernel_variants.at(variant_idx).name}; const auto shape = std::get(info.param); + const auto portion = std::get<2>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k; - return sstream.str(); + return test_description(name, shape, portion, true); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp index 9a0d24691b3acf47c3dad09a1584ae63740d0235..a8d3fb8f6c4a388f2be9cf67a5e146561c5939d8 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp @@ -38,6 +38,7 @@ #include "test/common/bfloat16.hpp" #include "test/common/cpu_info.hpp" #include "test/common/int4.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" @@ -77,9 +78,7 @@ static const std::array; -class UkernelVariantTest_withBL : public ::testing::TestWithParam {}; - -class MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p : public UkernelVariantTest_withBL {}; +class MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p : public ::testing::TestWithParam {}; TEST_P(MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p, Offset_RHS) { const auto& [variant_index, matmul_shape, bl, portion] = GetParam(); @@ -449,12 +448,12 @@ INSTANTIATE_TEST_SUITE_P( const auto bl = std::get<2>(info.param); const auto portion = std::get<3>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k << "__BL_" << bl - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000); + std::ostringstream sstream; + sstream << name << "__"; + PrintTo(shape, &sstream); + sstream << "__BL_" << bl << "__"; + PrintTo(portion, &sstream); + return sstream.str(); }); diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp index 9b02d50b8660a50ded1d9a64793e1f2d7754d0fd..5a770fbe59868131ec1365f84c16e33409d6ef91 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp @@ -35,6 +35,7 @@ #include "kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon.h" #include "test/common/cpu_info.hpp" #include "test/common/int4.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" @@ -48,9 +49,7 @@ namespace kai::test { /// Matrix multiplication test information. -using MatMulTestParams_with_portion = std::tuple; -class UkernelVariantTest_with_portions : public ::testing::TestWithParam {}; enum class RhsPackType { NxK, KxN }; using ukernel_rhs_pack_function = std::function; @@ -203,7 +202,7 @@ static const std::array {}; TEST_P(MatMulTest_f32_qai8dxp_qsi4cxp, Offset_RHS) { const auto& [variant_index, matmul_shape, portion] = GetParam(); @@ -814,13 +813,7 @@ INSTANTIATE_TEST_SUITE_P( const auto shape = std::get(info.param); const auto portion = std::get<2>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k << "__PortionStartRow_" - << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000); - return sstream.str(); + return test_description(name, shape, portion, true); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp index f55213de2c13428772eff462d339c90cefb806f5..f22671a152ada1ac6307bbfac77498eeef915c6e 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp @@ -25,6 +25,7 @@ #include "kai/ukernels/matmul/pack/kai_rhs_pack_kxn_qsi8cxp_qsi8cx_neon.h" #include "kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi8cxp_qsi8cx_neon.h" #include "test/common/cpu_info.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/test_suite.hpp" @@ -354,13 +355,7 @@ INSTANTIATE_TEST_SUITE_P( const auto shape = std::get(info.param); const auto portion = std::get(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000); - return sstream.str(); + return test_description(name, shape, portion, true); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f32_qsi8d32p_qai4c32p_test.cpp b/test/tests/matmul_clamp_f32_qsi8d32p_qai4c32p_test.cpp index 457c4d706879d640ad399207570d06ee976c134a..141841511a39799644b2f3baf8e288d4557c2fbe 100644 --- a/test/tests/matmul_clamp_f32_qsi8d32p_qai4c32p_test.cpp +++ b/test/tests/matmul_clamp_f32_qsi8d32p_qai4c32p_test.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include "kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qai4c32p_qau4c32s0s1_f32_f32_f32_neon.h" #include "test/common/cpu_info.hpp" #include "test/common/int4.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" @@ -226,14 +226,7 @@ INSTANTIATE_TEST_SUITE_P( const auto portion = std::get<2>(info.param); const auto has_bias = std::get<3>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000) // - << (has_bias ? "__Bias" : ""); - return sstream.str(); + return test_description(name, shape, portion, has_bias); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp b/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp index 153decb53e1c839e68eafbadf67c60dcf9c387d5..a93a0b65844b75a1b0be35d4d43fe97baed73514 100644 --- a/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp +++ b/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp @@ -31,6 +31,7 @@ #include "test/common/cpu_info.hpp" #include "test/common/float16.hpp" #include "test/common/int4.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" @@ -92,10 +93,7 @@ static const std::array< clamp_f32_qsi8d32p1x4_qsi4c32p4vlx4_1x4vl_sme2_sdot, cpu_has_sme2, lhs_quant_pack_qsi8d32p_f32_neon, rhs_pack_nxk_qsi4c32ps1s0scalef16_qsu4c32s16s0_neon)}}; -using MatMulTestParams_withPortion = std::tuple; - -class UkernelVariantTest_withPortion : public ::testing::TestWithParam {}; -class MatMulTest_f32_qsi8d32p_qsi4c32p : public UkernelVariantTest_withPortion {}; +class MatMulTest_f32_qsi8d32p_qsi4c32p : public ::testing::TestWithParam {}; TEST_P(MatMulTest_f32_qsi8d32p_qsi4c32p, Offset_RHS) { const auto& [variant_index, matmul_shape, portion] = GetParam(); @@ -295,13 +293,7 @@ INSTANTIATE_TEST_SUITE_P( const auto shape = std::get(info.param); const auto portion = std::get<2>(info.param); - std::stringstream sstream; - sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000); - return sstream.str(); + return test_description(name, shape, portion, true); }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp b/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp index 66191ca20a2556abb99e3d18022ef3020e3bd2f6..e3c1cb91da9c7721806749f7eb62cd1e5e921172 100644 --- a/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp @@ -31,11 +31,11 @@ #include "kai/ukernels/matmul/pack/kai_rhs_imatmul_pack_kxn_qsi8cxp2vlx4sb_qs8cx_f32_i32_sme.h" #include "kai/ukernels/matmul/pack/kai_rhs_pack_kxn_qsi8cxp2vlx4sb_qs8cx_f32_i32_sme.h" #include "test/common/cpu_info.hpp" +#include "test/common/matmul_test_common.hpp" #include "test/common/matrix_portion.hpp" #include "test/common/memory.hpp" #include "test/common/rect.hpp" #include "test/common/sme.hpp" -#include "test/common/test_suite.hpp" #include "test/reference/binary_elementwise.hpp" #include "test/reference/clamp.hpp" #include "test/reference/fill.hpp" @@ -345,17 +345,6 @@ const std::array& get_gemv_variants() { constexpr uint32_t seed = 0; ///< Random seed used for tests -/// Value range -template -struct Range { - T min; - T max; - - [[nodiscard]] T range() const { - return max - min; - } -}; - /// Quantization parameters struct Quant { float scale; @@ -726,14 +715,11 @@ static std::string test_description( const MatMulVariant& variant, // const MatMulShape& shape, // const MatrixPortion& portion, float clamp_ratio) { - std::stringstream sstream; - sstream << "Method_" << variant.name << "__M_" // - << shape.m << "__N_" << shape.n << "__K_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000) // + std::ostringstream sstream; + + sstream << test_description(variant.name, shape, portion, true) // << "__clamp_ratio_" << static_cast(clamp_ratio * 100); + return sstream.str(); }; @@ -741,15 +727,13 @@ static std::string test_description( const IndirectMatMulVariant& variant, // const MatMulShape& shape, // const MatrixPortion& portion, size_t k_chunk_len, float clamp_ratio) { - std::stringstream sstream; - sstream << "Method_" << variant.name << "__M_" // - << shape.m << "__N_" << shape.n << "__k_chunk_count_" << shape.k // - << "__PortionStartRow_" << static_cast(portion.start_row() * 1000) // - << "__PortionStartCol_" << static_cast(portion.start_col() * 1000) // - << "__PortionHeight_" << static_cast(portion.height() * 1000) // - << "__PortionWidth_" << static_cast(portion.width() * 1000) // - << "__k_chunk_len_" << k_chunk_len // - << "__clamp_ratio_" << static_cast(clamp_ratio * 100); + std::ostringstream sstream; + + sstream << "Method_" << variant.name << "__M_" << shape.m << "__N_" << shape.n << "__k_chunk_count_" << shape.k + << "__"; + PrintTo(portion, &sstream); + sstream << "__k_chunk_len_" << k_chunk_len << "__clamp_ratio_" << static_cast(clamp_ratio * 100); + return sstream.str(); }; diff --git a/test/tests/matmul_test.cpp b/test/tests/matmul_test.cpp index f22a593ec7a97d4899f341640da902a4cabd58c9..dbae97182ca4f328ec71a5a9d3df625126fcc3b0 100644 --- a/test/tests/matmul_test.cpp +++ b/test/tests/matmul_test.cpp @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include #include #include