1// Copyright 2019 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 15include "common.fbs"; 16 17namespace tflite.gpu.gl.data; 18 19file_identifier "AFCM"; 20 21file_extension "flow"; 22 23// Encapsulates entire OpenGL program with all necessary dependencies and 24// parameters. 25table Program { 26 // A collection of objects this program refers to. 27 objects:[Object]; 28 29 // Uniform parameters to be set before execution. 30 parameters:[UniformParameter]; 31 32 // Defines the number of work groups. 33 number_workgroups:Uint3; 34 35 // Defines the size of a workgroup. 36 workgroup_size:Uint3; 37 38 // Reference to a shader in this compiled model. 39 shader_index:uint32; 40 41 // Contains binary code that was once created after successful shader 42 // compilation. Normally it is much faster to instantiate a program from 43 // compiled binary. 44 binary:ProgramBinary; 45} 46 47// Compiled binary representation of a program. 48table ProgramBinary { 49 format:uint32; // GLenum 50 51 // Compiled binary shader blob extracted from GL. 52 binary:[ubyte]; 53} 54 55enum ParameterType : byte { 56 INT32 = 0, 57 UINT32 = 1, 58 FLOAT32 = 2, 59 INT32_2 = 3, 60} 61 62enum DataType : byte { 63 UNKNOWN = 0, 64 FLOAT32 = 1, 65 FLOAT16 = 2, 66 INT32 = 3, 67 INT16 = 4, 68} 69 70union DataVariant { 71 DataInt32, 72 DataFloat, 73 DataUint32, 74} 75 76table DataFloat { 77 data:[float]; 78} 79 80table DataInt32 { 81 data:[int32]; 82} 83 84table DataUint32 { 85 data:[uint32]; 86} 87 88table UniformParameter { 89 name:string; 90 91 type:ParameterType; 92 93 // Data is optional. If it is known in advance, it is encoded here, otherwise 94 // a parameter will be set in runtime. 95 data:DataVariant; 96} 97 98enum AccessType : byte { 99 READ = 0, 100 WRITE = 1, 101 READ_WRITE = 2, 102} 103 104enum ObjectType : byte { 105 UNKNOWN = 0, 106 BUFFER = 1, 107 TEXTURE = 2, 108} 109 110union ObjectVariant { 111 ObjectData, 112 ObjectRef, 113} 114 115union ObjectSize { 116 Uint1, 117 Uint2, 118 Uint3, 119} 120 121table Object { 122 access:AccessType; 123 124 binding:uint32; 125 126 data_type:DataType; 127 128 type:ObjectType; 129 130 size:ObjectSize; 131 132 object:ObjectVariant; 133} 134 135// Represents a reference to another object provided by object manager. 136table ObjectRef { 137 // Unique global identifier to be used by an object manager to lookup this 138 // buffer. 139 global_id:uint32; 140} 141 142table ObjectData { 143 data:[uint8]; 144} 145 146// Represents entire model as a collection of programs, inputs and outputs. 147table CompiledModel { 148 parameters:Parameters; 149 150 // A collection of shaders used by programs. 151 shaders:[string]; 152 153 // A collection of programs that need to be executed in the same order. 154 programs:[Program]; 155} 156 157table Parameters { 158 // indicated flow engine version that compiled this model. If engine version 159 // does not match compiled model, then a model need to be recompiled. 160 // version:uint32; // not implemented 161 162 // Could potentially be used to track environment when a model was compiled 163 // and detect whether it was changed and model recompilation is needed. 164 // environment_hash:uint32; // not implemented 165 166 dynamic_batch:bool; 167} 168 169root_type CompiledModel; 170