Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [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 | |
Gunes Bayir | 2ae536a | 2023-07-05 11:39:37 +0100 | [diff] [blame] | 25 | #ifndef COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO |
| 26 | #define COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 27 | |
| 28 | #include "ckw/Types.h" |
| 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 | |
Gian Marco Iodice | 68e9c4d | 2023-06-15 17:40:28 +0100 | [diff] [blame] | 39 | /** Compute Kernel Writer tile shape. It is used to define the shape of the tile */ |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 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); |
| 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 Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 60 | * @param[in] h Tile height |
Viet-Hoa Do | bd4f6b9 | 2023-05-30 09:34:32 +0100 | [diff] [blame] | 61 | * @param[in] w Tile width |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 62 | */ |
Viet-Hoa Do | bd4f6b9 | 2023-05-30 09:34:32 +0100 | [diff] [blame] | 63 | TileInfo(DataType dt, int32_t h, int32_t w); |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 64 | /** 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 | |
| 77 | private: |
| 78 | DataType _dt{ DataType::Unknown }; |
| 79 | TileShape _shape{}; |
| 80 | }; |
| 81 | |
| 82 | } // namespace ckw |
| 83 | |
Gunes Bayir | 2ae536a | 2023-07-05 11:39:37 +0100 | [diff] [blame] | 84 | #endif /* COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEINFO */ |