KleidiAI Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 94.6% 35 / 0 / 37
Functions: 83.3% 10 / 0 / 12
Branches: 59.1% 13 / 0 / 22

test/common/matmul_test_common.cpp
Line Branch Exec Source
1 //
2 // SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6
7 #include "matmul_test_common.hpp"
8
9 #include <sstream>
10
11 namespace kai::test {
12
13 std::ostream& operator<<(std::ostream& os, const MatMulShape& shape) {
14 return os << "[m=" << shape.m << ", n=" << shape.n << ", k=" << shape.k << "]";
15 }
16
17 46008 void PrintTo(const MatMulClampTestParams& param, std::ostream* os) {
18 276048 const auto& [method, shape, portion, bias_mode, clamp_keep_ratio] = param;
19
20 92016 *os << method.name << "__";
21 46008 PrintTo(shape, os);
22 46008 *os << "__";
23 46008 PrintTo(portion, os);
24 46008 PrintTo(bias_mode, os);
25 92016 *os << "__clamp_keep_ratio_" << static_cast<int>(clamp_keep_ratio * 100);
26 46008 }
27
28 770712 void PrintTo(const MatMulShape& shape, std::ostream* os) {
29 770712 *os << "M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k;
30 770712 }
31
32 46008 void PrintTo(const BiasMode& bias_mode, std::ostream* os) {
33 // Preserve legacy test names
34
2/2
✓ Branch 0 taken 40824 times.
✓ Branch 1 taken 5184 times.
46008 if (bias_mode == BiasMode::INTERNAL) {
35 5184 *os << "__NullBias";
36 5184 }
37 46008 }
38
39 770352 void PrintTo(const MatrixPortion& portion, std::ostream* os) {
40 770352 *os << "Portion__R_" << static_cast<int>(portion.start_row() * 1000) //
41 770352 << "__C_" << static_cast<int>(portion.start_col() * 1000) //
42 770352 << "__H_" << static_cast<int>(portion.height() * 1000) //
43 770352 << "__W_" << static_cast<int>(portion.width() * 1000);
44 770352 }
45
46 146850 std::string test_description(
47 const std::string_view& name, const MatMulShape& shape, const MatrixPortion& portion, bool bias,
48 float clamp_keep_ratio) {
49 146850 std::ostringstream os;
50
51
2/4
✓ Branch 0 taken 146850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146850 times.
✗ Branch 3 not taken.
146850 os << name << "__";
52
1/2
✓ Branch 0 taken 146850 times.
✗ Branch 1 not taken.
146850 PrintTo(shape, &os);
53
1/2
✓ Branch 0 taken 146850 times.
✗ Branch 1 not taken.
146850 os << "__";
54
1/2
✓ Branch 0 taken 146850 times.
✗ Branch 1 not taken.
146850 PrintTo(portion, &os);
55
2/2
✓ Branch 0 taken 86418 times.
✓ Branch 1 taken 60432 times.
146850 if (bias) {
56
1/2
✓ Branch 0 taken 86418 times.
✗ Branch 1 not taken.
86418 os << "__Bias";
57 86418 }
58
2/4
✓ Branch 0 taken 146850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146850 times.
✗ Branch 3 not taken.
146850 os << "__clamp_keep_ratio_" << static_cast<int>(clamp_keep_ratio * 100);
59
60
1/2
✓ Branch 0 taken 146850 times.
✗ Branch 1 not taken.
146850 return os.str();
61 146850 }
62
63 } // namespace kai::test
64