Elffuss BraidHub

kikocis/kleidiai public

main · 1.8 KiBRawPermalink
1//
2// SPDX-FileCopyrightText: Copyright 2024-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
11#include "test/common/buffer.hpp"
12#include "test/common/data_type.hpp"
13
14namespace kai::test {
15
16/// Converts each element of the array to the specified data type.
17///
18/// @tparam DstType The data type to cast into.
19/// @tparam SrcType The data type to cast from.
20///
21/// @param[in] src The source data.
22/// @param[in] length The number of elements.
23///
24/// @return A new data buffer containing casted values.
25template <typename DstType, typename SrcType>
26Buffer cast(const void* src, size_t length);
27
28/// Converts each element of the source matrix to the new data type.
29///
30/// @param[in] src Source matrix data buffer.
31/// @param[in] src_dt Data type of the source matrix.
32/// @arapm[in] dst_dt Data type of the destination matrix.
33/// @param[in] height Number of rows.
34/// @param[in] width Number of columns.
35///
36/// @return The result matrix containing data in the destination data type.
37Buffer cast(const void* src, DataType src_dt, DataType dst_dt, size_t height, size_t width);
38
39/// Converts each element of the source data from 4-bit signed symmetric quantized
40/// to 4-bit unsigned symmetric quantized.
41///
42/// @param[in] src The source data.
43/// @param[in] length The number of elements.
44///
45/// @return A new data buffer with converted values.
46Buffer cast_qsu4_qsi4(const void* src, size_t length);
47
48/// Converts each element of the source data from 2-bit signed quantized
49/// to 2-bit unsigned quantized.
50///
51/// @param[in] src The source data.
52/// @param[in] length The number of elements.
53///
54/// @return A new data buffer with converted values.
55Buffer cast_u2_i2(const void* src, size_t length);
56
57} // namespace kai::test