1// Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15namespace tflite.gpu.data; 16 17table Int4 { 18 x:int32; 19 y:int32; 20 z:int32; 21 w:int32; 22} 23 24table Int3 { 25 x:int32; 26 y:int32; 27 z:int32; 28} 29 30table Int2 { 31 x:int32; 32 y:int32; 33} 34 35enum AccessType : byte { 36 READ = 0, 37 WRITE = 1, 38 READ_WRITE = 2, 39} 40 41table StateVariable { 42 key:string; 43 value:string; 44} 45 46table GPUObjectDescriptor { 47 state_vars:[StateVariable]; 48 access_type:AccessType; 49} 50 51table IntValue { 52 name:string; 53 value:int32; 54 active:bool; 55} 56 57table FloatValue { 58 name:string; 59 value:float; 60 active:bool; 61} 62 63table HalfValue { 64 name:string; 65 value:float; 66 active:bool; 67} 68 69enum DataType : byte { 70 UNKNOWN = 0, 71 FLOAT16 = 1, 72 FLOAT32 = 2, 73 FLOAT64 = 3, 74 UINT8 = 4, 75 INT8 = 5, 76 UINT16 = 6, 77 INT16 = 7, 78 UINT32 = 8, 79 INT32 = 9, 80 UINT64 = 10, 81 INT64 = 11, 82 BOOL = 12, 83} 84 85enum MemoryType : byte { 86 GLOBAL = 0, 87 CONSTANT = 1, 88 LOCAL = 2, 89} 90 91table BufferDescriptor { 92 base_obj:GPUObjectDescriptor; 93 element_type:DataType; 94 element_size:int32; 95 memory_type:MemoryType; 96 attributes:[string]; 97 size:int32; 98 data:[uint8]; 99} 100 101enum TensorStorageType : byte { 102 UNKNOWN = 0, 103 BUFFER = 1, 104 IMAGE_BUFFER = 2, 105 TEXTURE_2D = 3, 106 TEXTURE_3D = 4, 107 TEXTURE_ARRAY = 5, 108 SINGLE_TEXTURE_2D = 6, 109} 110 111enum Layout : byte { 112 UNKNOWN = 0, 113 HWC = 1, 114 BHWC = 2, 115 HWDC = 3, 116 BHWDC = 4, 117 LINEAR = 5, 118 HW = 6, 119} 120 121table BHWDC { 122 b:int32; 123 h:int32; 124 w:int32; 125 d:int32; 126 c:int32; 127} 128 129table TensorDescriptor { 130 base_obj:GPUObjectDescriptor; 131 data_type:DataType; 132 storage_type:TensorStorageType; 133 layout:Layout; 134 shape:BHWDC; 135 data:[uint8]; 136 use_buffer_for_write_only_2d_texture:bool; 137 use_buffer_for_write_only_image_buffer:bool; 138} 139 140table BufferDescriptorMapValue { 141 key:string; 142 value:BufferDescriptor; 143} 144 145table TensorDescriptorMapValue { 146 key:string; 147 value:TensorDescriptor; 148} 149 150table Arguments { 151 int_values:[IntValue]; 152 float_values:[FloatValue]; 153 half_values:[HalfValue]; 154 155 buffer_refs:[BufferDescriptorMapValue]; 156 tensor_refs:[TensorDescriptorMapValue]; 157 158 buffer_objects:[BufferDescriptorMapValue]; 159 tensor_objects:[TensorDescriptorMapValue]; 160} 161 162enum CalculationsPrecision : byte { 163 F32 = 0, 164 F32_F16 = 1, 165 F16 = 2, 166} 167 168enum TensorToGrid : byte { 169 CUSTOM = 0, 170 WB_TO_X_HD_TO_Y_S_TO_Z = 1, 171 WB_TO_X_HD_TO_Y_Z_IS_1 = 2, 172 WB_TO_X_H_TO_Y_D_TO_Z = 3, 173 B_TO_X_Y_IS_1_Z_IS_1 = 4, 174} 175 176enum CompilerOptions : byte { 177 ADRENO_FULL_SIMD_LINE = 0, 178 ADRENO_MORE_WAVES = 1, 179 CL_FAST_RELAXED_MATH = 2, 180 CL_OPT_DISABLE = 3, 181 CL_2_0 = 4, 182 CL_3_0 = 5, 183} 184 185table OperationDef { 186 precision:CalculationsPrecision; 187 src_tensors:[TensorDescriptor]; 188 dst_tensors:[TensorDescriptor]; 189} 190 191table CompilerOption { 192 option:CompilerOptions; 193} 194 195table GPUOperation { 196 arguments:Arguments; 197 code:string; 198 work_group_size:Int3; 199 compiler_options:[CompilerOption]; 200 tensor_to_grid:TensorToGrid; 201 flops:uint64; 202 definition:OperationDef; 203 grid_dimension:int32; 204 work_group_launch_order:Int3; 205 grid_size:Int3; 206 src_tensors_names:[string]; 207 dst_tensors_names:[string]; 208 work_groups_count:Int3; 209} 210