Skip to content

feat: add support for tensorflow v2.15.0 #59

feat: add support for tensorflow v2.15.0

feat: add support for tensorflow v2.15.0 #59

Workflow file for this run

name: Build TensorFlow Lite runtime
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
TF_PYTHON_VERSION: '3.10'
jobs:
build-android:
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- config: android_arm64
- config: android_arm
- config: android_fat_aar
env:
ANDROID_SDK_API_LEVEL: 30
ANDROID_NDK_API_LEVEL: 26
ANDROID_BUILD_TOOLS_VERSION: '31.0.0'
steps:
- uses: actions/checkout@v3
with:
repository: tensorflow/tensorflow
ref: ${{ github.ref_name }}
submodules: recursive
github-server-url: https://github.com
- uses: actions/setup-python@v4
with:
python-version: ${{ env.TF_PYTHON_VERSION }}
- name: Install dependencies
run: |
pip install numpy
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21b
add-to-path: true
- name: Build shared libraries
if: ${{ matrix.config != 'android_fat_aar' }}
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
export ANDROID_SDK_HOME=$ANDROID_HOME
# Main
bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 --define=xnn_enable_arm_fp16=false --define=xnn_enable_arm_i8mm=false tensorflow/lite/c:tensorflowlite_c
cp -f bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so .
# GPU Delegate
bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 --define=xnn_enable_arm_fp16=false --define=xnn_enable_arm_i8mm=false --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=hidden --linkopt -s --strip always tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so
cp -f bazel-bin/tensorflow/lite/delegates/gpu/libtensorflowlite_gpu_delegate.so .
# GL Delegate
bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 --define=xnn_enable_arm_fp16=false --define=xnn_enable_arm_i8mm=false --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=hidden --linkopt -s --strip always tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_gl.so
cp -f bazel-bin/tensorflow/lite/delegates/gpu/libtensorflowlite_gpu_gl.so .
# NNAPI Delegate
# bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 //tensorflow/lite/delegates/nnapi:nnapi_delegate
# cp -f bazel-bin/tensorflow/lite/delegates/nnapi/libnnapi_delegate.so .
- name: Build AAR
if: ${{ matrix.config == 'android_fat_aar' }}
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
export ANDROID_SDK_HOME=$ANDROID_HOME
# Main
bazel build -c opt --fat_apk_cpu=arm64-v8a,armeabi-v7a,x86_64 --cxxopt=--std=c++17 --define=xnn_enable_arm_fp16=false --define=xnn_enable_arm_i8mm=false --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
cp -f bazel-bin/tensorflow/lite/java/tensorflow-lite.aar .
# GPU Delegate
bazel build -c opt --fat_apk_cpu=arm64-v8a,armeabi-v7a,x86_64 --cxxopt=--std=c++17 --define=xnn_enable_arm_fp16=false --define=xnn_enable_arm_i8mm=false --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
cp -f bazel-bin/tensorflow/lite/java/tensorflow-lite-gpu.aar .
- uses: actions/upload-artifact@v3
with:
name: tflite-runtime-${{ matrix.config }}
path: |
*.so
*.aar
build-ios:
runs-on: macos-12
strategy:
matrix:
include:
- config: ios_arm64
steps:
- uses: actions/checkout@v3
with:
repository: tensorflow/tensorflow
ref: ${{ github.ref_name }}
submodules: recursive
github-server-url: https://github.com
- uses: bazelbuild/setup-bazelisk@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ env.TF_PYTHON_VERSION }}
- name: Install dependencies
run: |
pip install numpy
- name: Build runtime
run: |
mv tensorflow/lite/ios/BUILD.apple tensorflow/lite/ios/BUILD
mv tensorflow/lite/objc/BUILD.apple tensorflow/lite/objc/BUILD
mv tensorflow/lite/swift/BUILD.apple tensorflow/lite/swift/BUILD
# Main
bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 tensorflow/lite/ios:TensorFlowLiteC_framework
unzip -o bazel-bin/tensorflow/lite/ios/TensorFlowLiteC_framework.zip
# Metal Delegate
bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 tensorflow/lite/ios:TensorFlowLiteCMetal_framework
unzip -o bazel-bin/tensorflow/lite/ios/TensorFlowLiteCMetal_framework.zip
# CoreML Delegate
bazel build -c opt --config=${{ matrix.config }} --cxxopt=--std=c++17 tensorflow/lite/ios:TensorFlowLiteCCoreML_framework
unzip -o bazel-bin/tensorflow/lite/ios/TensorFlowLiteCCoreML_framework.zip
- uses: actions/upload-artifact@v3
with:
name: tflite-runtime-${{ matrix.config }}
path: |
*.framework
build-linux:
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- config: linux
- config: elinux_aarch64
steps:
- uses: actions/checkout@v3
with:
repository: tensorflow/tensorflow
ref: ${{ github.ref_name }}
submodules: recursive
github-server-url: https://github.com
- uses: bazelbuild/setup-bazelisk@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ env.TF_PYTHON_VERSION }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libegl1-mesa-dev
pip install numpy
- name: Build runtime
run: |
bazel build --config=${{ matrix.config }} -c opt --define tflite_with_xnnpack=true tensorflow/lite/c:tensorflowlite_c
cp -f bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so .
- uses: actions/upload-artifact@v3
with:
name: tflite-runtime-${{ matrix.config }}
path: |
*.so
build-macos:
runs-on: macos-12
strategy:
matrix:
include:
- config: macos
cpu: x86_64
- config: macos_arm64
cpu: arm64
steps:
- uses: actions/checkout@v3
with:
repository: tensorflow/tensorflow
ref: ${{ github.ref_name }}
submodules: recursive
github-server-url: https://github.com
- uses: bazelbuild/setup-bazelisk@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ env.TF_PYTHON_VERSION }}
- name: Install dependencies
run: |
pip install numpy
- name: Build runtime
run: |
# Main
bazel build --config=${{ matrix.config }} --macos_cpus=${{ matrix.cpu }} --cxxopt=--std=c++17 -c opt --define tflite_with_xnnpack=true tensorflow/lite/c:tensorflowlite_c
cp -f bazel-bin/tensorflow/lite/c/libtensorflowlite_c.dylib .
# Metal Delegate
bazel build --config=${{ matrix.config }} --macos_cpus=${{ matrix.cpu }} --cxxopt=--std=c++17 -c opt --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=default --linkopt -s --strip always tensorflow/lite/delegates/gpu:tensorflow_lite_gpu_dylib
cp -f bazel-bin/tensorflow/lite/delegates/gpu/tensorflow_lite_gpu_dylib.dylib ./libtensorflowlite_metal_delegate.dylib
- uses: actions/upload-artifact@v3
with:
name: tflite-runtime-macos_${{ matrix.cpu }}
path: |
*.dylib
build-macos-universal:
needs: [build-macos]
runs-on: macos-12
steps:
- uses: actions/download-artifact@v3
- name: Build universal binary
run: |
lipo -create -output libtensorflowlite_c.dylib tflite-runtime-macos_x86_64/libtensorflowlite_c.dylib tflite-runtime-macos_arm64/libtensorflowlite_c.dylib
lipo -create -output libtensorflowlite_metal_delegate.dylib tflite-runtime-macos_x86_64/libtensorflowlite_metal_delegate.dylib tflite-runtime-macos_arm64/libtensorflowlite_metal_delegate.dylib
- uses: actions/upload-artifact@v3
with:
name: tflite-runtime-macos
path: |
*.dylib
build-windows:
# Using windows-2019 as build is broken on windows-latest runner due to another
# See: https://github.com/bazelbuild/bazel/issues/18592
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
with:
repository: tensorflow/tensorflow
ref: ${{ github.ref_name }}
submodules: recursive
github-server-url: https://github.com
- uses: bazelbuild/setup-bazelisk@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ env.TF_PYTHON_VERSION }}
- name: Install dependencies
run: |
pip install numpy
- name: Build runtime
shell: bash
run: |
# Main
bazel build -c opt --define tflite_with_xnnpack=true tensorflow/lite/c:tensorflowlite_c
cp -f bazel-bin/tensorflow/lite/c/tensorflowlite_c.dll .
- uses: actions/upload-artifact@v3
with:
name: tflite-runtime-windows_x86_64
path: |
*.dll
release:
needs: [build-android, build-ios, build-linux, build-macos-universal, build-windows]
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/download-artifact@v3
- name: Compress artifact
run: zip -r tflite-runtime.zip .
- uses: softprops/action-gh-release@v1
with:
files: tflite-runtime.zip