KleidiAI Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 7 / 0 / 7
Functions: 100.0% 1 / 0 / 1
Branches: -% 0 / 0 / 0

test/nextgen/quantization/symm_linear_quantizer.hpp
Line Branch Exec Source
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/nextgen/functions/round.hpp"
14 #include "test/nextgen/harness/tensor.hpp"
15 #include "test/nextgen/quantization/quantizer.hpp"
16
17 namespace kai::test {
18
19 /// Symmetric linear quantizer.
20 class SymmLinearQuantizer : public Quantizer {
21 public:
22 /// Creates a new symmetric linear quantizer.
23 ///
24 /// @param[in] qdata_dtype The quantized data type.
25 /// @param[in] qscale_dtype The quantization scale data type.
26 /// @param[in] qdata_round_mode The rounding mode to calculate quantized data.
27 /// @param[in] block_height The quantization block height (0 if it's full height).
28 /// @param[in] block_width The quantization block width (0 if it's full width).
29 16 SymmLinearQuantizer(
30 DataType qdata_dtype, DataType qscale_dtype, RoundMode qdata_round_mode, size_t block_height,
31 size_t block_width) :
32 12 m_qdata_dtype(qdata_dtype),
33 12 m_qscale_dtype(qscale_dtype),
34 12 m_qdata_round_mode(qdata_round_mode),
35 12 m_block_height(block_height),
36 28 m_block_width(block_width) {
37 16 }
38
39 void dynamic_quantize(
40 DataType fp_dtype, Span<const size_t> shape, Span<const std::byte> fp_data, Tensor& qdata, Tensor& qscale,
41 Tensor& qzp) const override;
42 [[nodiscard]] Buffer dequantize(
43 DataType fp_dtype, Span<const size_t> shape, Span<const std::byte> qdata, Span<const std::byte> qscale,
44 Span<const std::byte> qzp) const override;
45
46 private:
47 DataType m_qdata_dtype;
48 DataType m_qscale_dtype;
49
50 RoundMode m_qdata_round_mode;
51
52 size_t m_block_height;
53 size_t m_block_width;
54 };
55
56 } // namespace kai::test
57