Skip to content

Commit 7c95c3d

Browse files
authored
Build TensorFlow Lite libs in docker image (#103)
* fix: actually build tensorflow in the docker container * gh: bump code version * gha: modernize release file * docker: update the tensorflow submodule as part of the docker build * tflow: fix func local native build
1 parent 0a85714 commit 7c95c3d

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SYSROOT_VERSION=0.1.9
2-
SYSROOT_CLI_IMAGE=faasm/cpp-sysroot:0.1.9
1+
SYSROOT_VERSION=0.1.10
2+
SYSROOT_CLI_IMAGE=faasm/cpp-sysroot:0.1.10
33
COMPOSE_PROJECT_NAME=cpp-dev

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ on:
77

88
jobs:
99
build:
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111
steps:
1212
- name: "Prune docker"
1313
run: docker system prune -f --all
1414
- name: "Get the code"
15-
uses: actions/checkout@v2
16-
- name: "Submodules"
17-
run: "git submodule update --init --recursive"
15+
uses: actions/checkout@v3
16+
with:
17+
submodules: recursive
1818
- name: "Get tag version"
1919
run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_ENV
2020
- name: "Print tag version"
2121
run: echo ${{ env.TAG_VERSION }}
2222
- name: "Set up QEMU"
23-
uses: docker/setup-qemu-action@v1
23+
uses: docker/setup-qemu-action@v2
2424
- name: "Set up Docker Buildx"
25-
uses: docker/setup-buildx-action@v1
25+
uses: docker/setup-buildx-action@v2
2626
- name: "Log in to DockerHub"
27-
uses: docker/login-action@v1
27+
uses: docker/login-action@v2
2828
with:
2929
username: ${{ secrets.DOCKER_USERNAME }}
3030
password: ${{ secrets.DOCKER_PASSWORD }}
3131
- name: "Build and push cpp-sysroot container"
3232
id: docker_build
33-
uses: docker/build-push-action@v2
33+
uses: docker/build-push-action@v3
3434
with:
3535
push: true
3636
file: docker/cpp-sysroot.dockerfile

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
if: github.event.pull_request.draft == false
2020
runs-on: ubuntu-20.04
2121
container:
22-
image: faasm/cpp-sysroot:0.1.9
22+
image: faasm/cpp-sysroot:0.1.10
2323
steps:
2424
# --- Update code ---
2525
- name: "Checkout code"

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.9
1+
0.1.10

docker/cpp-sysroot.dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ RUN mkdir -p /code \
2626
&& git submodule update --init -f third-party/FFmpeg \
2727
&& git submodule update --init -f third-party/zlib \
2828
&& git submodule update --init -f third-party/libpng \
29-
&& git submodule update --init -f third-party/ImageMagick
29+
&& git submodule update --init -f third-party/ImageMagick \
30+
&& git submodule update --init -f third-party/tensorflow
3031

3132
# Install the faasmtools Python lib
3233
RUN cd /code/cpp \
@@ -60,6 +61,7 @@ RUN cd /code/cpp \
6061
zlib \
6162
libpng \
6263
imagemagick \
64+
tensorflow \
6365
# Build Faasm WASM libraries
6466
&& inv \
6567
libemscripten \

func/tf/CMakeLists.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Set where the library has been built
21
if (FAASM_BUILD_TYPE STREQUAL "wasm")
32
set(TF_LIB ${CMAKE_SYSROOT}/lib/wasm32-wasi/libtensorflow-lite.a)
4-
else()
5-
message(FATAL_ERROR "Tensorflow can only be built for WebAssembly")
6-
endif()
73

8-
faasm_func(minimal minimal.cpp)
4+
faasm_func(minimal minimal.cpp)
95

10-
set(TF_HEADERS
11-
${CMAKE_SYSROOT}/include/tensorflow
12-
${CMAKE_SYSROOT}/include/tensorflow/tensorflow/lite/tools/make/downloads/flatbuffers/include
13-
)
6+
set(TF_HEADERS
7+
${CMAKE_SYSROOT}/include/tensorflow
8+
${CMAKE_SYSROOT}/include/tensorflow/tensorflow/lite/tools/make/downloads/flatbuffers/include
9+
)
1410

15-
target_include_directories(minimal PUBLIC ${TF_HEADERS})
16-
target_link_libraries(minimal faasm ${TF_LIB})
17-
add_custom_target(tf_all_funcs DEPENDS minimal)
11+
target_include_directories(minimal PUBLIC ${TF_HEADERS})
12+
target_link_libraries(minimal faasm ${TF_LIB})
13+
add_custom_target(tf_all_funcs DEPENDS minimal)
14+
else()
15+
message(STATUS "Tensorflow can only be built for WebAssembly")
16+
add_custom_target(tf_all_funcs)
17+
endif()

0 commit comments

Comments
 (0)