KleidiAI Coverage Report


Directory: ./
File: test/common/logging.hpp
Date: 2025-10-20 13:18:31
Coverage Exec Excl Total
Lines: 0.0% 0 0 14
Functions: 0.0% 0 0 57
Branches: -% 0 0 0

Line Branch Exec Source
1 //
2 // SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6
7 #pragma once
8
9 #include <cstdint>
10 #include <iostream>
11 #include <string_view>
12 #include <type_traits>
13
14 #include "test/common/int4.hpp"
15
16 #define KAI_LOGE(...) kai::test::detail::log("ERROR", __VA_ARGS__)
17
18 namespace kai::test::detail {
19
20 /// Prints the specified value to standard error.
21 ///
22 /// @tparam T Data type.
23 ///
24 /// @param[in] value Value to be printed out.
25 template <typename T>
26 void write_log_content(T&& value) {
27 using TT = std::decay_t<decltype(value)>;
28
29 if constexpr (std::is_same_v<TT, uint8_t>) {
30 std::cerr << static_cast<uint32_t>(value);
31 } else if constexpr (std::is_same_v<TT, int8_t>) {
32 std::cerr << static_cast<int32_t>(value);
33 } else if constexpr (std::is_same_v<TT, UInt4>) {
34 std::cerr << static_cast<int32_t>(value);
35 } else if constexpr (std::is_same_v<TT, Int4>) {
36 std::cerr << static_cast<int32_t>(value);
37 } else {
38 std::cerr << value;
39 }
40 }
41
42 /// Prints the specified values to standard error.
43 ///
44 /// @tparam T Data type of the first value.
45 /// @tparam Ts Data types of the subsequent values.
46 ///
47 /// @param[in] value First value to be printed out.
48 /// @param[in] others Subsequent values to be printed out.
49 template <typename T, typename... Ts>
50 void write_log_content(T&& value, Ts&&... others) {
51 write_log_content(std::forward<T>(value));
52 write_log_content(std::forward<Ts>(others)...);
53 }
54
55 /// Prints the log to standard error.
56 ///
57 /// @tparam Ts Data types of values to be printed out.
58 ///
59 /// @param[in] level Severity level.
60 /// @param[in] args Values to be printed out.
61 template <typename... Ts>
62 void log(std::string_view level, Ts&&... args) {
63 std::cerr << level << " | ";
64 write_log_content(std::forward<Ts>(args)...);
65 std::cerr << "\n";
66 }
67
68 } // namespace kai::test::detail
69