KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/transform/transform_common.h
Date: 2025-11-25 17:23:32
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 5492 bool is_image_large(const Rows<T> &rows, size_t height) {
13 5492 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 5492 void transform_operation(size_t channels, Args &&...args) {
21
32/48
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1148 times.
✓ Branch 14 taken 20 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 460 times.
✓ Branch 17 taken 20 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1384 times.
✓ Branch 20 taken 264 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 700 times.
✓ Branch 23 taken 264 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 4 times.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4 times.
✓ Branch 29 taken 4 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 8 times.
✓ Branch 32 taken 4 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 8 times.
✓ Branch 35 taken 4 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 20 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 20 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 264 times.
✓ Branch 44 taken 264 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 264 times.
✓ Branch 47 taken 264 times.
5492 switch (channels) {
22 case 1:
23 4324 transform_operation<ScalarType, IsLarge, Inter, Border, 1UL>(
24 4324 std::forward<Args>(args)...);
25 4324 break;
26 case 2:
27 1168 transform_operation<ScalarType, IsLarge, Inter, Border, 2UL>(
28 1168 std::forward<Args>(args)...);
29 default:
30 1168 return;
31 }
32 5492 }
33
34 // Convert border_type to a template argument.
35 template <typename ScalarType, bool IsLarge,
36 kleidicv_interpolation_type_t Inter, typename... Args>
37 5492 void transform_operation(kleidicv_border_type_t border_type, Args &&...args) {
38
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 1168 times.
✓ Branch 5 taken 480 times.
✓ Branch 6 taken 1648 times.
✓ Branch 7 taken 964 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 12 times.
✓ Branch 12 taken 36 times.
✓ Branch 13 taken 36 times.
✓ Branch 14 taken 528 times.
✓ Branch 15 taken 528 times.
5492 if (border_type == KLEIDICV_BORDER_TYPE_REPLICATE) {
39 3436 transform_operation<ScalarType, IsLarge, Inter,
40 KLEIDICV_BORDER_TYPE_REPLICATE>(
41 3436 std::forward<Args>(args)...);
42 3436 } else {
43 2056 transform_operation<ScalarType, IsLarge, Inter,
44 KLEIDICV_BORDER_TYPE_CONSTANT>(
45 2056 std::forward<Args>(args)...);
46 }
47 5492 }
48
49 // Convert interpolation_type to a template argument.
50 template <typename ScalarType, bool IsLarge, typename... Args>
51 5492 void transform_operation(kleidicv_interpolation_type_t interpolation_type,
52 Args &&...args) {
53
8/8
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 2612 times.
✓ Branch 3 taken 1648 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 1056 times.
✓ Branch 7 taken 72 times.
5492 if (interpolation_type == KLEIDICV_INTERPOLATION_NEAREST) {
54 1764 transform_operation<ScalarType, IsLarge, KLEIDICV_INTERPOLATION_NEAREST>(
55 1764 std::forward<Args>(args)...);
56 1764 } else {
57 3728 transform_operation<ScalarType, IsLarge, KLEIDICV_INTERPOLATION_LINEAR>(
58 3728 std::forward<Args>(args)...);
59 }
60 5492 }
61
62 // Convert is_large to a template argument.
63 template <typename ScalarType, typename... Args>
64 5492 void transform_operation(bool is_large, Args &&...args) {
65
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4260 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 1128 times.
5492 if (KLEIDICV_UNLIKELY(is_large)) {
66 104 transform_operation<ScalarType, true>(std::forward<Args>(args)...);
67 104 } else {
68 5388 transform_operation<ScalarType, false>(std::forward<Args>(args)...);
69 }
70 5492 }
71
72 } // namespace KLEIDICV_TARGET_NAMESPACE
73