diff --git a/test/tests/matmul_clamp_f32_f32_f32p_test.cpp b/test/tests/matmul_clamp_f32_f32_f32p_test.cpp index 65194ceea04a7906c9a28856fc7e526eee38da94..eae21b9b14cf9cf03d26cebe9fc01ce2166bbe34 100644 --- a/test/tests/matmul_clamp_f32_f32_f32p_test.cpp +++ b/test/tests/matmul_clamp_f32_f32_f32p_test.cpp @@ -130,8 +130,8 @@ TEST_P(MatMulTest_f32_f32_f32p, EndToEnd) // NOLINT(google-readability-avoid-un // Compare the output of the micro-kernels against the output of the reference implementation. for (size_t y = 0; y < m; ++y) { for (size_t x = 0; x < n; ++x) { - const auto imp_value = read_array(imp_dst.data(), (y * n) + x); - const auto ref_value = read_array(ref_dst.data(), (y * n) + x); + const auto imp_value = read_array(imp_dst.data(), y * n + x); + const auto ref_value = read_array(ref_dst.data(), y * n + x); const auto rel_error = ref_value != 0 ? std::abs((imp_value - ref_value) / ref_value) : std::abs(imp_value); if (rel_error > 0.0001F) { @@ -153,14 +153,13 @@ INSTANTIATE_TEST_SUITE_P( MatMulShape{1, 800, 64}, // MatMulShape{1, 512, 130} // )), - [](const testing::TestParamInfo& info) { - const uint8_t variant_idx = std::get<0>(info.param); - const MatMulShape matmul_shape = std::get<1>(info.param); + [](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); std::stringstream sstream; - sstream << ukernel_variants[variant_idx].name << "_m_" << matmul_shape.m << "_n_" << matmul_shape.n << "_k_" - << matmul_shape.k; - + sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k; return sstream.str(); }); diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp index c24361f544710cb967ac05e3f302901aa6fca68d..1fb1095ffabb58ff497213863edef2e93e40221c 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include #include #include "kai/kai_common.h" @@ -25,7 +28,6 @@ #include "kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4c32p_qsu4c32s1s0.h" #include "test/common/bfloat16.hpp" #include "test/common/cpu_info.hpp" -#include "test/common/data_type.hpp" #include "test/common/int4.hpp" #include "test/common/memory.hpp" #include "test/common/round.hpp" @@ -131,8 +133,8 @@ TEST_P(MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p, EndToEnd_RHS_nxk) { // Compares the output of the micro-kernels against the output of the reference implementation. for (size_t y = 0; y < M; ++y) { for (size_t x = 0; x < N; ++x) { - const auto imp_value = read_array(imp_dst.data(), (y * N) + x); - const auto ref_value = read_array(ref_dst.data(), (y * N) + x); + const auto imp_value = read_array(imp_dst.data(), y * N + x); + const auto ref_value = read_array(ref_dst.data(), y * N + x); const auto rel_error = ref_value != 0 ? std::abs((imp_value - ref_value) / ref_value) : std::abs(imp_value); if (rel_error > 0.0001F) { @@ -226,8 +228,8 @@ TEST_P(MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p, EndToEnd_RHS_kxn) { // Compares the output of the micro-kernels against the output of the reference implementation. for (size_t y = 0; y < M; ++y) { for (size_t x = 0; x < N; ++x) { - const auto imp_value = read_array(imp_dst.data(), (y * N) + x); - const auto ref_value = read_array(ref_dst.data(), (y * N) + x); + const auto imp_value = read_array(imp_dst.data(), y * N + x); + const auto ref_value = read_array(ref_dst.data(), y * N + x); const auto rel_error = ref_value != 0 ? std::abs((imp_value - ref_value) / ref_value) : std::abs(imp_value); if (rel_error > 0.0001F) { @@ -241,7 +243,21 @@ INSTANTIATE_TEST_SUITE_P( MatMul, MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p, testing::Combine( testing::Range(0, variants_kai_matmul_clamp_f32_qai8dxp_qsi4c32p.size()), - testing::Values(MatMulShape{16, 32, 64}, MatMulShape{8, 32, 64}, MatMulShape{17, 25, 33}), - testing::Values(32, 64))); + testing::Values( + MatMulShape{16, 32, 64}, // + MatMulShape{8, 32, 64}, // + MatMulShape{17, 25, 33}, // + MatMulShape{15, 31, 45}), + testing::Values(32, 64)), + [](const auto& info) { + const auto variant_idx = std::get<0>(info.param); + const std::string name{variants_kai_matmul_clamp_f32_qai8dxp_qsi4c32p.at(variant_idx).name}; + const auto shape = std::get(info.param); + const auto bl = std::get<2>(info.param); + + std::stringstream sstream; + sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k << "__BL_" << bl; + return sstream.str(); + }); } // namespace kai::test diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp index ecc7f70318885a586fc77ed00ab0b99b03a21a59..c8b5b8f1fedc1f475fd4191b213397c89777f360 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1x8_qsi4cxp4x8_1x4x32_neon_dotprod.h" @@ -54,7 +56,7 @@ static const std::array(0, variants_kai_matmul_clamp_f32_qai8dxp_qsi4cxp.size()), - testing::Values(MatMulShape{16, 32, 64}, MatMulShape{16, 32, 36}, MatMulShape{15, 35, 65}))); + testing::Values( + MatMulShape{16, 32, 64}, // + MatMulShape{16, 32, 36}, // + MatMulShape{15, 35, 65}, // + MatMulShape{8, 32, 64}, // + MatMulShape{15, 31, 45})), + [](const auto& info) { + const auto variant_idx = std::get<0>(info.param); + const std::string name{variants_kai_matmul_clamp_f32_qai8dxp_qsi4cxp.at(variant_idx).name}; + const auto shape = std::get(info.param); + + std::stringstream sstream; + sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k; + return sstream.str(); + }); } // 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 00c237cc93b00c211e4247b2f69cf16b26ddae35..b02e2d60210de4f6e1d643b0ede33c9475d429d3 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi8cxp/kai_matmul_clamp_f32_qai8dxp1x4_qsi8cxp4x4_1x4_neon_dotprod.h" @@ -215,6 +217,15 @@ INSTANTIATE_TEST_SUITE_P( MatMul, MatMulTest_f32_qai8dxp_qsi8cxp, testing::Combine( testing::Range(0, variants_kai_matmul_clamp_f32_qai8dxp_qsi8cxp.size()), - testing::Values(MatMulShape{17, 33, 67}, MatMulShape{19, 35, 63}, MatMulShape{1, 27, 31}))); + testing::Values(MatMulShape{17, 33, 67}, MatMulShape{19, 35, 63}, MatMulShape{1, 27, 31})), + [](const auto& info) { + const auto variant_idx = std::get<0>(info.param); + const std::string name{variants_kai_matmul_clamp_f32_qai8dxp_qsi8cxp.at(variant_idx).name}; + const auto shape = std::get(info.param); + + std::stringstream sstream; + sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k; + return sstream.str(); + }); } // 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 acb28f14afe47f6faf340c48be08073eb782bd51..cc0bba80339294aeb6cc9487c29b68c4a6fbffdc 100644 --- a/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp +++ b/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include "test/common/float16.hpp" #include "test/common/int4.hpp" #include "test/common/memory.hpp" +#include "test/common/round.hpp" #include "test/common/test_suite.hpp" #include "test/reference/cast.hpp" #include "test/reference/fill.hpp" @@ -149,8 +151,8 @@ TEST_P(MatMulTest_f32_qsi8d32p_qsi4c32p, EndToEnd) { // Compares the output of the micro-kernels against the output of the reference implementation. for (size_t y = 0; y < M; ++y) { for (size_t x = 0; x < N; ++x) { - const auto imp_value = read_array(imp_dst.data(), (y * N) + x); - const auto ref_value = read_array(ref_dst.data(), (y * N) + x); + const auto imp_value = read_array(imp_dst.data(), y * N + x); + const auto ref_value = read_array(ref_dst.data(), y * N + x); const auto rel_error = ref_value != 0 ? std::abs((imp_value - ref_value) / ref_value) : std::abs(imp_value); if (rel_error > 0.0001F) { @@ -172,11 +174,13 @@ INSTANTIATE_TEST_SUITE_P( MatMulShape{15, 32, 32}, // MatMulShape{77, 99, 64})), [](const auto& info) { - const std::string name{ - variants_kai_matmul_clamp_f32_qsi8d32p_qsi4c32p.at(std::get(info.param)).ukernel.name}; + const auto variant_idx = std::get<0>(info.param); + const std::string name{variants_kai_matmul_clamp_f32_qsi8d32p_qsi4c32p.at(variant_idx).ukernel.name}; const auto shape = std::get(info.param); - return name + "__M_" + std::to_string(shape.m) + "__N_" + std::to_string(shape.n) + "__K_" + - std::to_string(shape.k); + + std::stringstream sstream; + sstream << name << "__M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k; + return sstream.str(); }); } // 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 e8011f4f3480a4bb7f08a4aeab3cb6f1124e3b43..f84db17f885ac4564f5007065c12c93eb0a72d13 100644 --- a/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include "kai/kai_common.h" @@ -20,6 +22,7 @@ #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" @@ -75,12 +78,6 @@ struct GemmVariant { size_t dst_stride_col, const kai_matmul_requantize32_params* params); }; -struct GemmShape { - size_t m; - size_t n; - size_t k; -}; - const std::array gemm_variants = { GemmVariant{ .acc_height = 2 * get_sme_vector_length(), @@ -122,16 +119,16 @@ const std::array gemm_variants = { constexpr float output_clamp_rate = 0.1F; // Clamping 10% the range of the output. const std::array gemm_shapes = { - GemmShape{1, 1, 1}, // - GemmShape{ + MatMulShape{1, 1, 1}, // + MatMulShape{ 2 * get_sme_vector_length(), 2 * get_sme_vector_length(), sizeof(int32_t) / sizeof(int8_t)}, // - GemmShape{20, 30, 40}, // - GemmShape{1, 49, 21}, // - GemmShape{23, 1, 43}, // - GemmShape{32, 14, 1}, // - GemmShape{123, 85, 45}, // - GemmShape{130, 130, 6}, + MatMulShape{20, 30, 40}, // + MatMulShape{1, 49, 21}, // + MatMulShape{23, 1, 43}, // + MatMulShape{32, 14, 1}, // + MatMulShape{123, 85, 45}, // + MatMulShape{130, 130, 6}, }; const std::array output_portions = { @@ -140,7 +137,7 @@ const std::array output_portions = { MatrixPortion(0.75, 0.75, 1, 1), // Bottom-right corner. }; -void run_test(const GemmShape& shape, const GemmVariant& variant, const MatrixPortion& output_portion) { +void run_test(const MatMulShape& shape, const GemmVariant& variant, const MatrixPortion& output_portion) { const uint64_t seed = 0; if (!variant.fn_is_supported()) { @@ -361,7 +358,7 @@ void run_test(const GemmShape& shape, const GemmVariant& variant, const MatrixPo } } -using ThisTest = testing::TestWithParam>; +using ThisTest = testing::TestWithParam>; TEST_P(ThisTest, EndToEnd) { const auto& [variant, shape, output_portion] = GetParam(); @@ -374,6 +371,18 @@ TEST_P(ThisTest, EndToEnd) { INSTANTIATE_TEST_SUITE_P( matmul_clamp_qai8_qai8p_qsi8cxp, ThisTest, testing::Combine( - testing::ValuesIn(gemm_variants), testing::ValuesIn(gemm_shapes), testing::ValuesIn(output_portions))); + testing::ValuesIn(gemm_variants), testing::ValuesIn(gemm_shapes), testing::ValuesIn(output_portions)), + [](const auto& info) { + const auto shape = std::get(info.param); + const auto portion = std::get(info.param); + + std::stringstream sstream; + sstream << "__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(); + }); } // namespace kai::test