Elffuss BraidHub

kikocis/kleidiai public

main · 4.0 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 <cstddef>
10
11#include "test/common/buffer.hpp"
12#include "test/common/data_type.hpp"
13
14namespace kai::test {
15
16/// Elementwise addition.
17///
18/// Broadcasting is supported for any dimension and both LHS and RHS operands.
19///
20/// @param[in] lhs LHS data buffer.
21/// @param[in] lhs_dt LHS data type.
22/// @param[in] lhs_height LHS height.
23/// @param[in] lhs_width LHS width.
24/// @param[in] rhs RHS data buffer.
25/// @param[in] rhs_dt RHS data type.
26/// @param[in] rhs_height RHS height.
27/// @param[in] rhs_width RHS width.
28///
29/// @return The result matrix.
30Buffer add(
31 const void* lhs, DataType lhs_dt, size_t lhs_height, size_t lhs_width, //
32 const void* rhs, DataType rhs_dt, size_t rhs_height, size_t rhs_width);
33
34/// Elementwise subtraction.
35///
36/// Broadcasting is supported for any dimension and both LHS and RHS operands.
37///
38/// @param[in] lhs LHS data buffer.
39/// @param[in] lhs_dt LHS data type.
40/// @param[in] lhs_height LHS height.
41/// @param[in] lhs_width LHS width.
42/// @param[in] rhs RHS data buffer.
43/// @param[in] rhs_dt RHS data type.
44/// @param[in] rhs_height RHS height.
45/// @param[in] rhs_width RHS width.
46///
47/// @return The result matrix.
48Buffer sub(
49 const void* lhs, DataType lhs_dt, size_t lhs_height, size_t lhs_width, //
50 const void* rhs, DataType rhs_dt, size_t rhs_height, size_t rhs_width);
51
52/// Elementwise subtraction.
53///
54/// Broadcasting is supported for any dimension and both LHS and RHS operands.
55///
56/// @tparam T The data type.
57///
58/// @param[in] lhs The LHS data buffer.
59/// @param[in] lhs_height The number of rows of the LHS matrix.
60/// @param[in] lhs_width The number of columns of the LHS matrix.
61/// @param[in] rhs The RHS data buffer.
62/// @param[in] rhs_height The number of rows of the RHS matrix.
63/// @param[in] rhs_width The number of columns of the LHS matrix.
64///
65/// @return The result matrix.
66template <typename T>
67Buffer sub(
68 const void* lhs, size_t lhs_height, size_t lhs_width, //
69 const void* rhs, size_t rhs_height, size_t rhs_width);
70
71/// Elementwise multiplication.
72///
73/// Broadcasting is supported for any dimension and both LHS and RHS operands.
74///
75/// @param[in] lhs LHS data buffer.
76/// @param[in] lhs_dt LHS data type.
77/// @param[in] lhs_height LHS height.
78/// @param[in] lhs_width LHS width.
79/// @param[in] rhs RHS data buffer.
80/// @param[in] rhs_dt RHS data type.
81/// @param[in] rhs_height RHS height.
82/// @param[in] rhs_width RHS width.
83///
84/// @return The result matrix.
85Buffer mul(
86 const void* lhs, DataType lhs_dt, size_t lhs_height, size_t lhs_width, //
87 const void* rhs, DataType rhs_dt, size_t rhs_height, size_t rhs_width);
88
89/// Elementwise multiplication.
90///
91/// Broadcasting is supported for any dimension and both LHS and RHS operands.
92///
93/// @tparam T The data type.
94///
95/// @param[in] lhs The LHS data buffer.
96/// @param[in] lhs_height The number of rows of the LHS matrix.
97/// @param[in] lhs_width The number of columns of the LHS matrix.
98/// @param[in] rhs The RHS data buffer.
99/// @param[in] rhs_height The number of rows of the RHS matrix.
100/// @param[in] rhs_width The number of columns of the LHS matrix.
101///
102/// @return The result matrix.
103template <typename T>
104Buffer mul(
105 const void* lhs, size_t lhs_height, size_t lhs_width, //
106 const void* rhs, size_t rhs_height, size_t rhs_width);
107
108/// Elementwise division.
109///
110/// Broadcasting is supported for any dimension and both LHS and RHS operands.
111///
112/// @param[in] lhs LHS data buffer.
113/// @param[in] lhs_dt LHS data type.
114/// @param[in] lhs_height LHS height.
115/// @param[in] lhs_width LHS width.
116/// @param[in] rhs RHS data buffer.
117/// @param[in] rhs_dt RHS data type.
118/// @param[in] rhs_height RHS height.
119/// @param[in] rhs_width RHS width.
120///
121/// @return The result matrix.
122Buffer div(
123 const void* lhs, DataType lhs_dt, size_t lhs_height, size_t lhs_width, //
124 const void* rhs, DataType rhs_dt, size_t rhs_height, size_t rhs_width);
125
126} // namespace kai::test