blob: 86a4b441b782139affaf6a0b6717dcc4135a3491 [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
28#include "ckw/Types.h"
29
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);
51 /** Constructor used to initialize a vector with a given data type and vector length.
52 *
53 * @param[in] dt Tile data type
54 * @param[in] w Tile width (or vector length)
55 */
56 TileInfo(DataType dt, int32_t w);
57 /** Constructor used to initialize a tile with a given data type and tile sizes.
58 *
59 * @param[in] dt Tile data type
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000060 * @param[in] h Tile height
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010061 * @param[in] w Tile width
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000062 */
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010063 TileInfo(DataType dt, int32_t h, int32_t w);
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000064 /** Set width */
65 TileInfo &width(int32_t w);
66 /** Get width */
67 int32_t width() const;
68 /** Set height */
69 TileInfo &height(int32_t h);
70 /** Get height */
71 int32_t height() const;
72 /** Set data type */
73 TileInfo &data_type(DataType dt);
74 /** Get data type */
75 DataType data_type() const;
76
77private:
78 DataType _dt{ DataType::Unknown };
79 TileShape _shape{};
80};
81
82} // namespace ckw
83
Gunes Bayir2ae536a2023-07-05 11:39:37 +010084#endif /* COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO */