1load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library") 2load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite") 3load( 4 "//tensorflow/core/platform:build_config_root.bzl", 5 "tf_gpu_tests_tags", 6) 7 8package( 9 default_visibility = ["//visibility:public"], 10 licenses = ["notice"], 11) 12 13cc_library( 14 name = "api", 15 srcs = ["api.cc"], 16 hdrs = ["api.h"], 17 deps = [ 18 ":command_queue", 19 ":common_cc_fbs", 20 ":compiler", 21 ":compiler_options", 22 ":gl_call", 23 ":request_gpu_info", 24 ":node_shader", 25 ":object", 26 ":object_manager", 27 ":portable", 28 ":runtime", 29 ":runtime_options", 30 ":stats", 31 ":variable", 32 "@com_google_absl//absl/container:flat_hash_map", 33 "@com_google_absl//absl/memory", 34 "@com_google_absl//absl/strings", 35 "//tensorflow/lite/delegates/gpu/common:model", 36 "//tensorflow/lite/delegates/gpu/common:status", 37 "//tensorflow/lite/delegates/gpu/common:types", 38 "//tensorflow/lite/delegates/gpu/common:util", 39 "//tensorflow/lite/delegates/gpu/gl/workgroups:calculator", 40 ] + select({ 41 "//tensorflow/lite/delegates/gpu:tflite_gpu_binary_release": [], 42 "//conditions:default": [ 43 ":serialization", 44 ], 45 }), 46) 47 48cc_library( 49 name = "api2", 50 srcs = ["api2.cc"], 51 hdrs = ["api2.h"], 52 deps = [ 53 ":command_queue", 54 ":compiler", 55 ":egl_environment", 56 ":gl_call", 57 ":object", 58 ":portable", 59 ":request_gpu_info", 60 ":runtime", 61 ":variable", 62 "//tensorflow/lite/delegates/gpu:api", 63 "//tensorflow/lite/delegates/gpu/common:data_type", 64 "//tensorflow/lite/delegates/gpu/common:model", 65 "//tensorflow/lite/delegates/gpu/common:status", 66 "//tensorflow/lite/delegates/gpu/common:tensor", 67 "//tensorflow/lite/delegates/gpu/gl/kernels:converter", 68 "//tensorflow/lite/delegates/gpu/gl/kernels:registry", 69 "//tensorflow/lite/delegates/gpu/gl/workgroups:default_calculator", 70 "@com_google_absl//absl/container:flat_hash_map", 71 "@com_google_absl//absl/memory", 72 "@com_google_absl//absl/types:span", 73 ], 74) 75 76cc_library( 77 name = "command_queue", 78 srcs = ["command_queue.cc"], 79 hdrs = ["command_queue.h"], 80 deps = [ 81 ":gl_call", 82 ":gl_program", 83 ":gl_sync", 84 ":portable", 85 "//tensorflow/lite/delegates/gpu/common:gpu_info", 86 "//tensorflow/lite/delegates/gpu/common:status", 87 "//tensorflow/lite/delegates/gpu/common:types", 88 "@com_google_absl//absl/memory", 89 ], 90) 91 92flatbuffer_cc_library( 93 name = "common_cc_fbs", 94 srcs = ["common.fbs"], 95) 96 97# Generic schema for inference on GPU device. 98flatbuffer_cc_library( 99 name = "compiled_model_cc_fbs", 100 srcs = ["compiled_model.fbs"], 101 flatc_args = [ 102 "--scoped-enums", 103 ], 104 includes = [ 105 ":common_cc_fbs_includes", 106 ], 107) 108 109cc_library( 110 name = "compiler", 111 srcs = ["compiler.cc"], 112 hdrs = ["compiler.h"], 113 deps = [ 114 ":compiler_options", 115 ":float16_conversions", 116 ":node_shader", 117 "//tensorflow/lite/delegates/gpu/common:data_type", 118 "//tensorflow/lite/delegates/gpu/common:gpu_info", 119 "//tensorflow/lite/delegates/gpu/common:model", 120 "//tensorflow/lite/delegates/gpu/common:model_transformer", 121 "//tensorflow/lite/delegates/gpu/common:operations", 122 "//tensorflow/lite/delegates/gpu/common:status", 123 "//tensorflow/lite/delegates/gpu/common:types", 124 "//tensorflow/lite/delegates/gpu/gl/compiler:compiled_node", 125 "//tensorflow/lite/delegates/gpu/gl/compiler:fuse_auto_input", 126 "//tensorflow/lite/delegates/gpu/gl/compiler:fuse_inline", 127 "//tensorflow/lite/delegates/gpu/gl/compiler:fuse_inplace", 128 "//tensorflow/lite/delegates/gpu/gl/compiler:shader_code", 129 "//tensorflow/lite/delegates/gpu/gl/compiler:shader_codegen", 130 "@com_google_absl//absl/container:flat_hash_map", 131 "@com_google_absl//absl/memory", 132 "@com_google_absl//absl/types:any", 133 ], 134) 135 136cc_library( 137 name = "compiler_options", 138 hdrs = ["compiler_options.h"], 139 deps = [ 140 ":object", 141 ], 142) 143 144cc_library( 145 name = "egl_context", 146 srcs = ["egl_context.cc"], 147 hdrs = ["egl_context.h"], 148 deps = [ 149 ":gl_call", 150 ":gl_errors", 151 ":portable", 152 "//tensorflow/lite/delegates/gpu/common:status", 153 ], 154) 155 156cc_library( 157 name = "egl_environment", 158 srcs = ["egl_environment.cc"], 159 hdrs = ["egl_environment.h"], 160 deps = [ 161 ":egl_context", 162 ":egl_surface", 163 ":gl_call", 164 ":portable", 165 ":request_gpu_info", 166 "//tensorflow/lite/delegates/gpu/common:status", 167 "@com_google_absl//absl/memory", 168 ], 169) 170 171cc_library( 172 name = "egl_surface", 173 srcs = ["egl_surface.cc"], 174 hdrs = ["egl_surface.h"], 175 deps = [ 176 ":gl_call", 177 ":gl_errors", 178 ":portable", 179 "//tensorflow/lite/delegates/gpu/common:status", 180 ], 181) 182 183cc_library( 184 name = "float16_conversions", 185 srcs = ["float16_conversions.cc"], 186 hdrs = ["float16_conversions.h"], 187 deps = [ 188 ":object", 189 "//tensorflow/lite/delegates/gpu/common:data_type", 190 "//tensorflow/lite/delegates/gpu/common:tensor", 191 "@FP16", 192 "@com_google_absl//absl/types:variant", 193 ], 194) 195 196cc_library( 197 name = "gl_buffer", 198 srcs = ["gl_buffer.cc"], 199 hdrs = ["gl_buffer.h"], 200 deps = [ 201 ":gl_call", 202 ":gl_errors", 203 ":portable", 204 "//tensorflow/lite/delegates/gpu/common:status", 205 "@com_google_absl//absl/types:span", 206 ], 207) 208 209cc_test( 210 name = "gl_buffer_test", 211 srcs = ["gl_buffer_test.cc"], 212 linkopts = [ 213 "-lEGL", 214 "-lGLESv2", 215 ], 216 tags = tf_gpu_tests_tags() + [ 217 "local", 218 "nobuilder", 219 "notap", 220 "tflite_not_portable_ios", 221 ], 222 deps = [ 223 ":egl_environment", 224 ":gl_buffer", 225 "//tensorflow/lite/delegates/gpu/common:status", 226 "@com_google_googletest//:gtest_main", 227 ], 228) 229 230cc_library( 231 name = "gl_call", 232 hdrs = ["gl_call.h"], 233 deps = [ 234 ":gl_errors", 235 "//tensorflow/lite/delegates/gpu/common:status", 236 ], 237) 238 239cc_library( 240 name = "gl_errors", 241 srcs = ["gl_errors.cc"], 242 hdrs = ["gl_errors.h"], 243 deps = [ 244 ":portable", 245 "//tensorflow/lite/delegates/gpu/common:status", 246 "@com_google_absl//absl/strings", 247 ], 248) 249 250cc_library( 251 name = "gl_program", 252 srcs = ["gl_program.cc"], 253 hdrs = ["gl_program.h"], 254 deps = [ 255 ":gl_call", 256 ":gl_errors", 257 ":gl_shader", 258 ":portable", 259 ":variable", 260 "//tensorflow/lite/delegates/gpu/common:status", 261 "//tensorflow/lite/delegates/gpu/common:types", 262 "@com_google_absl//absl/types:variant", 263 ], 264) 265 266cc_library( 267 name = "gl_shader", 268 srcs = ["gl_shader.cc"], 269 hdrs = ["gl_shader.h"], 270 deps = [ 271 ":gl_call", 272 ":gl_errors", 273 ":portable", 274 "//tensorflow/lite/delegates/gpu/common:status", 275 ], 276) 277 278cc_library( 279 name = "gl_texture", 280 srcs = ["gl_texture.cc"], 281 hdrs = ["gl_texture.h"], 282 deps = [ 283 ":gl_call", 284 ":gl_errors", 285 ":gl_texture_helper", 286 ":portable", 287 "//tensorflow/lite/delegates/gpu/common:data_type", 288 "//tensorflow/lite/delegates/gpu/common:status", 289 "//tensorflow/lite/delegates/gpu/common:tensor", 290 "//tensorflow/lite/delegates/gpu/common:types", 291 "@com_google_absl//absl/types:span", 292 ], 293) 294 295cc_library( 296 name = "gl_texture_helper", 297 srcs = ["gl_texture_helper.cc"], 298 hdrs = ["gl_texture_helper.h"], 299 deps = [ 300 ":portable", 301 "//tensorflow/lite/delegates/gpu/common:data_type", 302 ], 303) 304 305cc_library( 306 name = "gl_sync", 307 srcs = ["gl_sync.cc"], 308 hdrs = ["gl_sync.h"], 309 deps = [ 310 ":gl_buffer", 311 ":gl_call", 312 ":gl_errors", 313 ":gl_program", 314 ":portable", 315 "//tensorflow/lite/delegates/gpu/common:status", 316 ], 317) 318 319flatbuffer_cc_library( 320 name = "metadata_cc_fbs", 321 srcs = ["metadata.fbs"], 322 includes = [ 323 ":common_cc_fbs_includes", 324 ":workgroups_cc_fbs_includes", 325 ], 326) 327 328cc_library( 329 name = "node_shader", 330 hdrs = ["node_shader.h"], 331 deps = [ 332 ":compiler_options", 333 ":object", 334 ":variable", 335 "//tensorflow/lite/delegates/gpu/common:gpu_info", 336 "//tensorflow/lite/delegates/gpu/common:model", 337 "//tensorflow/lite/delegates/gpu/common:status", 338 "//tensorflow/lite/delegates/gpu/common:types", 339 "@com_google_absl//absl/types:any", 340 ], 341) 342 343cc_library( 344 name = "object", 345 hdrs = ["object.h"], 346 deps = [ 347 "//tensorflow/lite/delegates/gpu/common:access_type", 348 "//tensorflow/lite/delegates/gpu/common:data_type", 349 "//tensorflow/lite/delegates/gpu/common:shape", 350 "//tensorflow/lite/delegates/gpu/common:types", 351 "//tensorflow/lite/delegates/gpu/common:util", 352 "@com_google_absl//absl/types:variant", 353 ], 354) 355 356cc_library( 357 name = "object_manager", 358 srcs = ["object_manager.cc"], 359 hdrs = ["object_manager.h"], 360 deps = [ 361 ":gl_buffer", 362 ":gl_texture", 363 ":stats", 364 "//tensorflow/lite/delegates/gpu/common:convert", 365 "//tensorflow/lite/delegates/gpu/common:model", 366 "//tensorflow/lite/delegates/gpu/common:status", 367 "@com_google_absl//absl/memory", 368 "@com_google_absl//absl/types:span", 369 ], 370) 371 372cc_library( 373 name = "portable", 374 hdrs = [ 375 "portable_egl.h", 376 "portable_gl31.h", 377 ], 378) 379 380cc_library( 381 name = "request_gpu_info", 382 srcs = ["request_gpu_info.cc"], 383 hdrs = ["request_gpu_info.h"], 384 deps = [ 385 ":gl_errors", 386 ":portable", 387 "//tensorflow/lite/delegates/gpu/common:gpu_info", 388 "//tensorflow/lite/delegates/gpu/common:status", 389 "@com_google_absl//absl/strings", 390 ], 391) 392 393cc_library( 394 name = "runtime", 395 srcs = ["runtime.cc"], 396 hdrs = ["runtime.h"], 397 deps = [ 398 ":command_queue", 399 ":gl_buffer", 400 ":gl_call", 401 ":gl_errors", 402 ":gl_program", 403 ":gl_shader", 404 ":gl_texture", 405 ":object", 406 ":object_manager", 407 ":portable", 408 ":runtime_options", 409 ":stats", 410 ":variable", 411 "//tensorflow/lite/delegates/gpu/common:data_type", 412 "//tensorflow/lite/delegates/gpu/common:gpu_info", 413 "//tensorflow/lite/delegates/gpu/common:memory_management", 414 "//tensorflow/lite/delegates/gpu/common:status", 415 "//tensorflow/lite/delegates/gpu/common:types", 416 "//tensorflow/lite/delegates/gpu/gl/runtime:shared_buffer", 417 "@com_google_absl//absl/status", 418 "@com_google_absl//absl/strings", 419 ], 420) 421 422cc_library( 423 name = "runtime_options", 424 hdrs = ["runtime_options.h"], 425) 426 427cc_library( 428 name = "serialization", 429 srcs = ["serialization.cc"], 430 hdrs = ["serialization.h"], 431 deps = [ 432 ":common_cc_fbs", 433 ":compiled_model_cc_fbs", 434 ":object", 435 ":variable", 436 "//tensorflow/lite/delegates/gpu/common:data_type", 437 "//tensorflow/lite/delegates/gpu/common:status", 438 "//tensorflow/lite/delegates/gpu/common:types", 439 "@com_google_absl//absl/types:span", 440 "@com_google_absl//absl/types:variant", 441 "@flatbuffers", 442 ], 443) 444 445cc_test( 446 name = "serialization_test", 447 srcs = ["serialization_test.cc"], 448 tags = [ 449 "local", 450 "nobuilder", 451 "notap", 452 "tflite_not_portable_ios", 453 ], 454 deps = [ 455 ":object", 456 ":serialization", 457 ":variable", 458 "//tensorflow/lite/delegates/gpu/common:shape", 459 "//tensorflow/lite/delegates/gpu/common:status", 460 "//tensorflow/lite/delegates/gpu/common:types", 461 "@com_google_absl//absl/types:span", 462 "@com_google_googletest//:gtest_main", 463 ], 464) 465 466cc_library( 467 name = "stats", 468 hdrs = ["stats.h"], 469 deps = [ 470 "@com_google_absl//absl/strings", 471 ], 472) 473 474cc_library( 475 name = "variable", 476 hdrs = ["variable.h"], 477 deps = [ 478 "//tensorflow/lite/delegates/gpu/common:types", 479 "@com_google_absl//absl/types:variant", 480 ], 481) 482 483flatbuffer_cc_library( 484 name = "workgroups_cc_fbs", 485 srcs = ["workgroups.fbs"], 486 includes = [ 487 ":common_cc_fbs_includes", 488 ], 489) 490 491tflite_portable_test_suite() 492