Elffuss BraidHub

kikocis/kleidiai public

main · 1.9 KiBRawPermalink
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 <ostream>
11
12#include "test/common/buffer.hpp"
13#include "test/common/compare.hpp"
14#include "test/common/data_type.hpp"
15#include "test/nextgen/common/random.hpp"
16#include "test/nextgen/common/shape.hpp"
17#include "test/nextgen/format/format.hpp"
18
19namespace kai::test {
20
21/// Multidimensional array with elements being stored in row-major order.
22///
23/// For example:
24/// A data buffer with the shape of (2, 3), i.e. 2 rows and 3 columns:
25/// a00 a01 a02
26/// a10 a11 a12
27/// It is stored in the memory as follows:
28/// a00 a01 a02 a10 a11 a12
29class PlainFormat final : public Format {
30public:
31 /// Creates a new plain data format.
32 ///
33 /// @param[in] dtype The element data type.
34 explicit PlainFormat(DataType dtype) : m_dtype(dtype) {
35 }
36
37 [[nodiscard]] DataType dtype() const override {
38 return m_dtype;
39 }
40
41 [[nodiscard]] std::string uid() const override;
42 [[nodiscard]] size_t compute_offset(Shape shape, Span<const size_t> indices) const override;
43 [[nodiscard]] size_t compute_size(Shape shape) const override;
44 [[nodiscard]] Buffer generate(Shape shape, const GeneratorFn& generator) const override;
45 [[nodiscard]] Buffer pack(Shape shape, Span<const Span<const std::byte>> buffers) const override;
46 [[nodiscard]] bool compare(
47 Shape shape, Span<const size_t> tile_coords, Shape tile_shape, Span<const std::byte> imp_buffer,
48 Span<const std::byte> ref_buffer, MismatchHandler& handler) const override;
49 void print(std::ostream& os, Shape shape, Span<const std::byte> data) const override;
50 [[nodiscard]] bool operator==(const Format& other) const override;
51
52private:
53 DataType m_dtype;
54};
55
56} // namespace kai::test