KleidiAI Coverage Report


Directory: ./
File: test/reference/reorder.cpp
Date: 2025-10-20 13:18:31
Coverage Exec Excl Total
Lines: 100.0% 21 0 21
Functions: 100.0% 2 0 2
Branches: 80.6% 29 0 36

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 "test/reference/reorder.hpp"
8
9 #include <cstddef>
10 #include <cstdint>
11 #include <vector>
12
13 #include "test/common/buffer.hpp"
14 #include "test/common/memory.hpp"
15 #include "test/common/round.hpp"
16
17 namespace kai::test {
18
19 template <typename T>
20 5025 Buffer reorder_block(const void* src, size_t height, size_t width, size_t block_height, size_t block_width) {
21 5025 const auto num_dst_elements = round_up_multiple(height, block_height) * round_up_multiple(width, block_width);
22 5025 const auto dst_size = round_up_division(num_dst_elements * size_in_bits<T>, 8);
23
24 5025 Buffer dst(dst_size, 0);
25 5025 size_t dst_index = 0;
26
27
4/4
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 1854 times.
✓ Branch 2 taken 4851 times.
✓ Branch 3 taken 3171 times.
14814 for (size_t y_block = 0; y_block < height; y_block += block_height) {
28
4/4
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 201882 times.
✓ Branch 2 taken 4851 times.
✓ Branch 3 taken 81732 times.
293403 for (size_t x_block = 0; x_block < width; x_block += block_width) {
29
4/4
✓ Branch 0 taken 6452133 times.
✓ Branch 1 taken 201882 times.
✓ Branch 2 taken 2614122 times.
✓ Branch 3 taken 81732 times.
9349869 for (size_t y_element = 0; y_element < block_height; ++y_element) {
30
4/4
✓ Branch 0 taken 25808532 times.
✓ Branch 1 taken 6452133 times.
✓ Branch 2 taken 2614122 times.
✓ Branch 3 taken 2614122 times.
37488909 for (size_t x_element = 0; x_element < block_width; ++x_element) {
31 28422654 const auto y = y_block + y_element;
32 28422654 const auto x = x_block + x_element;
33
34
7/8
✓ Branch 0 taken 18715812 times.
✓ Branch 1 taken 7092720 times.
✓ Branch 2 taken 110034 times.
✓ Branch 3 taken 18605778 times.
✓ Branch 4 taken 1130571 times.
✓ Branch 5 taken 1483551 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1130571 times.
28422654 if (y < height && x < width) {
35
6/12
✓ Branch 0 taken 18605778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18605778 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18605778 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1130571 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1130571 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1130571 times.
✗ Branch 11 not taken.
19736349 write_array<T>(dst.data(), dst_index, read_array<T>(src, y * width + x));
36 19736349 }
37
38 28422654 ++dst_index;
39 28422654 }
40 9066255 }
41 283614 }
42 9789 }
43
44 5025 return dst;
45 5025 }
46
47 template Buffer reorder_block<int8_t>(
48 const void* src, size_t height, size_t width, size_t block_height, size_t block_width);
49 template Buffer reorder_block<const void*>(
50 const void* src, size_t height, size_t width, size_t block_height, size_t block_width);
51
52 } // namespace kai::test
53