test/reference/reorder.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 "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 | 2447 | Buffer reorder_block(const void* src, size_t height, size_t width, size_t block_height, size_t block_width) { | |
| 21 | 2447 | const auto num_dst_elements = round_up_multiple(height, block_height) * round_up_multiple(width, block_width); | |
| 22 | 2447 | const auto dst_size = round_up_division(num_dst_elements * size_in_bits<T>, 8); | |
| 23 | |||
| 24 | 2447 | Buffer dst(dst_size, 0); | |
| 25 | 2447 | size_t dst_index = 0; | |
| 26 | |||
| 27 |
4/4✓ Branch 0 taken 2817 times.
✓ Branch 1 taken 1042 times.
✓ Branch 2 taken 2120 times.
✓ Branch 3 taken 1405 times.
|
7384 | for (size_t y_block = 0; y_block < height; y_block += block_height) { |
| 28 |
4/4✓ Branch 0 taken 2817 times.
✓ Branch 1 taken 73829 times.
✓ Branch 2 taken 2120 times.
✓ Branch 3 taken 29228 times.
|
107994 | for (size_t x_block = 0; x_block < width; x_block += block_width) { |
| 29 |
4/4✓ Branch 0 taken 2354437 times.
✓ Branch 1 taken 73829 times.
✓ Branch 2 taken 933994 times.
✓ Branch 3 taken 29228 times.
|
3391488 | for (size_t y_element = 0; y_element < block_height; ++y_element) { |
| 30 |
4/4✓ Branch 0 taken 9417748 times.
✓ Branch 1 taken 2354437 times.
✓ Branch 2 taken 933994 times.
✓ Branch 3 taken 933994 times.
|
13640173 | for (size_t x_element = 0; x_element < block_width; ++x_element) { |
| 31 | 10351742 | const auto y = y_block + y_element; | |
| 32 | 10351742 | const auto x = x_block + x_element; | |
| 33 | |||
| 34 |
7/8✓ Branch 0 taken 6841164 times.
✓ Branch 1 taken 2576584 times.
✓ Branch 2 taken 80049 times.
✓ Branch 3 taken 6761115 times.
✓ Branch 4 taken 464123 times.
✓ Branch 5 taken 469871 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 464123 times.
|
10351742 | if (y < height && x < width) { |
| 35 |
6/12✓ Branch 0 taken 6761115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6761115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6761115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 464123 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 464123 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 464123 times.
✗ Branch 11 not taken.
|
7225238 | write_array<T>(dst.data(), dst_index, read_array<T>(src, y * width + x)); |
| 36 | 7225238 | } | |
| 37 | |||
| 38 | 10351742 | ++dst_index; | |
| 39 | 10351742 | } | |
| 40 | 3288431 | } | |
| 41 | 103057 | } | |
| 42 | 4937 | } | |
| 43 | |||
| 44 | 2447 | return dst; | |
| 45 | 2447 | } | |
| 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 |