| 1 | // |
| 2 | // SPDX-FileCopyrightText: Copyright 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/assert.hpp" |
| 12 | #include "test/common/enum_utils.hpp" |
| 13 | #include "test/nextgen/common/shape.hpp" |
| 14 | |
| 15 | namespace kai::test { |
| 16 | |
| 17 | /// Matrix multiplication dimensions. |
| 18 | enum class MatMulDim : size_t { |
| 19 | M, |
| 20 | N, |
| 21 | K, |
| 22 | LAST, |
| 23 | }; |
| 24 | |
| 25 | /// Two-dimensional matrix dimensions. |
| 26 | enum class MatDim : size_t { |
| 27 | R, |
| 28 | C, |
| 29 | LAST, |
| 30 | }; |
| 31 | |
| 32 | /// Helper class for allowing MatMulDim to be used as index for matmul shapes. |
| 33 | class MatMulShape : public Shape { |
| 34 | public: |
| 35 | using Span<const size_t>::Span; |
| 36 | |
| 37 | constexpr MatMulShape() = default; |
| 38 | |
| 39 | constexpr MatMulShape(Shape shape) : Span<const size_t>(shape.data(), shape.size()) { |
| 40 | } |
| 41 | |
| 42 | [[nodiscard]] constexpr size_t at(MatMulDim dim) const { |
| 43 | return Span<const size_t>::at(static_cast<size_t>(as_idx(dim))); |
| 44 | } |
| 45 | |
| 46 | [[nodiscard]] constexpr size_t at(size_t) const = delete; |
| 47 | [[nodiscard]] constexpr size_t operator[](size_t) const = delete; |
| 48 | }; |
| 49 | |
| 50 | /// Helper class for allowing MatDim to be used as index for 2D matrix shapes. |
| 51 | class MatShape : public Shape { |
| 52 | public: |
| 53 | using Span<const size_t>::Span; |
| 54 | |
| 55 | constexpr MatShape() = default; |
| 56 | |
| 57 | constexpr MatShape(Shape shape) : Span<const size_t>(shape.data(), shape.size()) { |
| 58 | } |
| 59 | |
| 60 | [[nodiscard]] constexpr size_t at(MatDim dim) const { |
| 61 | return Span<const size_t>::at(static_cast<size_t>(as_idx(dim))); |
| 62 | } |
| 63 | |
| 64 | [[nodiscard]] constexpr size_t at(size_t) const = delete; |
| 65 | [[nodiscard]] constexpr size_t operator[](size_t) const = delete; |
| 66 | }; |
| 67 | |
| 68 | } // namespace kai::test |