Elffuss BraidHub

kikocis/kleidiai public

main · 2.0 KiBRawPermalink
1//
2// SPDX-FileCopyrightText: Copyright 2024-2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6
7#include "matmul_test_common.hpp"
8
9#include <sstream>
10
11namespace kai::test {
12
13std::ostream& operator<<(std::ostream& os, const MatMulShape& shape) {
14 return os << "[m=" << shape.m << ", n=" << shape.n << ", k=" << shape.k << "]";
15}
16
17void PrintTo(const MatMulClampTestParams& param, std::ostream* os) {
18 const auto& [method, shape, portion, bias_mode, clamp_keep_ratio] = param;
19
20 *os << method.name << "__";
21 PrintTo(shape, os);
22 *os << "__";
23 PrintTo(portion, os);
24 PrintTo(bias_mode, os);
25 *os << "__clamp_keep_ratio_"
26 << (clamp_keep_ratio.has_value() ? std::to_string(static_cast<int>(clamp_keep_ratio.value() * 100))
27 : "noclamp");
28}
29
30void PrintTo(const MatMulShape& shape, std::ostream* os) {
31 *os << "M_" << shape.m << "__N_" << shape.n << "__K_" << shape.k;
32}
33
34void PrintTo(const BiasMode& bias_mode, std::ostream* os) {
35 // Preserve legacy test names
36 if (bias_mode == BiasMode::INTERNAL) {
37 *os << "__NullBias";
38 }
39}
40
41void PrintTo(const MatrixPortion& portion, std::ostream* os) {
42 *os << "Portion__R_" << static_cast<int>(portion.start_row() * 1000) //
43 << "__C_" << static_cast<int>(portion.start_col() * 1000) //
44 << "__H_" << static_cast<int>(portion.height() * 1000) //
45 << "__W_" << static_cast<int>(portion.width() * 1000);
46}
47
48std::string test_description(
49 const std::string_view& name, const MatMulShape& shape, const MatrixPortion& portion, bool bias,
50 std::optional<float> clamp_keep_ratio) {
51 std::ostringstream os;
52
53 os << name << "__";
54 PrintTo(shape, &os);
55 os << "__";
56 PrintTo(portion, &os);
57 if (bias) {
58 os << "__Bias";
59 }
60 os << "__clamp_keep_ratio_"
61 << (clamp_keep_ratio.has_value() ? std::to_string(static_cast<int>(clamp_keep_ratio.value() * 100)) : "noclamp");
62
63 return os.str();
64}
65
66} // namespace kai::test