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 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_SHADER_CODEGEN_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_SHADER_CODEGEN_H_
18 
19 #include <string>
20 #include <vector>
21 
22 #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
23 #include "tensorflow/lite/delegates/gpu/common/model.h"
24 #include "tensorflow/lite/delegates/gpu/common/status.h"
25 #include "tensorflow/lite/delegates/gpu/gl/compiler/compiled_node.h"
26 #include "tensorflow/lite/delegates/gpu/gl/compiler/object_accessor.h"
27 #include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h"
28 #include "tensorflow/lite/delegates/gpu/gl/compiler_options.h"
29 #include "tensorflow/lite/delegates/gpu/gl/object.h"
30 
31 namespace tflite {
32 namespace gpu {
33 namespace gl {
34 
35 // This class is responsible for assembling a shader by putting together
36 // objects, parameters declarations and main function.
37 class ShaderCodegen {
38  public:
39   ShaderCodegen(const CompilationOptions& options, const GpuInfo& gpu_info);
40 
41   // Builds final program representation.
42   absl::Status Build(CompiledNodeAttributes attr,
43                      ShaderCode* shader_code) const;
44 
45  private:
46   const CompilationOptions options_;
47   const GpuVendor gpu_type_;
48 };
49 
50 }  // namespace gl
51 }  // namespace gpu
52 }  // namespace tflite
53 
54 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_SHADER_CODEGEN_H_
55