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_TYPES_H |
| 26 | #define CKW_PROTOTYPE_INCLUDE_CKW_TYPES_H |
| 27 | |
| 28 | #include <array> |
| 29 | #include <cstdint> |
| 30 | |
| 31 | namespace ckw |
| 32 | { |
| 33 | |
| 34 | /** Compute Kernel Writer data types. This data type is used by the code variables and tensor arguments. */ |
| 35 | enum class DataType |
| 36 | { |
| 37 | Unknown = 0x00, |
| 38 | Fp32 = 0x11, |
| 39 | Fp16 = 0x12, |
| 40 | Int32 = 0x21, |
| 41 | Int16 = 0x22, |
| 42 | Int8 = 0x24, |
| 43 | Uint32 = 0x31, |
| 44 | Uint16 = 0x32, |
| 45 | Uint8 = 0x34, |
| 46 | Bool = 0x41 |
| 47 | }; |
| 48 | |
| 49 | enum class GpuTargetLanguage |
| 50 | { |
| 51 | Unknown, |
| 52 | OpenCL |
| 53 | }; |
| 54 | |
| 55 | /* Binary operations |
| 56 | */ |
| 57 | enum class BinaryOp : int32_t |
| 58 | { |
| 59 | // Elementwise |
| 60 | Add = 0x0000, // + |
| 61 | Sub = 0x0001, // - |
| 62 | Mul = 0x0002, // * |
| 63 | Div = 0x0003, // / |
| 64 | Mod = 0x0004, // % |
| 65 | // Relational |
| 66 | Equal = 0x1000, // == |
| 67 | Less = 0x1001, // < |
| 68 | LessEqual = 0x1002, // <= |
| 69 | Greater = 0x1003, // > |
| 70 | GreaterEqual = 0x1004, // >= |
| 71 | // Algebra |
| 72 | MatMul_Nt_Nt = 0x2000, // X |
| 73 | MatMul_Nt_T = 0x2001, // X |
| 74 | MatMul_T_Nt = 0x2002, // X |
| 75 | MatMul_T_T = 0x2003, // X |
| 76 | Dot = 0x2004, // . |
| 77 | // Logical |
| 78 | LogicalAnd = 0x3000, // && |
| 79 | LogicalOr = 0x3001, // || |
| 80 | LogicalNot = 0x3002 // ! |
| 81 | }; |
| 82 | |
| 83 | enum class AssignmentOp : int32_t |
| 84 | { |
| 85 | // Unary |
| 86 | Increment = 0x0000, // += |
| 87 | Decrement = 0x0001, // -= |
| 88 | }; |
| 89 | |
| 90 | enum class ScalarUnaryFunction : int32_t |
| 91 | { |
| 92 | Exp, |
| 93 | }; |
| 94 | |
| 95 | enum class TensorSamplerFormat : int32_t |
| 96 | { |
| 97 | Unknown = 0, |
| 98 | C_WH_1 = 1, |
| 99 | C_W_H = 2 |
| 100 | }; |
| 101 | |
| 102 | enum class TensorSamplerAddressModeX : int32_t |
| 103 | { |
| 104 | Unknown = 0, |
| 105 | None = 1, // The user guarantees that the X coordinate is always in-bound |
| 106 | OverlappingMin = 2 // (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length |
| 107 | // Leftover elements can be handled using overlapping. This involves processing some of the elements in the array twice. |
| 108 | }; |
| 109 | |
| 110 | enum class TensorSamplerAddressModeY : int32_t |
| 111 | { |
| 112 | Unknown = 0, |
| 113 | None = 1, // The user guarantees that the Y coordinate is always in-bound |
| 114 | OverlappingMin = 2, // (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length |
| 115 | Skip = 3, // Skip the read/write |
| 116 | SkipMinEdgeOnly = 4, // Skip greater than or equal to max only. The user guarantees that the Y coordinate is always >= 0 |
| 117 | SkipMaxEdgeOnly = 5, // Skip less than 0 only |
| 118 | ClampToNearest = 6, // Clamp the coordinate to nearest edge (0 or max value allowed on Y) |
| 119 | ClampToMinEdgeOnly = 7, // Clamp the negative coordinate to 0 only. Therefore, we expect Y to be always < MAX |
| 120 | ClampToMaxEdgeOnly = 8, // Clamp the coordinate to the max value allowed on Y only. We expect Y to be always >= 0 |
| 121 | ClampToBorder = 9, // Clamp to border which always has 0 value |
| 122 | ClampToBorderMinEdgeOnly = 10, |
| 123 | ClampToBorderMaxEdgeOnly = 11 |
| 124 | }; |
| 125 | |
| 126 | enum class TensorSamplerAddressModeZ : int32_t |
| 127 | { |
| 128 | Unknown = 0, |
| 129 | None = 1, // The user guarantees that the Y coordinate is always in-bound |
| 130 | Skip = 3, // Skip the read/write |
| 131 | SkipMinEdgeOnly = 4, // Skip greater than or equal to max only. The user guarantees that the Y coordinate is always >= 0 |
| 132 | SkipMaxEdgeOnly = 5, // Skip less than 0 only |
| 133 | ClampToNearest = 6, // Clamp the coordinate to nearest edge (0 or max value allowed on Y) |
| 134 | ClampToMinEdgeOnly = 7, // Clamp the negative coordinate to 0 only. Therefore, we expect Y to be always < MAX |
| 135 | ClampToMaxEdgeOnly = 8, // Clamp the coordinate to the max value allowed on Y only. We expect Y to be always >= 0 |
| 136 | }; |
| 137 | |
| 138 | } // namespace ckw |
| 139 | |
| 140 | #endif // CKW_PROTOTYPE_INCLUDE_CKW_TYPES_H |