Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 1 | /* |
| 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 Jensen | 5ff4802 | 2023-06-27 14:13:24 +0100 | [diff] [blame] | 28 | #include "ckw/types/DataType.h" |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 29 | |
| 30 | #include <array> |
| 31 | #include <cstdint> |
| 32 | |
| 33 | namespace ckw |
| 34 | { |
| 35 | // Constants to access the tile width and height in the TileShape |
| 36 | constexpr int32_t kTileWidthIdx = 0; |
| 37 | constexpr int32_t kTileHeightIdx = 1; |
| 38 | |
| 39 | /** Compute Kernel Writer tile shape. It is used to define the shape of the tile */ |
| 40 | using TileShape = std::array<int32_t, 2>; |
| 41 | |
| 42 | /** Compute Kernel Writer tile info */ |
| 43 | class TileInfo |
| 44 | { |
| 45 | public: |
| 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 Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 51 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 52 | /** 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 Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 58 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 59 | /** 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 Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 66 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 67 | /** Set width */ |
| 68 | TileInfo &width(int32_t w); |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 69 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 70 | /** Get width */ |
| 71 | int32_t width() const; |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 72 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 73 | /** Set height */ |
| 74 | TileInfo &height(int32_t h); |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 75 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 76 | /** Get height */ |
| 77 | int32_t height() const; |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 78 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 79 | /** Set data type */ |
| 80 | TileInfo &data_type(DataType dt); |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 81 | |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 82 | /** Get data type */ |
| 83 | DataType data_type() const; |
| 84 | |
| 85 | private: |
| 86 | DataType _dt{ DataType::Unknown }; |
| 87 | TileShape _shape{}; |
| 88 | }; |
| 89 | |
| 90 | } // namespace ckw |
| 91 | |
| 92 | #endif /* COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO_H */ |