Elffuss BraidHub

kikocis/kleidiai public

main · 4.8 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#ifndef KLEIDIAI_BENCHMARK_MATMUL_MATMUL_INTERFACE_HPP
8#define KLEIDIAI_BENCHMARK_MATMUL_MATMUL_INTERFACE_HPP
9
10#include <cstddef>
11#include <cstdint>
12
13#include "kai/kai_common.h"
14#include "kai/ukernels/matmul/kai_matmul_types.h"
15
16namespace kai::benchmark {
17
18enum : uint32_t {
19 KAI_BENCHMARK_MATMUL_UKER_ARGS_ACC_BIAS_M = 1U << 0,
20 KAI_BENCHMARK_MATMUL_UKER_ARGS_ACC_BIAS_N = 1U << 1,
21 KAI_BENCHMARK_MATMUL_UKER_ARGS_SCALE_BIAS_N = 1U << 2,
22 KAI_BENCHMARK_MATMUL_UKER_ARGS_ACC_SCALE_GLOBAL = 1U << 3,
23 KAI_BENCHMARK_MATMUL_UKER_ARGS_SCALE_BIAS_GLOBAL = 1U << 4,
24};
25
26/// Abstraction for the unspecialized Matrix Multiplication microkernel interface
27struct MatMulBaseInterface {
28 void (*run_matmul)(
29 size_t m, size_t n, size_t k, //
30 const void* lhs_packed, //
31 const void* rhs_packed, //
32 void* dst, //
33 size_t dst_stride_row, size_t dst_stride_col, //
34 float clamp_min, float clamp_max);
35};
36
37/// Abstraction for the unspecialized Matrix Multiplication microkernel interface with a strided LHS matrix
38struct MatMulStridedLhsInterface {
39 void (*run_matmul)(
40 size_t m, size_t n, size_t k, //
41 const void* lhs_packed, //
42 size_t lhs_stride, //
43 const void* rhs_packed, //
44 void* dst, //
45 size_t dst_stride_row, size_t dst_stride_col, //
46 float clamp_min, float clamp_max);
47};
48
49/// Abstraction for the Matrix Multiplication microkernel interface with a floating point destination buffer
50struct MatMulFloatInterface {
51 void (*run_matmul)(
52 size_t m, size_t n, size_t k, //
53 const void* lhs_packed, //
54 const void* rhs_packed, //
55 float* dst, //
56 size_t dst_stride_row, size_t dst_stride_col, //
57 float clamp_min, float clamp_max);
58};
59
60/// Abstraction for the Matrix Multiplication micro-kernel with static quantization
61struct MatMulStaticQuantInterface {
62 void (*run_matmul)(
63 size_t m, size_t n, size_t k, //
64 const void* lhs_packed, //
65 const void* rhs_packed, //
66 void* dst, //
67 size_t dst_stride_row, size_t dst_stride_col, //
68 const kai_matmul_requantize32_params* params);
69};
70
71/// Abstraction for the Matrix Multiplication micro-kernel with dynamic blockwise quantization and generic destination
72/// buffer
73struct MatMulBlockwiseDynamicQuantGenericDstInterface {
74 void (*run_matmul)(
75 size_t m, size_t n, size_t k, size_t bl, //
76 const void* lhs_packed, //
77 const void* rhs_packed, //
78 void* dst, //
79 size_t dst_stride_row, size_t dst_stride_col, //
80 float clamp_min, float clamp_max);
81};
82
83/// Abstraction for the Matrix Multiplication micro-kernel with dynamic blockwise quantization and float destination
84/// buffer
85struct MatMulBlockwiseDynamicQuantInterface {
86 void (*run_matmul)(
87 size_t m, size_t n, size_t k, size_t bl, //
88 const void* lhs_packed, //
89 const void* rhs_packed, //
90 float* dst, //
91 size_t dst_stride_row, size_t dst_stride_col, //
92 float clamp_min, float clamp_max);
93};
94
95/// Abstraction for the Matrix Multiplication micro-kernel with dynamic blockwise quantization and float destination
96/// buffer with look up table in the interface
97struct MatMulBlockwiseDynamicQuantLutInterface {
98 void (*run_matmul)(
99 size_t m, size_t n, size_t k, //
100 const void* lhs_packed, //
101 const void* rhs_packed, //
102 float* dst, //
103 size_t dst_stride_row, size_t dst_stride_col, //
104 float clamp_min, float clamp_max, //
105 const int32_t* lut);
106};
107
108/// Abstraction for the Matrix Multiplication micro-kernel API wrapper.
109struct MatMulUkernelApiInterface {
110 kai_matmul_uker_config (*get_config)(void);
111 kai_matmul_uker_api (*get_api)(void);
112 uint64_t flags = 0;
113 uint32_t args_flags = 0;
114 size_t acc_bias_elem_size = 0;
115 size_t acc_scale_elem_size = 0;
116 size_t scale_bias_elem_size = 0;
117};
118
119} // namespace kai::benchmark
120
121#endif // KLEIDIAI_BENCHMARK_MATMUL_MATMUL_INTERFACE_HPP