| 1 | // |
| 2 | // SPDX-FileCopyrightText: Copyright 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 | #include "test/common/span.hpp" |
| 14 | |
| 15 | namespace kai::test { |
| 16 | |
| 17 | /// Dequantizes the data using per-block linear quantization. |
| 18 | /// |
| 19 | /// @param[in] height The height of data matrix. |
| 20 | /// @param[in] width The width of data matrix. |
| 21 | /// @param[in] block_height The height of quantization block. |
| 22 | /// @param[in] block_width The width of quantization block. |
| 23 | /// @param[in] qdata The quantized data. |
| 24 | /// @param[in] qscale The quantization scale. |
| 25 | /// @param[in] qzp The quantization zero-point. |
| 26 | /// |
| 27 | /// @return The dequantized data. |
| 28 | using DequantizeLinearFn = Buffer (*)( |
| 29 | size_t height, size_t width, size_t block_height, size_t block_width, Span<const std::byte> qdata, |
| 30 | Span<const std::byte> qscale, Span<const std::byte> qzp); |
| 31 | |
| 32 | /// Creates a dequantization function using per-block linear quantization. |
| 33 | /// |
| 34 | /// @param[in] fp_dtype The data type of dequantized data. |
| 35 | /// @param[in] qdata_dtype The data type of quantized data. |
| 36 | /// @param[in] qscale_dtype The data type of quantization scale. |
| 37 | /// @param[in] qzp_dtype The data type of quantization zero-point. |
| 38 | /// |
| 39 | /// @return The function pointer. |
| 40 | [[nodiscard]] DequantizeLinearFn make_dequantize_linear( |
| 41 | DataType fp_dtype, DataType qdata_dtype, DataType qscale_dtype, DataType qzp_dtype = DataType::UNKNOWN); |
| 42 | |
| 43 | } // namespace kai::test |