66 - published
77 workflow_dispatch :
88 inputs :
9- version :
10- description : " Semantic version (e.g., 2.19.0)"
9+ ref :
10+ description : " Commit SHA or tag to build from"
11+ default : " af1d5bc4fbb66d9e6cc1cf89503014a99233583b"
1112 required : true
1213 release :
1314 description : " If true, release the artifact"
@@ -30,9 +31,7 @@ permissions:
3031 contents : write
3132
3233env :
33- VERSION :
34- |- # Enter release tag name or version in workflow_dispatch. Recent version if not specified
35- ${{ github.event.release.tag_name || github.event.inputs.version || '2.19.0' }}
34+ VERSION : ${{ github.ref_name }}
3635 REPOSITORY :
3736 ${{ github.event.inputs.repository || 'tensorflow/tensorflow' }}
3837
@@ -45,35 +44,30 @@ jobs:
4544 include :
4645 - config : android_arm64
4746 artifact_name : tflite-runtime-android-arm64
48- - config : android_arm
49- artifact_name : tflite-runtime-android-arm
50- - config : android_x86_64
51- artifact_name : tflite-runtime-android-x86_64
52- - config : android_fat_aar
53- artifact_name : tflite-runtime-android-fat-aar
5447 env :
5548 ANDROID_SDK_API_LEVEL : 31
5649 ANDROID_NDK_API_LEVEL : 26
5750 ANDROID_BUILD_TOOLS_VERSION : ' 31.0.0'
58- CC : clang-17
59- CXX : clang++-17
60- HERMETIC_PYTHON_VERSION : 3.12
6151 steps :
6252 - uses : actions/checkout@v4
6353 with :
6454 repository : ${{ env.REPOSITORY }}
65- ref : v ${{ env.VERSION }}
55+ ref : ${{ inputs.ref }}
6656 submodules : recursive
6757 github-server-url : https://github.com
58+ - uses : actions/checkout@v4
59+ with :
60+ path : builder
61+ - name : Patch TensorFlow
62+ run : |
63+ patch -d . -p1 < builder/gpudelegate.diff
6864 - uses : bazel-contrib/setup-bazel@0.15.0
6965 - name : Install dependencies
7066 run : |
71- sudo apt-get remove -y gcc g++
72- wget https://apt.llvm.org/llvm.sh
73- chmod u+x llvm.sh
74- sudo ./llvm.sh 17
75- sudo apt-get update
76- sudo apt-get install -y mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev clang-17 llvm-17
67+ pip3 install numpy
68+ - name : Install dependencies
69+ run : |
70+ sudo apt-get install -y mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev
7771 - uses : nttld/setup-ndk@v1
7872 id : setup-ndk
7973 with :
@@ -102,21 +96,6 @@ jobs:
10296 # NNAPI Delegate
10397 # bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 ${{ inputs.xnn_arm_options }} ${{ inputs.xnn_avx_options }} tensorflow/lite/delegates/nnapi:nnapi_delegate
10498 # cp -f bazel-bin/tensorflow/lite/delegates/nnapi/libnnapi_delegate.so artifact
105- - name : Build AAR
106- if : ${{ matrix.config == 'android_fat_aar' }}
107- env :
108- ANDROID_NDK_HOME : ${{ steps.setup-ndk.outputs.ndk-path }}
109- run : |
110- mkdir -p artifact
111- export ANDROID_SDK_HOME=$ANDROID_HOME
112-
113- # Main
114- bazel build -c opt --fat_apk_cpu=arm64-v8a,armeabi-v7a,x86_64 --cxxopt=--std=c++17 ${{ inputs.xnn_arm_options }} ${{ inputs.xnn_avx_options }} --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --define=android_dexmerger_tool=d8_dexmerger --define=android_incremental_dexing_tool=d8_dexbuilder tensorflow/lite/java:tensorflow-lite
115- cp -f bazel-bin/tensorflow/lite/java/tensorflow-lite.aar artifact
116-
117- # GPU Delegate
118- bazel build -c opt --fat_apk_cpu=arm64-v8a,armeabi-v7a,x86_64 --cxxopt=--std=c++17 ${{ inputs.xnn_arm_options }} ${{ inputs.xnn_avx_options }} --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --define=android_dexmerger_tool=d8_dexmerger --define=android_incremental_dexing_tool=d8_dexbuilder tensorflow/lite/java:tensorflow-lite-gpu
119- cp -f bazel-bin/tensorflow/lite/java/tensorflow-lite-gpu.aar artifact
12099 - name : Compress artifact
121100 run : |
122101 mv artifact/ "${{ matrix.artifact_name }}-${{ env.VERSION }}"
@@ -125,221 +104,4 @@ jobs:
125104 if : ${{ inputs.release }}
126105 with :
127106 files : " *.tgz"
128- tag_name : ${{ env.VERSION }}
129-
130- build-ios :
131- runs-on : macos-15
132- strategy :
133- fail-fast : false
134- matrix :
135- include :
136- - config : ios_arm64
137- artifact_name : tflite-runtime-ios-arm64
138- - config : ios_sim_arm64
139- artifact_name : tflite-runtime-ios-sim-arm64
140- - config : ios_x86_64
141- artifact_name : tflite-runtime-ios-sim-x86_64
142- env :
143- HERMETIC_PYTHON_VERSION : 3.12
144- steps :
145- - uses : actions/checkout@v4
146- with :
147- repository : ${{ env.REPOSITORY }}
148- ref : v${{ env.VERSION }}
149- submodules : recursive
150- github-server-url : https://github.com
151- - uses : bazel-contrib/setup-bazel@0.15.0
152- - name : Build runtime
153- run : |
154- mv tensorflow/lite/ios/BUILD.apple tensorflow/lite/ios/BUILD
155- mv tensorflow/lite/objc/BUILD.apple tensorflow/lite/objc/BUILD
156- mv tensorflow/lite/swift/BUILD.apple tensorflow/lite/swift/BUILD
157-
158- mkdir -p artifact
159-
160- # Main
161- bazel build -c opt --config=${{ matrix.config }} ${{ inputs.xnn_avx_options }} --cxxopt=--std=c++17 tensorflow/lite/ios:TensorFlowLiteC_framework
162- unzip -o bazel-bin/tensorflow/lite/ios/TensorFlowLiteC_framework.zip -d artifact
163-
164- # Metal Delegate
165- bazel build -c opt --config=${{ matrix.config }} ${{ inputs.xnn_avx_options }} --cxxopt=--std=c++17 tensorflow/lite/ios:TensorFlowLiteCMetal_framework
166- unzip -o bazel-bin/tensorflow/lite/ios/TensorFlowLiteCMetal_framework.zip -d artifact
167-
168- # CoreML Delegate
169- bazel build -c opt --config=${{ matrix.config }} ${{ inputs.xnn_avx_options }} --cxxopt=--std=c++17 tensorflow/lite/ios:TensorFlowLiteCCoreML_framework
170- unzip -o bazel-bin/tensorflow/lite/ios/TensorFlowLiteCCoreML_framework.zip -d artifact
171-
172- mv artifact/ "${{ matrix.artifact_name }}-${{ env.VERSION }}"
173- 7z a "${{ matrix.artifact_name }}-${{ env.VERSION }}.zip" "${{ matrix.artifact_name }}-${{ env.VERSION }}"
174- - uses : softprops/action-gh-release@v2
175- if : ${{ inputs.release }}
176- with :
177- files : " *.zip"
178- tag_name : ${{ env.VERSION }}
179-
180- build-linux :
181- runs-on : ubuntu-22.04
182- strategy :
183- fail-fast : false
184- matrix :
185- include :
186- - config : linux
187- artifact_name : tflite-runtime-linux-x86_64
188- - config : elinux_aarch64
189- artifact_name : tflite-runtime-linux-arm64
190- env :
191- CC : gcc-12
192- CXX : g++-12
193- HERMETIC_PYTHON_VERSION : 3.12
194- steps :
195- - uses : actions/checkout@v4
196- with :
197- repository : ${{ env.REPOSITORY }}
198- ref : v${{ env.VERSION }}
199- submodules : recursive
200- github-server-url : https://github.com
201- - uses : bazel-contrib/setup-bazel@0.15.0
202- - name : Install dependencies
203- run : |
204- sudo apt-get remove -y gcc g++
205- sudo apt update
206- sudo apt-get install -y mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev gcc-12 g++-12
207- - name : Build runtime
208- run : |
209- mkdir -p artifact
210-
211- bazel build --config=${{ matrix.config }} -c opt --define tflite_with_xnnpack=true ${{ inputs.xnn_avx_options }} tensorflow/lite/c:tensorflowlite_c
212- cp -f bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so artifact
213-
214- mv artifact/ "${{ matrix.artifact_name }}-${{ env.VERSION }}"
215- tar cfz "${{ matrix.artifact_name }}-${{ env.VERSION }}.tgz" "${{ matrix.artifact_name }}-${{ env.VERSION }}"
216- - uses : softprops/action-gh-release@v2
217- if : ${{ inputs.release }}
218- with :
219- files : " *.tgz"
220- tag_name : ${{ env.VERSION }}
221-
222- build-macos :
223- runs-on : ${{ matrix.vm }}
224- strategy :
225- fail-fast : false
226- matrix :
227- include :
228- - config : macos
229- cpu : x86_64
230- artifact_name : tflite-runtime-osx-x86_64
231- vm : macos-13
232- - config : macos_arm64
233- cpu : arm64
234- artifact_name : tflite-runtime-osx-arm64
235- vm : macos-15
236- env :
237- HERMETIC_PYTHON_VERSION : 3.12
238- steps :
239- - uses : actions/checkout@v4
240- with :
241- repository : ${{ env.REPOSITORY }}
242- ref : v${{ env.VERSION }}
243- submodules : recursive
244- github-server-url : https://github.com
245- - uses : bazel-contrib/setup-bazel@0.15.0
246- - name : Install dependencies
247- if : ${{ matrix.vm != 'macos-15' }}
248- shell : bash
249- run : |
250- brew install llvm@17 \
251- && echo 'export PATH="/opt/homebrew/opt/llvm@17/bin:$PATH"' >> /Users/runner/.bash_profile \
252- && source /Users/runner/.bash_profile \
253- && which clang++
254- - name : Build runtime
255- shell : bash
256- run : |
257- mkdir -p artifact
258-
259- # Main
260- bazel build --config=${{ matrix.config }} --macos_cpus=${{ matrix.cpu }} --cxxopt=--std=c++17 ${{ inputs.xnn_avx_options }} -c opt --define tflite_with_xnnpack=true tensorflow/lite/c:tensorflowlite_c
261- cp -f bazel-bin/tensorflow/lite/c/libtensorflowlite_c.dylib artifact
262-
263- # Metal Delegate
264- bazel build --config=${{ matrix.config }} --macos_cpus=${{ matrix.cpu }} --cxxopt=--std=c++17 ${{ inputs.xnn_avx_options }} -c opt --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=default --linkopt -s --strip always tensorflow/lite/delegates/gpu:tensorflow_lite_gpu_dylib
265- cp -f bazel-bin/tensorflow/lite/delegates/gpu/tensorflow_lite_gpu_dylib.dylib artifact/libtensorflowlite_metal_delegate.dylib
266-
267- mv artifact/ "${{ matrix.artifact_name }}-${{ env.VERSION }}"
268- tar cfz "${{ matrix.artifact_name }}-${{ env.VERSION }}.tgz" "${{ matrix.artifact_name }}-${{ env.VERSION }}"
269- - uses : actions/upload-artifact@v4
270- with :
271- name : ${{ matrix.artifact_name }}
272- path : ${{ matrix.artifact_name }}-${{ env.VERSION }}
273- retention-days : 1
274- - uses : softprops/action-gh-release@v2
275- if : ${{ inputs.release }}
276- with :
277- files : " *.tgz"
278- tag_name : ${{ env.VERSION }}
279-
280- build-macos-universal :
281- needs : [build-macos]
282- runs-on : macos-15
283- steps :
284- - uses : actions/download-artifact@v4
285- - name : Build universal binary
286- run : |
287- mkdir -p artifact
288- lipo -create -output artifact/libtensorflowlite_c.dylib "tflite-runtime-osx-x86_64/libtensorflowlite_c.dylib" "tflite-runtime-osx-arm64/libtensorflowlite_c.dylib"
289- lipo -create -output artifact/libtensorflowlite_metal_delegate.dylib "tflite-runtime-osx-x86_64/libtensorflowlite_metal_delegate.dylib" "tflite-runtime-osx-arm64/libtensorflowlite_metal_delegate.dylib"
290- mv artifact/ "tflite-runtime-osx-universal2-${{ env.VERSION }}"
291- tar cfz "tflite-runtime-osx-universal2-${{ env.VERSION }}.tgz" "tflite-runtime-osx-universal2-${{ env.VERSION }}"
292- - uses : softprops/action-gh-release@v2
293- if : ${{ inputs.release }}
294- with :
295- files : " *.tgz"
296- tag_name : ${{ env.VERSION }}
297-
298- build-windows :
299- # Using windows-2019 as build is broken on windows-latest runner due to another
300- # See: https://github.com/bazelbuild/bazel/issues/18592
301- runs-on : windows-2019
302- strategy :
303- fail-fast : false
304- matrix :
305- include :
306- - config : windows_x86_64
307- cpu : x86_64
308- artifact_name : tflite-runtime-win-x86_64
309- env :
310- HERMETIC_PYTHON_VERSION : 3.12
311- steps :
312- - uses : actions/checkout@v4
313- with :
314- repository : ${{ env.REPOSITORY }}
315- ref : v${{ env.VERSION }}
316- submodules : recursive
317- github-server-url : https://github.com
318- - uses : bazel-contrib/setup-bazel@0.15.0
319- - name : Build runtime
320- shell : bash
321- run : |
322- mkdir -p artifact
323-
324- # Main
325- bazel build --cxxopt=/std:c++20 -c opt --define tflite_with_xnnpack=true ${{ inputs.xnn_arm_options }} ${{ inputs.xnn_avx_options }} tensorflow/lite/c:tensorflowlite_c
326- cp -f bazel-bin/tensorflow/lite/c/tensorflowlite_c.dll artifact
327-
328- mv artifact/ "${{ matrix.artifact_name }}-${{ env.VERSION }}"
329- 7z a "${{ matrix.artifact_name }}-${{ env.VERSION }}.zip" "${{ matrix.artifact_name }}-${{ env.VERSION }}"
330- - uses : softprops/action-gh-release@v2
331- if : ${{ inputs.release }}
332- with :
333- files : " *.zip"
334- tag_name : ${{ env.VERSION }}
335-
336- release :
337- needs : [build-android, build-ios, build-linux, build-macos-universal, build-windows]
338- runs-on : ubuntu-latest
339- steps :
340- - uses : softprops/action-gh-release@v2
341- if : ${{ inputs.release }}
342- with :
343- name : TFLite Runtime v${{ env.VERSION }}
344- tag_name : ${{ env.VERSION }}
345- target_commitish : ${{ github.sha }}
107+ draft : true
0 commit comments