blob: 678bb7aaf6b2a22c3a486b1bce4d4ac081fc8683 [file] [log] [blame]
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +00001/*
2 * Copyright (c) 2023 Arm Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
Gunes Bayir2ae536a2023-07-05 11:39:37 +010025#ifndef COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO
26#define COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000027
Nikolaj Jensen5ff48022023-06-27 14:13:24 +010028#include "ckw/types/DataType.h"
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000029
30#include <array>
31#include <cstdint>
32
33namespace ckw
34{
35// Constants to access the tile width and height in the TileShape
36constexpr int32_t kTileWidthIdx = 0;
37constexpr int32_t kTileHeightIdx = 1;
38
Gian Marco Iodice68e9c4d2023-06-15 17:40:28 +010039/** Compute Kernel Writer tile shape. It is used to define the shape of the tile */
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000040using TileShape = std::array<int32_t, 2>;
41
42/** Compute Kernel Writer tile info */
43class TileInfo
44{
45public:
46 /** Constructor used to initialize a scalar variable with a given data type
47 *
48 * @param[in] dt Tile data type
49 */
50 TileInfo(DataType dt);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010051
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000052 /** Constructor used to initialize a vector with a given data type and vector length.
53 *
54 * @param[in] dt Tile data type
55 * @param[in] w Tile width (or vector length)
56 */
57 TileInfo(DataType dt, int32_t w);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010058
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000059 /** Constructor used to initialize a tile with a given data type and tile sizes.
60 *
61 * @param[in] dt Tile data type
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000062 * @param[in] h Tile height
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010063 * @param[in] w Tile width
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000064 */
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010065 TileInfo(DataType dt, int32_t h, int32_t w);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010066
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000067 /** Set width */
68 TileInfo &width(int32_t w);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010069
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000070 /** Get width */
71 int32_t width() const;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010072
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000073 /** Set height */
74 TileInfo &height(int32_t h);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010075
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000076 /** Get height */
77 int32_t height() const;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010078
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000079 /** Set data type */
80 TileInfo &data_type(DataType dt);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010081
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000082 /** Get data type */
83 DataType data_type() const;
84
85private:
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010086 DataType _dt{DataType::Unknown};
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000087 TileShape _shape{};
88};
89
90} // namespace ckw
91
Gunes Bayir2ae536a2023-07-05 11:39:37 +010092#endif /* COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO */