KleidiAI Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 90.0% 18 / 0 / 20
Functions: 100.0% 2 / 0 / 2
Branches: 60.0% 12 / 0 / 20

test/nextgen/reference/matmul.cpp
Line Branch Exec Source
1 //
2 // SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6
7 #include "test/nextgen/reference/matmul.hpp"
8
9 #include <cstddef>
10
11 #include "test/common/assert.hpp"
12 #include "test/common/buffer.hpp"
13 #include "test/common/data_type.hpp"
14 #include "test/common/memory.hpp"
15 #include "test/common/round.hpp"
16 #include "test/common/span.hpp"
17 #include "test/nextgen/functions/fused_mul_add.hpp"
18
19 namespace kai::test {
20
21 namespace {
22
23 template <typename T>
24 200 [[nodiscard]] Buffer matmul_nt_t(
25 size_t shape_m, size_t shape_n, size_t shape_k, Span<const std::byte> lhs, Span<const std::byte> rhs) {
26 200 Buffer dst(shape_m * round_up_division(shape_n * size_in_bits<T>, 8), 0);
27
28
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 15452 times.
15652 for (size_t row = 0; row < shape_m; ++row) {
29
2/2
✓ Branch 0 taken 15452 times.
✓ Branch 1 taken 1246953 times.
1262405 for (size_t col = 0; col < shape_n; ++col) {
30 1246953 T acc = static_cast<T>(0);
31
32
2/2
✓ Branch 0 taken 100601313 times.
✓ Branch 1 taken 1246953 times.
101848266 for (size_t depth = 0; depth < shape_k; ++depth) {
33
1/2
✓ Branch 0 taken 100601313 times.
✗ Branch 1 not taken.
100601313 const T lhs_value = read_2d<T>(lhs, shape_k, row, depth);
34
1/2
✓ Branch 0 taken 100601313 times.
✗ Branch 1 not taken.
100601313 const T rhs_value = read_2d<T>(rhs, shape_k, col, depth);
35
36
1/2
✓ Branch 0 taken 100601313 times.
✗ Branch 1 not taken.
100601313 acc = fused_mul_add<T>(lhs_value, rhs_value, acc);
37 100601313 }
38
39
2/4
✓ Branch 0 taken 1246953 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1246953 times.
✗ Branch 3 not taken.
1246953 write_2d<T>(dst.view(), shape_n, row, col, acc);
40 1246953 }
41 15452 }
42
43 200 return dst;
44 200 }
45
46 } // namespace
47
48 200 MatMulFn make_matmul_nt_t(DataType dtype) {
49
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 switch (dtype) {
50 case DataType::FP32:
51 200 return matmul_nt_t<float>;
52
53 default:
54 KAI_TEST_ERROR("Not implemented.");
55 }
56 }
57
58 } // namespace kai::test
59