KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/transform/transform_common.h
Date: 2025-09-25 14:13:34
Exec Total Coverage
Lines: 33 33 100.0%
Functions: 94 94 100.0%
Branches: 60 76 78.9%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 #include <utility>
6
7 #include "kleidicv/types.h"
8
9 namespace KLEIDICV_TARGET_NAMESPACE {
10
11 template <typename T>
12 4119 bool is_image_large(const Rows<T> &rows, size_t height) {
13 4119 return rows.stride() * height >= 1ULL << 32;
14 }
15
16 // Convert channels to a template argument.
17 template <typename ScalarType, bool IsLarge,
18 kleidicv_interpolation_type_t Inter, kleidicv_border_type_t Border,
19 typename... Args>
20 4119 void transform_operation(size_t channels, Args &&...args) {
21
32/48
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 861 times.
✓ Branch 14 taken 15 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 345 times.
✓ Branch 17 taken 15 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1038 times.
✓ Branch 20 taken 198 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 525 times.
✓ Branch 23 taken 198 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 3 times.
✓ Branch 26 taken 3 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 3 times.
✓ Branch 29 taken 3 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 6 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 6 times.
✓ Branch 35 taken 3 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 12 times.
✓ Branch 38 taken 15 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 12 times.
✓ Branch 41 taken 15 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 198 times.
✓ Branch 44 taken 198 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 198 times.
✓ Branch 47 taken 198 times.
4119 switch (channels) {
22 case 1:
23 3243 transform_operation<ScalarType, IsLarge, Inter, Border, 1UL>(
24 3243 std::forward<Args>(args)...);
25 3243 break;
26 case 2:
27 876 transform_operation<ScalarType, IsLarge, Inter, Border, 2UL>(
28 876 std::forward<Args>(args)...);
29 default:
30 876 return;
31 }
32 4119 }
33
34 // Convert border_type to a template argument.
35 template <typename ScalarType, bool IsLarge,
36 kleidicv_interpolation_type_t Inter, typename... Args>
37 4119 void transform_operation(kleidicv_border_type_t border_type, Args &&...args) {
38
16/16
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 876 times.
✓ Branch 5 taken 360 times.
✓ Branch 6 taken 1236 times.
✓ Branch 7 taken 723 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 27 times.
✓ Branch 14 taken 396 times.
✓ Branch 15 taken 396 times.
4119 if (border_type == KLEIDICV_BORDER_TYPE_REPLICATE) {
39 2577 transform_operation<ScalarType, IsLarge, Inter,
40 KLEIDICV_BORDER_TYPE_REPLICATE>(
41 2577 std::forward<Args>(args)...);
42 2577 } else {
43 1542 transform_operation<ScalarType, IsLarge, Inter,
44 KLEIDICV_BORDER_TYPE_CONSTANT>(
45 1542 std::forward<Args>(args)...);
46 }
47 4119 }
48
49 // Convert interpolation_type to a template argument.
50 template <typename ScalarType, bool IsLarge, typename... Args>
51 4119 void transform_operation(kleidicv_interpolation_type_t interpolation_type,
52 Args &&...args) {
53
8/8
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 1959 times.
✓ Branch 3 taken 1236 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 792 times.
✓ Branch 7 taken 54 times.
4119 if (interpolation_type == KLEIDICV_INTERPOLATION_NEAREST) {
54 1323 transform_operation<ScalarType, IsLarge, KLEIDICV_INTERPOLATION_NEAREST>(
55 1323 std::forward<Args>(args)...);
56 1323 } else {
57 2796 transform_operation<ScalarType, IsLarge, KLEIDICV_INTERPOLATION_LINEAR>(
58 2796 std::forward<Args>(args)...);
59 }
60 4119 }
61
62 // Convert is_large to a template argument.
63 template <typename ScalarType, typename... Args>
64 4119 void transform_operation(bool is_large, Args &&...args) {
65
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3195 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 846 times.
4119 if (KLEIDICV_UNLIKELY(is_large)) {
66 78 transform_operation<ScalarType, true>(std::forward<Args>(args)...);
67 78 } else {
68 4041 transform_operation<ScalarType, false>(std::forward<Args>(args)...);
69 }
70 4119 }
71
72 } // namespace KLEIDICV_TARGET_NAMESPACE
73