Elffuss BraidHub

kikocis/kleidiai public

main · 2.1 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#include <cstdint>
11
12#include "test/common/buffer.hpp"
13
14namespace kai::test {
15
16class DataFormat;
17
18/// Reduction operator.
19enum class ReductionOperator : uint32_t {
20 ADD, ///< Addition.
21};
22
23/// Reduces the matrix value using addition.
24///
25/// @param[in] src Input data.
26/// @param[in] src_format Input data format.
27/// @param[in] height Number of rows.
28/// @param[in] width Number of columns.
29/// @param[in] dst_format Output data format.
30/// @param[in] dimension Reduction dimension.
31///
32/// @return The reduced matrix.
33Buffer reduce_add(
34 const void* src, const DataFormat& src_format, size_t height, size_t width, const DataFormat& dst_format,
35 size_t dimension);
36
37/// Accumulates the matrix along the first dimension.
38///
39/// @tparam Value The data type of the matrix value.
40/// @tparam Accumulator The data type of the accumulator.
41///
42/// @param[in] src The input data.
43/// @param[in] height The number of rows of the input matrix.
44/// @param[in] width The number of columns of the input matrix.
45///
46/// @return The vector containing the sum of each input matrix row.
47template <typename Value, typename Accumulator>
48Buffer reduce_add_x(const void* src, size_t height, size_t width);
49
50/// Retrieve the minimum value in a provided matrix.
51///
52/// @tparam T Datatype of source matrix
53///
54/// @param[in] src The input data
55/// @param[in] len The number of values within the source matrix.
56///
57/// @return The quantized data matrix, the quantization scale matrix and the quantization zero point matrix.
58template <typename T>
59T reduce_min(const void* src, size_t len);
60
61/// Retrieve the maximum value in a provided matrix.
62///
63/// @tparam T Datatyoe of source matrix
64///
65/// @param[in] src The input data
66/// @param[in] len The number of values within the source matrix.
67///
68/// @return The quantized data matrix, the quantization scale matrix and the quantization zero point matrix.
69template <typename T>
70T reduce_max(const void* src, size_t len);
71
72} // namespace kai::test