Gunes Bayir | e421167 | 2023-07-25 10:37:13 +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 | |
Gunes Bayir | d5f9a1c | 2023-08-17 11:04:02 +0100 | [diff] [blame] | 25 | #ifndef CKW_INCLUDE_CKW_TYPES_TENSORSAMPLERTYPES_H |
| 26 | #define CKW_INCLUDE_CKW_TYPES_TENSORSAMPLERTYPES_H |
Gunes Bayir | e421167 | 2023-07-25 10:37:13 +0100 | [diff] [blame] | 27 | |
| 28 | #include <cstdint> |
| 29 | |
| 30 | namespace ckw |
| 31 | { |
| 32 | |
| 33 | // This enum class defines how the dimensions of a 3d tensor is mapped into x,y and z coordianates. |
| 34 | enum class TensorSamplerFormat : int32_t |
| 35 | { |
Gunes Bayir | 5e84251 | 2023-07-25 22:32:05 +0100 | [diff] [blame] | 36 | Unknown = 0, |
| 37 | Dim0_Dim1xDim2_1 = 1, // Original dimensions 1 and 2 are collapsed onto y-axis |
| 38 | Dim0_Dim1_Dim2 = 2 // Original dimensions stays as they're defined. No collapsing. |
Gunes Bayir | e421167 | 2023-07-25 10:37:13 +0100 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | /** Tensor sampler address mode enum class for X dimension |
| 42 | * |
| 43 | * The following address modes are available in total: |
| 44 | * Unknown |
| 45 | * None : The user guarantees that the coordinate is always in-bound |
| 46 | * OverlappingMin : (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length |
| 47 | * Leftover elements can be handled using overlapping. This involves processing some of the elements in the array twice. |
| 48 | * ClampToBorderMaxOnly : Clamp to max value allowed in the corresponding dimension, and construct an if/else guard to prevent out of bound access, |
| 49 | * e.g. if( y < size-of-dimension-y ){ <do the operation> } |
Gunes Bayir | d5f9a1c | 2023-08-17 11:04:02 +0100 | [diff] [blame] | 50 | * SkipLessThanZero : Skip loading/storing if the index is less than 0 |
Gunes Bayir | e421167 | 2023-07-25 10:37:13 +0100 | [diff] [blame] | 51 | * |
| 52 | * Individual dimensions choose which adddress mode to implement in their respective enum classes. |
| 53 | */ |
| 54 | enum class TensorSamplerAddressModeX : int32_t |
| 55 | { |
| 56 | Unknown = 0, |
Gunes Bayir | 5e84251 | 2023-07-25 22:32:05 +0100 | [diff] [blame] | 57 | None = 1, |
| 58 | OverlappingMin = 2 |
Gunes Bayir | e421167 | 2023-07-25 10:37:13 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | /** |
| 62 | * Similar to @ref TensorSamplerAddressModeX |
| 63 | */ |
| 64 | enum class TensorSamplerAddressModeY : int32_t |
| 65 | { |
| 66 | Unknown = 0, |
| 67 | None = 1, |
| 68 | OverlappingMin = 2, |
Gunes Bayir | d5f9a1c | 2023-08-17 11:04:02 +0100 | [diff] [blame] | 69 | ClampToBorderMaxOnly = 3, |
| 70 | SkipLessThanZero = 4 |
Gunes Bayir | e421167 | 2023-07-25 10:37:13 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /** |
| 74 | * Similar to @ref TensorSamplerAddressModeX |
| 75 | */ |
| 76 | enum class TensorSamplerAddressModeZ : int32_t |
| 77 | { |
| 78 | Unknown = 0, |
| 79 | None = 1, |
| 80 | }; |
| 81 | |
| 82 | } // namespace ckw |
| 83 | |
Gunes Bayir | d5f9a1c | 2023-08-17 11:04:02 +0100 | [diff] [blame] | 84 | #endif // CKW_INCLUDE_CKW_TYPES_TENSORSAMPLERTYPES_H |