Skip to content

Commit

Permalink
Fix TensorsToSegmentationCalculator gpu dependencies.
Browse files Browse the repository at this point in the history
Fix the dependency that when using Metal, the code should not depend on tensors_to_segmentation_converter_gl_texture (OpenGL 3.0 required).

PiperOrigin-RevId: 599388775
  • Loading branch information
aaronndx authored and copybara-github committed Jan 18, 2024
1 parent 76d5f60 commit a5b714c
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions mediapipe/calculators/tensor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ cc_library(
],
"//conditions:default": [],
}),
features = ["-layering_check"], # allow depending on tensors_to_segmentation_calculator_gpu_deps
deps = [
":tensors_to_segmentation_calculator_cc_proto",
":tensors_to_segmentation_converter",
Expand All @@ -1465,35 +1466,62 @@ cc_library(
"//mediapipe/util:resource_util",
"@com_google_absl//absl/status",
"@org_tensorflow//tensorflow/lite:framework",
] + selects.with_or({
] + select({
"//mediapipe/gpu:disable_gpu": [],
"//conditions:default": [":tensors_to_segmentation_calculator_gpu_deps"],
}) + select({
"//mediapipe/framework/port:disable_opencv": [],
"//conditions:default": [
":tensors_to_segmentation_converter_gl_texture",
":tensors_to_segmentation_converter_opencv",
],
}),
alwayslink = 1,
)

cc_library(
name = "tensors_to_segmentation_calculator_gpu_deps",
visibility = ["//visibility:private"],
deps = selects.with_or({
"//mediapipe:android": [
"@org_tensorflow//tensorflow/lite/delegates/gpu:gl_delegate",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:gl_program",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:gl_shader",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:gl_texture",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl/converters:util",
"//mediapipe/gpu:gl_base_hdr",
"//mediapipe/gpu:gl_calculator_helper",
"//mediapipe/gpu:gl_simple_shaders",
"//mediapipe/gpu:gpu_buffer",
"//mediapipe/gpu:gpu_buffer_format",
"//mediapipe/gpu:shader_util",
],
}) + selects.with_or({
":gpu_inference_disabled": [],
":platform_apple_with_gpu": [
"//mediapipe/gpu:MPPMetalUtil",
"//mediapipe/gpu:MPPMetalHelper",
"//third_party/apple_frameworks:MetalKit",
"//mediapipe/gpu:gl_base_hdr",
"//mediapipe/gpu:gl_calculator_helper",
"//mediapipe/gpu:gl_simple_shaders",
"//mediapipe/gpu:gpu_buffer",
"//mediapipe/gpu:gpu_buffer_format",
"//mediapipe/gpu:shader_util",
],
# This setting is needed to allow bazel to build all targets on Mac with GPU disabled
":platform_apple_without_gpu": [],
"//conditions:default": [
"@org_tensorflow//tensorflow/lite/delegates/gpu:gl_delegate",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:gl_program",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:gl_shader",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:gl_texture",
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl/converters:util",
],
}) + select({
"//mediapipe/framework/port:disable_opencv": [],
"//conditions:default": [
":tensors_to_segmentation_converter_opencv",
"//mediapipe/gpu:gl_base_hdr",
"//mediapipe/gpu:gl_calculator_helper",
"//mediapipe/gpu:gl_simple_shaders",
"//mediapipe/gpu:gpu_buffer",
"//mediapipe/gpu:gpu_buffer_format",
"//mediapipe/gpu:shader_util",
],
}),
alwayslink = 1,
)

cc_library(
Expand Down

0 comments on commit a5b714c

Please sign in to comment.