blob: e0d064169ed068b082168dbee6f78ffcaef4437c [file] [log] [blame]
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +01001/*
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
25#ifndef CKW_PROTOTYPE_INCLUDE_CKW_TILEINFO_H
26#define CKW_PROTOTYPE_INCLUDE_CKW_TILEINFO_H
27
Nikolaj Jensen5ff48022023-06-27 14:13:24 +010028#include "ckw/types/DataType.h"
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010029
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
39/** Compute Kernel Writer tile shape. It is used to define the shape of the tile */
40using 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
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010052 /** 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
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010059 /** Constructor used to initialize a tile with a given data type and tile sizes.
60 *
61 * @param[in] dt Tile data type
62 * @param[in] h Tile height
63 * @param[in] w Tile width
64 */
65 TileInfo(DataType dt, int32_t h, int32_t w);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010066
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010067 /** Set width */
68 TileInfo &width(int32_t w);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010069
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010070 /** Get width */
71 int32_t width() const;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010072
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010073 /** Set height */
74 TileInfo &height(int32_t h);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010075
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010076 /** Get height */
77 int32_t height() const;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010078
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010079 /** Set data type */
80 TileInfo &data_type(DataType dt);
Nikolaj Jensenacea4072023-07-03 09:44:42 +010081
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010082 /** Get data type */
83 DataType data_type() const;
84
85private:
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010086 DataType _dt{DataType::Unknown};
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010087 TileShape _shape{};
88};
89
90} // namespace ckw
91
92#endif /* COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO_H */