Elffuss BraidHub

kikocis/kleidiai public

main · 2.8 KiBRawPermalink
1//
2// SPDX-FileCopyrightText: Copyright 2024-2025 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 <stddef.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif // __cplusplus
14
15/// Gets m step value.
16///
17/// The starting row index must be divisible by `m_step`.
18///
19/// @param[in] mr Number of rows to be interleaved.
20///
21/// @return The m step value.
22size_t kai_get_m_step_lhs_pack_x8p2vlx4_x8_sme(size_t mr);
23
24/// Gets the offset in bytes to the data element in the LHS buffer.
25///
26/// @param[in] m_idx Row index.
27/// @param[in] lhs_stride_row Row stride in bytes.
28///
29/// @return The offset in bytes to the data element.
30size_t kai_get_lhs_offset_lhs_pack_x8p2vlx4_x8_sme(size_t m_idx, size_t lhs_stride_row);
31
32/// Gets the offset in bytes to the data element in the packed LHS buffer.
33///
34/// @param[in] m_idx Row index in the unpacked LHS matrix.
35/// @param[in] k Number of columns in the unpacked LHS matrix.
36/// @param[in] mr Number of rows to be interleaved.
37/// @param[in] kr Unused. Must be 4.
38/// @param[in] sr Unused. Must be 1.
39///
40/// @return The offset in bytes to the data element.
41size_t kai_get_lhs_packed_offset_lhs_pack_x8p2vlx4_x8_sme(size_t m_idx, size_t k, size_t mr, size_t kr, size_t sr);
42
43/// Gets the size in bytes of the packed LHS buffer.
44///
45/// @param[in] m Number of rows in the unpacked LHS matrix.
46/// @param[in] k Number of columns in the unpacked LHS matrix.
47/// @param[in] mr Number of rows to be interleaved.
48/// @param[in] kr Unused. Must be 4.
49/// @param[in] sr Unused. Must be 1.
50///
51/// @return The size in bytes of the packed LHS buffer.
52size_t kai_get_lhs_packed_size_lhs_pack_x8p2vlx4_x8_sme(size_t m, size_t k, size_t mr, size_t kr, size_t sr);
53
54/// Runs the LHS packing function for matrix multiplication.
55///
56/// The pointer of each buffers (LHS and packed LHS) needs to be added with offset
57/// calculated using the following functions:
58///
59/// * LHS: @ref kai_get_lhs_offset_lhs_pack_x8p2vlx4_x8_sme.
60/// * Packed LHS: @ref kai_get_lhs_packed_offset_lhs_pack_x8p2vlx4_x8_sme.
61///
62/// @param[in] m Number of rows of the unpacked LHS matrix.
63/// @param[in] k Number of columns in the unpacked LHS matrix.
64/// @param[in] mr Block size in M dimension. It must be kai_get_m_step_lhs_pack_x8p2vlx4_x8_sme().
65/// @param[in] kr Block size in K dimension. It must be 4.
66/// @param[in] sr Number of kr splits. It must be 1.
67/// @param[in] m_idx_start Unused. Must be 0.
68/// @param[in] lhs LHS matrix data buffer.
69/// @param[in] lhs_stride_row Row stride in bytes of the LHS matrix.
70/// @param[out] lhs_packed Packed LHS matrix.
71void kai_run_lhs_pack_x8p2vlx4_x8_sme(
72 size_t m, size_t k, size_t mr, size_t kr, size_t sr, size_t m_idx_start, const void* lhs, size_t lhs_stride_row,
73 void* lhs_packed);
74
75#ifdef __cplusplus
76} // extern "C"
77#endif // __cplusplus