Skip to content

Commit

Permalink
Add patch for linux gpu delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
asus4 committed Sep 5, 2023
1 parent 6b7337f commit e961ab5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Scripts/linux-gpu-delegate.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git forkSrcPrefix/tensorflow/lite/delegates/gpu/build_defs.bzl forkDstPrefix/tensorflow/lite/delegates/gpu/build_defs.bzl
index 462ec7c22189685cbca99024e41f594864ef2e1c..a76b4de5c982faf62e6e5bf982e4ff2b21c983d7 100644
--- forkSrcPrefix/tensorflow/lite/delegates/gpu/build_defs.bzl
+++ forkDstPrefix/tensorflow/lite/delegates/gpu/build_defs.bzl
@@ -24,4 +24,4 @@ def gpu_delegate_linkopts():
"-lGLESv2",
],
"//conditions:default": [],
- }) + nativewindow_linkopts()
+ }) # + nativewindow_linkopts()
5 changes: 3 additions & 2 deletions build_tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ def build_linux(enable_xnnpack = True):

# GPU Delegate
# See MediaPipe docs to setup EGL on Linux https://google.github.io/mediapipe/getting_started/gpu_support.html#opengl-es-setup-on-linux-desktop
# Also, you need link EGL and GLESv2 for Linux platform, will make a patch for this
# https://github.com/tensorflow/tensorflow/blob/5850c0ba26745f92456234c34ed258b472f07487/tensorflow/lite/delegates/gpu/build_defs.bzl#L3-L15
# Need to apply patch to build gpu delegate
patch_file = os.path.abspath('Scripts/linux-gpu-delegate.patch')
run_cmd(f'git apply {patch_file}')
run_cmd('bazel build --config=linux -c opt --copt -Os --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 --copt -DCL_TARGET_OPENCL_VERSION=210 --copt -fvisibility=default --linkopt -s --strip always //tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so')
copy('bazel-bin/tensorflow/lite/delegates/gpu/libtensorflowlite_gpu_delegate.so', 'Linux/x86_64/libtensorflowlite_gpu_delegate.so')

Expand Down

0 comments on commit e961ab5

Please sign in to comment.