Elffuss BraidHub

kikocis/kleidiai public

main · 1.9 KiBRawPermalink
1//
2// SPDX-FileCopyrightText: Copyright 2025-2026 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 <cstddef>
10#include <memory>
11#include <optional>
12#include <string_view>
13#include <vector>
14
15#include "test/common/data_type.hpp"
16#include "test/common/matrix_portion.hpp"
17#include "test/common/span.hpp"
18#include "test/nextgen/harness/kernel_wrapper.hpp"
19#include "test/nextgen/operators/matmul/matmul_bias_mode.hpp"
20#include "test/nextgen/operators/matmul/matmul_dims.hpp"
21#include "test/nextgen/quantization/quantizer.hpp"
22
23namespace kai::test {
24
25using MatMulKernelPtr = std::unique_ptr<KernelWrapper<MatMulShape>>;
26using MatPackKernelPtr = std::unique_ptr<KernelWrapper<MatShape>>;
27
28/// Matrix multiplication clamping support.
29enum class MatMulClampMode {
30 UNSUPPORTED, ///< Clamping is not supported.
31 OPTIONAL, ///< Clamping is supported, but require explicit activation to enable.
32 REQUIRED, ///< Clamping parameters are required.
33};
34
35/// Matrix multiplication operator.
36struct MatMulOperator {
37 std::string_view name;
38
39 bool (*is_cpu_supported)();
40 bool (*is_shape_suitable)(size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion);
41
42 std::vector<MatMulBiasModeSet> supported_bias_mode_sets;
43 MatMulClampMode clamp_mode;
44
45 std::optional<std::unique_ptr<Quantizer>> lhs_quant;
46 std::optional<std::unique_ptr<Quantizer>> rhs_quant;
47 std::optional<std::unique_ptr<Quantizer>> bias_quant;
48
49 DataType lhs_dtype;
50 DataType rhs_dtype;
51 DataType bias_dtype;
52 DataType acc_dtype;
53 DataType dst_dtype;
54
55 std::optional<MatPackKernelPtr> pack_lhs;
56 std::optional<MatPackKernelPtr> pack_rhs;
57 std::optional<MatMulKernelPtr> matmul;
58};
59
60[[nodiscard]] Span<const MatMulOperator> get_available_matmul_operators();
61
62} // namespace kai::test