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_CODE_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_SHADER_CODE_H_
18 
19 #include <string>
20 #include <vector>
21 
22 #include "tensorflow/lite/delegates/gpu/common/model.h"
23 #include "tensorflow/lite/delegates/gpu/common/types.h"
24 #include "tensorflow/lite/delegates/gpu/gl/object.h"
25 #include "tensorflow/lite/delegates/gpu/gl/variable.h"
26 
27 namespace tflite {
28 namespace gpu {
29 namespace gl {
30 
31 struct ShaderCode {
32   ShaderCode() = default;
ShaderCodeShaderCode33   ShaderCode(const std::vector<Variable>& in_parameters,
34              const std::vector<Object>& in_objects, const uint3& in_workload,
35              const uint3& in_recommended_workgroup,
36              const std::string& in_source_code,
37              const std::vector<NodeId>& in_node_indices)
38       : parameters(in_parameters),
39         objects(in_objects),
40         workload(in_workload),
41         recommended_workgroup(in_recommended_workgroup),
42         source_code(in_source_code),
43         node_indices(in_node_indices) {}
44 
45   // A list of uniform parameters to be set.
46   std::vector<Variable> parameters;
47 
48   // A list of objects to bind to opengl program.
49   std::vector<Object> objects;
50 
51   uint3 workload;
52 
53   // operation may specify recommended workgroup size
54   uint3 recommended_workgroup;
55 
56   // Generated source code does not set local size, therefore it needs to be set
57   // elsewhere.
58   std::string source_code;
59 
60   // nodes of the graph that are covered by the shader.
61   std::vector<NodeId> node_indices;
62 };
63 
64 }  // namespace gl
65 }  // namespace gpu
66 }  // namespace tflite
67 
68 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_SHADER_CODE_H_
69