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_COMMON_GPU_INFO_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_GPU_INFO_H_
18
19 #include <string>
20 #include <vector>
21
22 namespace tflite {
23 namespace gpu {
24
25 enum class GpuType { UNKNOWN, MALI, ADRENO, POWERVR, INTEL, NVIDIA };
26 enum class GpuModel {
27 UNKNOWN,
28 // Adreno 6xx series
29 ADRENO640,
30 ADRENO630,
31 ADRENO616,
32 ADRENO615,
33 ADRENO612,
34 ADRENO605,
35 // Adreno 5xx series
36 ADRENO540,
37 ADRENO530,
38 ADRENO512,
39 ADRENO510,
40 ADRENO509,
41 ADRENO508,
42 ADRENO506,
43 ADRENO505,
44 ADRENO504,
45 // Adreno 4xx series
46 ADRENO430,
47 ADRENO420,
48 ADRENO418,
49 ADRENO405,
50 // Adreno 3xx series
51 ADRENO330,
52 ADRENO320,
53 ADRENO308,
54 ADRENO306,
55 ADRENO305,
56 ADRENO304,
57 // Adreno 2xx series
58 ADRENO225,
59 ADRENO220,
60 ADRENO205,
61 ADRENO203,
62 ADRENO200,
63 // Adreno 1xx series
64 ADRENO130,
65 };
66
67 struct GpuInfo {
68 GpuType type = GpuType::UNKNOWN;
69 std::string renderer_name;
70 std::string vendor_name;
71 std::string version;
72 GpuModel gpu_model;
73 int major_version = -1;
74 int minor_version = -1;
75 std::vector<std::string> extensions;
76 int max_ssbo_bindings = 0;
77 int max_image_bindings = 0;
78 std::vector<int> max_work_group_size;
79 int max_work_group_invocations;
80 int max_texture_size = 0;
81 int max_image_units = 0;
82 int max_array_texture_layers = 0;
83 };
84
IsOpenGl31OrAbove(const GpuInfo & gpu_info)85 inline bool IsOpenGl31OrAbove(const GpuInfo& gpu_info) {
86 return (gpu_info.major_version == 3 && gpu_info.minor_version >= 1) ||
87 gpu_info.major_version > 3;
88 }
89
90 // Analyzes `renderer` and returns matching `GpuType` and `GpuModel`.
91 void GetGpuModelAndType(const std::string& renderer, GpuModel* gpu_model,
92 GpuType* gpu_type);
93
94 } // namespace gpu
95 } // namespace tflite
96
97 #endif // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_GPU_INFO_H_
98