TFLite GPU Delegate: Extract GpuInfo structure into separate translation module.

PiperOrigin-RevId: 262480689
This commit is contained in:
A. Unique TensorFlower 2019-08-08 19:15:47 -07:00 committed by TensorFlower Gardener
parent fcfca65651
commit 9c04d7c00e
35 changed files with 185 additions and 110 deletions

View File

@ -52,6 +52,7 @@ cc_library(
"//tensorflow/lite/delegates/gpu/gl:command_queue", "//tensorflow/lite/delegates/gpu/gl:command_queue",
"//tensorflow/lite/delegates/gpu/gl:compiler", "//tensorflow/lite/delegates/gpu/gl:compiler",
"//tensorflow/lite/delegates/gpu/gl:egl_environment", "//tensorflow/lite/delegates/gpu/gl:egl_environment",
"//tensorflow/lite/delegates/gpu/gl:request_gpu_info",
"//tensorflow/lite/delegates/gpu/gl:gl_call", "//tensorflow/lite/delegates/gpu/gl:gl_call",
"//tensorflow/lite/delegates/gpu/gl/converters:bhwc_to_phwc4", "//tensorflow/lite/delegates/gpu/gl/converters:bhwc_to_phwc4",
"//tensorflow/lite/delegates/gpu/gl/converters:phwc4_to_bhwc", "//tensorflow/lite/delegates/gpu/gl/converters:phwc4_to_bhwc",

View File

@ -24,6 +24,15 @@ cc_library(
hdrs = ["access_type.h"], hdrs = ["access_type.h"],
) )
cc_library(
name = "gpu_info",
srcs = ["gpu_info.cc"],
hdrs = ["gpu_info.h"],
deps = [
"@com_google_absl//absl/strings",
],
)
cc_library( cc_library(
name = "data_type", name = "data_type",
srcs = ["data_type.cc"], srcs = ["data_type.cc"],

View File

@ -13,19 +13,16 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==============================================================================*/ ==============================================================================*/
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h" #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <string> #include <string>
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_errors.h"
#include "tensorflow/lite/delegates/gpu/gl/portable_gl31.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {
namespace gl {
namespace { namespace {
GpuType GetGpuType(const std::string& renderer) { GpuType GetGpuType(const std::string& renderer) {
@ -102,54 +99,5 @@ void GetGpuModelAndType(const std::string& renderer, GpuModel* gpu_model,
*gpu_type == GpuType::ADRENO ? GetGpuModel(lowered) : GpuModel::UNKNOWN; *gpu_type == GpuType::ADRENO ? GetGpuModel(lowered) : GpuModel::UNKNOWN;
} }
Status RequestGpuInfo(GpuInfo* gpu_info) {
GpuInfo info;
const GLubyte* renderer_name = glGetString(GL_RENDERER);
if (renderer_name) {
info.renderer_name = reinterpret_cast<const char*>(renderer_name);
GetGpuModelAndType(info.renderer_name, &info.gpu_model, &info.type);
}
const GLubyte* vendor_name = glGetString(GL_VENDOR);
if (vendor_name) {
info.vendor_name = reinterpret_cast<const char*>(vendor_name);
}
const GLubyte* version_name = glGetString(GL_VERSION);
if (version_name) {
info.version = reinterpret_cast<const char*>(version_name);
}
glGetIntegerv(GL_MAJOR_VERSION, &info.major_version);
glGetIntegerv(GL_MINOR_VERSION, &info.minor_version);
GLint extensions_count;
glGetIntegerv(GL_NUM_EXTENSIONS, &extensions_count);
info.extensions.resize(extensions_count);
for (int i = 0; i < extensions_count; ++i) {
info.extensions[i] = std::string(
reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i)));
}
glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &info.max_ssbo_bindings);
glGetIntegerv(GL_MAX_COMPUTE_IMAGE_UNIFORMS, &info.max_image_bindings);
info.max_work_group_size.resize(3);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0,
&info.max_work_group_size[0]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1,
&info.max_work_group_size[1]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2,
&info.max_work_group_size[2]);
glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS,
&info.max_work_group_invocations);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &info.max_texture_size);
glGetIntegerv(GL_MAX_IMAGE_UNITS, &info.max_image_units);
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &info.max_array_texture_layers);
RETURN_IF_ERROR(GetOpenGlErrors());
*gpu_info = info;
return OkStatus();
}
} // namespace gl
} // namespace gpu } // namespace gpu
} // namespace tflite } // namespace tflite

