| 1 | // |
| 2 | // SPDX-FileCopyrightText: Copyright 2025-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 | #include <optional> |
| 11 | #include <tuple> |
| 12 | |
| 13 | #include "test/common/buffer.hpp" |
| 14 | #include "test/common/data_type.hpp" |
| 15 | #include "test/nextgen/common/shape.hpp" |
| 16 | |
| 17 | namespace kai::test { |
| 18 | |
| 19 | /// Clamp limits. |
| 20 | template <typename T> |
| 21 | struct ClampLimits { |
| 22 | T min_value; |
| 23 | T max_value; |
| 24 | }; |
| 25 | |
| 26 | /// Determines the clamp range and clamps the data. |
| 27 | /// |
| 28 | /// @param[in] ratio The ratio between the output range and the input range. |
| 29 | /// @param[in] shape The size of multidimensional array. |
| 30 | /// @param[in] data The data buffer. |
| 31 | /// |
| 32 | /// @return The clamp range and clamped data. |
| 33 | using DynamicClampFn = std::tuple<Buffer, Buffer> (*)(float ratio, Shape shape, Span<const std::byte> data); |
| 34 | |
| 35 | /// Creates a clamp function for the specified data type. |
| 36 | /// |
| 37 | /// @param[in] dtype The data type. |
| 38 | /// |
| 39 | /// @return The function pointer. |
| 40 | [[nodiscard]] DynamicClampFn make_dynamic_clamp(DataType dtype); |
| 41 | |
| 42 | } // namespace kai::test |