Line | Branch | Exec | Source |
---|---|---|---|
1 | // SPDX-FileCopyrightText: 2023 - 2025 Arm Limited and/or its affiliates <open-source-office@arm.com> | ||
2 | // | ||
3 | // SPDX-License-Identifier: Apache-2.0 | ||
4 | |||
5 | #ifndef KLEIDICV_COMPARE_SC_H | ||
6 | #define KLEIDICV_COMPARE_SC_H | ||
7 | |||
8 | #include "kleidicv/kleidicv.h" | ||
9 | #include "kleidicv/sve2.h" | ||
10 | |||
11 | namespace KLEIDICV_TARGET_NAMESPACE { | ||
12 | |||
13 | template <typename ScalarType> | ||
14 | class ComparatorEqual : public UnrollTwice { | ||
15 | public: | ||
16 | using ContextType = Context; | ||
17 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
18 | using VectorType = typename VecTraits::VectorType; | ||
19 | using SignedScalarType = typename std::make_signed<ScalarType>::type; | ||
20 | using SignedVecTraits = | ||
21 | KLEIDICV_TARGET_NAMESPACE::VecTraits<SignedScalarType>; | ||
22 | using SignedVectorType = typename SignedVecTraits::VectorType; | ||
23 | |||
24 | // NOLINTBEGIN(readability-make-member-function-const) | ||
25 | 780 | VectorType vector_path(ContextType ctx, VectorType src_a, | |
26 | VectorType src_b) KLEIDICV_STREAMING { | ||
27 | 780 | svbool_t pg = ctx.predicate(); | |
28 | 780 | svbool_t predicate = svcmpeq(pg, src_a, src_b); | |
29 | 1560 | return svsel(predicate, VecTraits::svdup(255), VecTraits::svdup(0)); | |
30 | 780 | } | |
31 | // NOLINTEND(readability-make-member-function-const) | ||
32 | }; // end of class ComparatorEqual | ||
33 | |||
34 | template <typename ScalarType> | ||
35 | class ComparatorGreater : public UnrollTwice { | ||
36 | public: | ||
37 | using ContextType = Context; | ||
38 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
39 | using VectorType = typename VecTraits::VectorType; | ||
40 | using SignedScalarType = typename std::make_signed<ScalarType>::type; | ||
41 | using SignedVecTraits = | ||
42 | KLEIDICV_TARGET_NAMESPACE::VecTraits<SignedScalarType>; | ||
43 | using SignedVectorType = typename SignedVecTraits::VectorType; | ||
44 | |||
45 | // NOLINTBEGIN(readability-make-member-function-const) | ||
46 | 780 | VectorType vector_path(ContextType ctx, VectorType src_a, | |
47 | VectorType src_b) KLEIDICV_STREAMING { | ||
48 | 780 | svbool_t pg = ctx.predicate(); | |
49 | 780 | svbool_t predicate = svcmpgt(pg, src_a, src_b); | |
50 | 1560 | return svsel(predicate, VecTraits::svdup(255), VecTraits::svdup(0)); | |
51 | 780 | } | |
52 | // NOLINTEND(readability-make-member-function-const) | ||
53 | }; // end of class ComparatorGreater | ||
54 | |||
55 | template <typename Comparator, typename ScalarType> | ||
56 | 312 | kleidicv_error_t compare_sc(const ScalarType *src_a, size_t src_a_stride, | |
57 | const ScalarType *src_b, size_t src_b_stride, | ||
58 | ScalarType *dst, size_t dst_stride, size_t width, | ||
59 | size_t height) KLEIDICV_STREAMING { | ||
60 |
8/8✓ Branch 0 taken 2 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 154 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 154 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 154 times.
|
312 | CHECK_POINTER_AND_STRIDE(src_a, src_a_stride, height); |
61 |
8/8✓ Branch 0 taken 2 times.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 152 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 152 times.
|
308 | CHECK_POINTER_AND_STRIDE(src_b, src_b_stride, height); |
62 |
8/8✓ Branch 0 taken 2 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 150 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 150 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 150 times.
|
304 | CHECK_POINTER_AND_STRIDE(dst, dst_stride, height); |
63 |
12/12✓ Branch 0 taken 2 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 146 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 148 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 146 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 146 times.
|
300 | CHECK_IMAGE_SIZE(width, height); |
64 | |||
65 | 292 | Comparator operation{}; | |
66 | 292 | Rectangle rect{width, height}; | |
67 | 292 | Rows<const ScalarType> src_a_rows{src_a, src_a_stride}; | |
68 | 292 | Rows<const ScalarType> src_b_rows{src_b, src_b_stride}; | |
69 | 292 | Rows<ScalarType> dst_rows{dst, dst_stride}; | |
70 | |||
71 | 292 | apply_operation_by_rows(operation, rect, src_a_rows, src_b_rows, dst_rows); | |
72 | |||
73 | 292 | return KLEIDICV_OK; | |
74 | 312 | } | |
75 | |||
76 | } // namespace KLEIDICV_TARGET_NAMESPACE | ||
77 | |||
78 | #endif // KLEIDICV_COMPARE_SC_H | ||
79 |