View File

@ -13,17 +13,14 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==============================================================================*/ ==============================================================================*/
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_GPU_INFO_H_ #ifndef TENSORFLOW_LITE_DELEGATES_GPU_COMMON_GPU_INFO_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_GL_GPU_INFO_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_GPU_INFO_H_
#include <string> #include <string>
#include <vector> #include <vector>
#include "tensorflow/lite/delegates/gpu/common/status.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {
namespace gl {
enum class GpuType { UNKNOWN, MALI, ADRENO, POWERVR, INTEL, NVIDIA }; enum class GpuType { UNKNOWN, MALI, ADRENO, POWERVR, INTEL, NVIDIA };
enum class GpuModel { enum class GpuModel {
@ -89,12 +86,7 @@ struct GpuInfo {
void GetGpuModelAndType(const std::string& renderer, GpuModel* gpu_model, void GetGpuModelAndType(const std::string& renderer, GpuModel* gpu_model,
GpuType* gpu_type); GpuType* gpu_type);
// This method performs multiple GL calls, therefore, egl context needs to be
// created upfront.
Status RequestGpuInfo(GpuInfo* gpu_info);
} // namespace gl
} // namespace gpu } // namespace gpu
} // namespace tflite } // namespace tflite
#endif // TENSORFLOW_LITE_DELEGATES_GPU_GL_GPU_INFO_H_ #endif // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_GPU_INFO_H_

View File

@ -16,7 +16,7 @@ cc_library(
":compiler", ":compiler",
":compiler_options", ":compiler_options",
":gl_call", ":gl_call",
":gpu_info", ":request_gpu_info",
":node_shader", ":node_shader",
":object", ":object",
":object_manager", ":object_manager",
@ -48,8 +48,8 @@ cc_library(
":gl_call", ":gl_call",
":gl_program", ":gl_program",
":gl_sync", ":gl_sync",
":gpu_info",
":portable", ":portable",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/common:types", "//tensorflow/lite/delegates/gpu/common:types",
"@com_google_absl//absl/memory", "@com_google_absl//absl/memory",
@ -80,9 +80,9 @@ cc_library(
deps = [ deps = [
":compiler_options", ":compiler_options",
":float16_conversions", ":float16_conversions",
":gpu_info",
":node_shader", ":node_shader",
"//tensorflow/lite/delegates/gpu/common:data_type", "//tensorflow/lite/delegates/gpu/common:data_type",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:model", "//tensorflow/lite/delegates/gpu/common:model",
"//tensorflow/lite/delegates/gpu/common:model_transformer", "//tensorflow/lite/delegates/gpu/common:model_transformer",
"//tensorflow/lite/delegates/gpu/common:operations", "//tensorflow/lite/delegates/gpu/common:operations",
@ -103,7 +103,6 @@ cc_library(
name = "compiler_options", name = "compiler_options",
hdrs = ["compiler_options.h"], hdrs = ["compiler_options.h"],
deps = [ deps = [
":gpu_info",
":object", ":object",
], ],
) )
@ -128,8 +127,8 @@ cc_library(
":egl_context", ":egl_context",
":egl_surface", ":egl_surface",
":gl_call", ":gl_call",
":gpu_info",
":portable", ":portable",
":request_gpu_info",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"@com_google_absl//absl/memory", "@com_google_absl//absl/memory",
], ],
@ -272,18 +271,6 @@ cc_library(
], ],
) )
cc_library(
name = "gpu_info",
srcs = ["gpu_info.cc"],
hdrs = ["gpu_info.h"],
deps = [
":gl_errors",
":portable",
"//tensorflow/lite/delegates/gpu/common:status",
"@com_google_absl//absl/strings",
],
)
flatbuffer_cc_library( flatbuffer_cc_library(
name = "metadata_cc_fbs", name = "metadata_cc_fbs",
srcs = ["metadata.fbs"], srcs = ["metadata.fbs"],
@ -298,9 +285,9 @@ cc_library(
hdrs = ["node_shader.h"], hdrs = ["node_shader.h"],
deps = [ deps = [
":compiler_options", ":compiler_options",
":gpu_info",
":object", ":object",
":variable", ":variable",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:model", "//tensorflow/lite/delegates/gpu/common:model",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/common:types", "//tensorflow/lite/delegates/gpu/common:types",
@ -344,6 +331,19 @@ cc_library(
], ],
) )
cc_library(
name = "request_gpu_info",
srcs = ["request_gpu_info.cc"],
hdrs = ["request_gpu_info.h"],
deps = [
":gl_errors",
":portable",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:status",
"@com_google_absl//absl/strings",
],
)
cc_library( cc_library(
name = "runtime", name = "runtime",
srcs = ["runtime.cc"], srcs = ["runtime.cc"],
@ -356,7 +356,6 @@ cc_library(
":gl_program", ":gl_program",
":gl_shader", ":gl_shader",
":gl_texture", ":gl_texture",
":gpu_info",
":object", ":object",
":object_manager", ":object_manager",
":portable", ":portable",
@ -364,6 +363,7 @@ cc_library(
":stats", ":stats",
":variable", ":variable",
"//tensorflow/lite/delegates/gpu/common:data_type", "//tensorflow/lite/delegates/gpu/common:data_type",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/common:types", "//tensorflow/lite/delegates/gpu/common:types",
"//tensorflow/lite/delegates/gpu/gl/runtime:shared_buffer", "//tensorflow/lite/delegates/gpu/gl/runtime:shared_buffer",

View File

@ -31,9 +31,9 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/common/util.h" #include "tensorflow/lite/delegates/gpu/common/util.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler.h" #include "tensorflow/lite/delegates/gpu/gl/compiler.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_call.h" #include "tensorflow/lite/delegates/gpu/gl/gl_call.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/object.h" #include "tensorflow/lite/delegates/gpu/gl/object.h"
#include "tensorflow/lite/delegates/gpu/gl/portable_gl31.h" #include "tensorflow/lite/delegates/gpu/gl/portable_gl31.h"
#include "tensorflow/lite/delegates/gpu/gl/request_gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/runtime.h" #include "tensorflow/lite/delegates/gpu/gl/runtime.h"
#include "tensorflow/lite/delegates/gpu/gl/variable.h" #include "tensorflow/lite/delegates/gpu/gl/variable.h"

View File

@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/gl/command_queue.h" #include "tensorflow/lite/delegates/gpu/gl/command_queue.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_call.h" #include "tensorflow/lite/delegates/gpu/gl/gl_call.h"

View File

@ -18,10 +18,10 @@ limitations under the License.
#include <memory> #include <memory>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_program.h" #include "tensorflow/lite/delegates/gpu/gl/gl_program.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {

View File

@ -24,6 +24,7 @@ limitations under the License.
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/types/any.h" #include "absl/types/any.h"
#include "tensorflow/lite/delegates/gpu/common/data_type.h" #include "tensorflow/lite/delegates/gpu/common/data_type.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/model_transformer.h" #include "tensorflow/lite/delegates/gpu/common/model_transformer.h"
#include "tensorflow/lite/delegates/gpu/common/operations.h" #include "tensorflow/lite/delegates/gpu/common/operations.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"

View File

@ -20,11 +20,11 @@ limitations under the License.
#include <memory> #include <memory>
#include <unordered_set> #include <unordered_set>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/model.h" #include "tensorflow/lite/delegates/gpu/common/model.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler_options.h" #include "tensorflow/lite/delegates/gpu/gl/compiler_options.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/node_shader.h" #include "tensorflow/lite/delegates/gpu/gl/node_shader.h"
namespace tflite { namespace tflite {

View File

@ -81,10 +81,10 @@ cc_library(
":preprocessor", ":preprocessor",
":shader_code", ":shader_code",
":variable_accessor", ":variable_accessor",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:model", "//tensorflow/lite/delegates/gpu/common:model",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/gl:compiler_options", "//tensorflow/lite/delegates/gpu/gl:compiler_options",
"//tensorflow/lite/delegates/gpu/gl:gpu_info",
"//tensorflow/lite/delegates/gpu/gl:object", "//tensorflow/lite/delegates/gpu/gl:object",
"//tensorflow/lite/delegates/gpu/gl:variable", "//tensorflow/lite/delegates/gpu/gl:variable",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",

View File

@ -18,6 +18,7 @@ limitations under the License.
#include <algorithm> #include <algorithm>
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/preprocessor.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/preprocessor.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/variable_accessor.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/variable_accessor.h"

View File

@ -19,13 +19,13 @@ limitations under the License.
#include <string> #include <string>
#include <vector> #include <vector>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/model.h" #include "tensorflow/lite/delegates/gpu/common/model.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/compiled_node.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/compiled_node.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/object_accessor.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/object_accessor.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler_options.h" #include "tensorflow/lite/delegates/gpu/gl/compiler_options.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/object.h" #include "tensorflow/lite/delegates/gpu/gl/object.h"
namespace tflite { namespace tflite {

View File

@ -16,7 +16,6 @@ limitations under the License.
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_OPTIONS_H_ #ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_OPTIONS_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_OPTIONS_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_GL_COMPILER_OPTIONS_H_
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/object.h" #include "tensorflow/lite/delegates/gpu/gl/object.h"
namespace tflite { namespace tflite {

View File

@ -18,6 +18,7 @@ limitations under the License.
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_call.h" #include "tensorflow/lite/delegates/gpu/gl/gl_call.h"
#include "tensorflow/lite/delegates/gpu/gl/request_gpu_info.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {

View File

@ -21,9 +21,9 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/gl/egl_context.h" #include "tensorflow/lite/delegates/gpu/gl/egl_context.h"
#include "tensorflow/lite/delegates/gpu/gl/egl_surface.h" #include "tensorflow/lite/delegates/gpu/gl/egl_surface.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/portable_egl.h" #include "tensorflow/lite/delegates/gpu/gl/portable_egl.h"
#include "tensorflow/lite/delegates/gpu/gl/portable_gl31.h" #include "tensorflow/lite/delegates/gpu/gl/portable_gl31.h"
#include "tensorflow/lite/delegates/gpu/gl/request_gpu_info.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {

View File

@ -582,9 +582,9 @@ cc_library(
"//tensorflow/lite/delegates/gpu/gl:compiler_options", "//tensorflow/lite/delegates/gpu/gl:compiler_options",
"//tensorflow/lite/delegates/gpu/gl:egl_environment", "//tensorflow/lite/delegates/gpu/gl:egl_environment",
"//tensorflow/lite/delegates/gpu/gl:gl_buffer", "//tensorflow/lite/delegates/gpu/gl:gl_buffer",
"//tensorflow/lite/delegates/gpu/gl:gpu_info",
"//tensorflow/lite/delegates/gpu/gl:node_shader", "//tensorflow/lite/delegates/gpu/gl:node_shader",
"//tensorflow/lite/delegates/gpu/gl:object_manager", "//tensorflow/lite/delegates/gpu/gl:object_manager",
"//tensorflow/lite/delegates/gpu/gl:request_gpu_info",
"//tensorflow/lite/delegates/gpu/gl:runtime_options", "//tensorflow/lite/delegates/gpu/gl:runtime_options",
"//tensorflow/lite/delegates/gpu/gl/workgroups:default_calculator", "//tensorflow/lite/delegates/gpu/gl/workgroups:default_calculator",
"@com_google_googletest//:gtest", "@com_google_googletest//:gtest",

View File

@ -28,8 +28,8 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/gl/api.h" #include "tensorflow/lite/delegates/gpu/gl/api.h"
#include "tensorflow/lite/delegates/gpu/gl/egl_environment.h" #include "tensorflow/lite/delegates/gpu/gl/egl_environment.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_buffer.h" #include "tensorflow/lite/delegates/gpu/gl/gl_buffer.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/object_manager.h" #include "tensorflow/lite/delegates/gpu/gl/object_manager.h"
#include "tensorflow/lite/delegates/gpu/gl/request_gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h"
namespace tflite { namespace tflite {

View File

@ -21,11 +21,11 @@ limitations under the License.
#include <string> #include <string>
#include <vector> #include <vector>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/model.h" #include "tensorflow/lite/delegates/gpu/common/model.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler_options.h" #include "tensorflow/lite/delegates/gpu/gl/compiler_options.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/object.h" #include "tensorflow/lite/delegates/gpu/gl/object.h"
#include "tensorflow/lite/delegates/gpu/gl/variable.h" #include "tensorflow/lite/delegates/gpu/gl/variable.h"

View File

@ -0,0 +1,81 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/lite/delegates/gpu/gl/request_gpu_info.h"
#include <algorithm>
#include <cctype>
#include <string>
#include "absl/strings/ascii.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_errors.h"
#include "tensorflow/lite/delegates/gpu/gl/portable_gl31.h"
namespace tflite {
namespace gpu {
namespace gl {
Status RequestGpuInfo(GpuInfo* gpu_info) {
GpuInfo info;
const GLubyte* renderer_name = glGetString(GL_RENDERER);
if (renderer_name) {
info.renderer_name = reinterpret_cast<const char*>(renderer_name);
GetGpuModelAndType(info.renderer_name, &info.gpu_model, &info.type);
}
const GLubyte* vendor_name = glGetString(GL_VENDOR);
if (vendor_name) {
info.vendor_name = reinterpret_cast<const char*>(vendor_name);
}
const GLubyte* version_name = glGetString(GL_VERSION);
if (version_name) {
info.version = reinterpret_cast<const char*>(version_name);
}
glGetIntegerv(GL_MAJOR_VERSION, &info.major_version);
glGetIntegerv(GL_MINOR_VERSION, &info.minor_version);
GLint extensions_count;
glGetIntegerv(GL_NUM_EXTENSIONS, &extensions_count);
info.extensions.resize(extensions_count);
for (int i = 0; i < extensions_count; ++i) {
info.extensions[i] = std::string(
reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i)));
}
glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &info.max_ssbo_bindings);
glGetIntegerv(GL_MAX_COMPUTE_IMAGE_UNIFORMS, &info.max_image_bindings);
info.max_work_group_size.resize(3);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0,
&info.max_work_group_size[0]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1,
&info.max_work_group_size[1]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2,
&info.max_work_group_size[2]);
glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS,
&info.max_work_group_invocations);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &info.max_texture_size);
glGetIntegerv(GL_MAX_IMAGE_UNITS, &info.max_image_units);
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &info.max_array_texture_layers);
RETURN_IF_ERROR(GetOpenGlErrors());
*gpu_info = info;
return OkStatus();
}
} // namespace gl
} // namespace gpu
} // namespace tflite

View File

@ -0,0 +1,37 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_REQUEST_GPU_INFO_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_GL_REQUEST_GPU_INFO_H_
#include <string>
#include <vector>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/status.h"
namespace tflite {
namespace gpu {
namespace gl {
// This method performs multiple GL calls, therefore, egl context needs to be
// created upfront.
Status RequestGpuInfo(GpuInfo* gpu_info);
} // namespace gl
} // namespace gpu
} // namespace tflite
#endif // TENSORFLOW_LITE_DELEGATES_GPU_GL_REQUEST_GPU_INFO_H_

View File

@ -22,6 +22,7 @@ limitations under the License.
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "tensorflow/lite/delegates/gpu/common/data_type.h" #include "tensorflow/lite/delegates/gpu/common/data_type.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_call.h" #include "tensorflow/lite/delegates/gpu/gl/gl_call.h"

View File

@ -18,13 +18,13 @@ limitations under the License.
#include <vector> #include <vector>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/status.h" #include "tensorflow/lite/delegates/gpu/common/status.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/command_queue.h" #include "tensorflow/lite/delegates/gpu/gl/command_queue.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_buffer.h" #include "tensorflow/lite/delegates/gpu/gl/gl_buffer.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_program.h" #include "tensorflow/lite/delegates/gpu/gl/gl_program.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_shader.h" #include "tensorflow/lite/delegates/gpu/gl/gl_shader.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/object.h" #include "tensorflow/lite/delegates/gpu/gl/object.h"
#include "tensorflow/lite/delegates/gpu/gl/object_manager.h" #include "tensorflow/lite/delegates/gpu/gl/object_manager.h"
#include "tensorflow/lite/delegates/gpu/gl/runtime/shared_buffer.h" #include "tensorflow/lite/delegates/gpu/gl/runtime/shared_buffer.h"

View File

@ -8,8 +8,8 @@ cc_library(
srcs = ["calculator.cc"], srcs = ["calculator.cc"],
hdrs = ["calculator.h"], hdrs = ["calculator.h"],
deps = [ deps = [
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:types", "//tensorflow/lite/delegates/gpu/common:types",
"//tensorflow/lite/delegates/gpu/gl:gpu_info",
"//tensorflow/lite/delegates/gpu/gl/compiler:shader_code", "//tensorflow/lite/delegates/gpu/gl/compiler:shader_code",
], ],
) )
@ -20,8 +20,8 @@ cc_library(
hdrs = ["default_calculator.h"], hdrs = ["default_calculator.h"],
deps = [ deps = [
":calculator", ":calculator",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:types", "//tensorflow/lite/delegates/gpu/common:types",
"//tensorflow/lite/delegates/gpu/gl:gpu_info",
], ],
) )
@ -35,7 +35,7 @@ cc_library(
":default_calculator", ":default_calculator",
"//tensorflow/lite/delegates/gpu/gl:common_cc_fbs", "//tensorflow/lite/delegates/gpu/gl:common_cc_fbs",
"//tensorflow/lite/delegates/gpu/gl:workgroups_cc_fbs", "//tensorflow/lite/delegates/gpu/gl:workgroups_cc_fbs",
"//tensorflow/lite/delegates/gpu/gl:gpu_info", "//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/gl:metadata_cc_fbs", "//tensorflow/lite/delegates/gpu/gl:metadata_cc_fbs",
":calculator", ":calculator",
"@com_google_absl//absl/memory", "@com_google_absl//absl/memory",
@ -52,7 +52,7 @@ cc_library(
deps = [ deps = [
":calculator", ":calculator",
":default_calculator", ":default_calculator",
"//tensorflow/lite/delegates/gpu/gl:gpu_info", "//tensorflow/lite/delegates/gpu/common:gpu_info",
] + select({ ] + select({
"//tensorflow/lite/delegates/gpu:tflite_gpu_binary_release": [], "//tensorflow/lite/delegates/gpu:tflite_gpu_binary_release": [],
"//conditions:default": [ "//conditions:default": [
@ -67,9 +67,9 @@ cc_library(
hdrs = ["ideal_workgroup_picker.h"], hdrs = ["ideal_workgroup_picker.h"],
deps = [ deps = [
":calculator", ":calculator",
"//tensorflow/lite/delegates/gpu/common:gpu_info",
"//tensorflow/lite/delegates/gpu/common:operations", "//tensorflow/lite/delegates/gpu/common:operations",
"//tensorflow/lite/delegates/gpu/common:shape", "//tensorflow/lite/delegates/gpu/common:shape",
"//tensorflow/lite/delegates/gpu/common:types", "//tensorflow/lite/delegates/gpu/common:types",
"//tensorflow/lite/delegates/gpu/gl:gpu_info",
], ],
) )

View File

@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/gl/workgroups/best_effort_calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/best_effort_calculator.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h"

View File

@ -16,7 +16,7 @@ limitations under the License.
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_BEST_EFFORT_CALCULATOR_H_ #ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_BEST_EFFORT_CALCULATOR_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_BEST_EFFORT_CALCULATOR_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_BEST_EFFORT_CALCULATOR_H_
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h" #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"
namespace tflite { namespace tflite {

View File

@ -15,9 +15,9 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {

View File

@ -18,9 +18,9 @@ limitations under the License.
#include <memory> #include <memory>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h" #include "tensorflow/lite/delegates/gpu/gl/compiler/shader_code.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {

View File

@ -20,15 +20,15 @@ limitations under the License.
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
#include "absl/memory/memory.h"
#include "flatbuffers/flatbuffers.h" // TF:flatbuffers
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/metadata_generated.h" #include "tensorflow/lite/delegates/gpu/gl/metadata_generated.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups_generated.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups_generated.h"
#include "absl/memory/memory.h"
#include "flatbuffers/flatbuffers.h" // TF:flatbuffers
#include "tensorflow/lite/delegates/gpu/common/types.h"
#endif // TFLITE_GPU_BINARY_RELEASE #endif // TFLITE_GPU_BINARY_RELEASE
namespace tflite { namespace tflite {

View File

@ -16,7 +16,7 @@ limitations under the License.
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_CALCULATOR_FROM_METADATA_H_ #ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_CALCULATOR_FROM_METADATA_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_CALCULATOR_FROM_METADATA_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_CALCULATOR_FROM_METADATA_H_
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h" #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"
namespace tflite { namespace tflite {

View File

@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/default_calculator.h"
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"

View File

@ -16,7 +16,7 @@ limitations under the License.
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_DEFAULT_CALCULATOR_H_ #ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_DEFAULT_CALCULATOR_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_DEFAULT_CALCULATOR_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_DEFAULT_CALCULATOR_H_
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h" #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"
namespace tflite { namespace tflite {

View File

@ -18,10 +18,10 @@ limitations under the License.
#include <map> #include <map>
#include <vector> #include <vector>
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/operations.h" #include "tensorflow/lite/delegates/gpu/common/operations.h"
#include "tensorflow/lite/delegates/gpu/common/shape.h" #include "tensorflow/lite/delegates/gpu/common/shape.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/calculator.h"
namespace tflite { namespace tflite {

View File

@ -16,10 +16,10 @@ limitations under the License.
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_IDEAL_WORKGROUP_PICKER_H_ #ifndef TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_IDEAL_WORKGROUP_PICKER_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_IDEAL_WORKGROUP_PICKER_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_GL_WORKGROUPS_IDEAL_WORKGROUP_PICKER_H_
#include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
#include "tensorflow/lite/delegates/gpu/common/operations.h" #include "tensorflow/lite/delegates/gpu/common/operations.h"
#include "tensorflow/lite/delegates/gpu/common/shape.h" #include "tensorflow/lite/delegates/gpu/common/shape.h"
#include "tensorflow/lite/delegates/gpu/common/types.h" #include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/gl/gpu_info.h"
namespace tflite { namespace tflite {
namespace gpu { namespace gpu {

View File

@ -43,6 +43,7 @@ limitations under the License.
#include "tensorflow/lite/delegates/gpu/gl/egl_environment.h" #include "tensorflow/lite/delegates/gpu/gl/egl_environment.h"
#include "tensorflow/lite/delegates/gpu/gl/gl_call.h" #include "tensorflow/lite/delegates/gpu/gl/gl_call.h"
#include "tensorflow/lite/delegates/gpu/gl/kernels/registry.h" #include "tensorflow/lite/delegates/gpu/gl/kernels/registry.h"
#include "tensorflow/lite/delegates/gpu/gl/request_gpu_info.h"
#include "tensorflow/lite/delegates/gpu/gl/workgroups/best_effort_calculator.h" #include "tensorflow/lite/delegates/gpu/gl/workgroups/best_effort_calculator.h"
#include "tensorflow/lite/minimal_logging.h" #include "tensorflow/lite/minimal_logging.h"