Skip to content

Commit 0fb5861

Browse files
Update Oz inlining demo to work with TFLite (#131)
Some minor changes to the inlining demo, just changing all of the info on using the Tensorflow C library to using TFLite, including adding info on compilation of the library using the buildbot script.
1 parent 016f398 commit 0fb5861

File tree

2 files changed

+12
-535
lines changed

2 files changed

+12
-535
lines changed

docs/demo/demo.md

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,9 @@ cipd install fuchsia/sysroot/linux-amd64 latest -root ${SYSROOT_DIR}/linux-x64
7474
## Set up the correct package versions
7575

7676
We need to make sure the git revision of llvm is one that works with the version
77-
of the Fuchsia tree. Note that Fuchsia frequently updates their llvm dependency,
78-
which should mean you could try working at HEAD for both, but the method here is
79-
safe.
77+
of the Fuchsia tree.
8078

81-
*Optionally, you can get Fuchsia to the version we used we wrote this guide:*
82-
83-
```
84-
cd ${FUCHSIA_SRCDIR}
85-
jiri update -gc ~/ml-compiler-opt/docs/demo/fuchsia.xml
86-
```
87-
88-
Either way - i.e. you can skip the step above to be at Fuchsia HEAD - to get the
89-
git hash at which we know this version of Fuchsia will build, do:
79+
To get the git hash at which we know this version of Fuchsia will build, do:
9080

9181
```
9282
cd ${FUCHSIA_SRCDIR}
@@ -108,20 +98,11 @@ This is this repository.
10898

10999
### Tensorflow dependencies
110100

111-
See also [the build bot script](../../buildbot/buildbot_init.sh)
101+
We need to install all of the Python dependencies for this repository, setup
102+
some environment variables for the AOT compiler, and also build the TFLite
103+
dependency to compile LLVM in MLGO development mode.
112104

113-
**NOTE:** The versioning of Tensorflow is pretty important in order to get a
114-
functioning build with the demo setup. Building with a Tensorflow pip
115-
package above v2.7.0 will cause the build to fail as well as building with
116-
a libtensorflow version above v1.15.x. Versions of the Tensorflow pip package
117-
under v2.8.0 don't have any available wheels for Python 3.10, so if you
118-
are on a more recent distro (eg Ubuntu 22.04) that has Python 3.10, you will
119-
run into version compatibility issues between the required Tensorflow version
120-
and the available Python version (pip will refuse to install Tensorflow) trying
121-
to install the required python packages from `ml-compiler-opt/requirements.txt`.
122-
To mitigate this, either use a distro with a compatible python version
123-
(eg Ubuntu 20.04), or your preferred flavor of python virtual environment
124-
to utilize a compatible Python version.
105+
See also [the build bot script](../../buildbot/buildbot_init.sh)
125106

126107
```shell
127108
cd
@@ -133,18 +114,18 @@ TF_PIP=$(python3 -m pip show tensorflow | grep Location | cut -d ' ' -f 2)
133114

134115
export TENSORFLOW_AOT_PATH="${TF_PIP}/tensorflow"
135116

136-
mkdir ~/tensorflow
137-
export TENSORFLOW_C_LIB_PATH=~/tensorflow
138-
wget --quiet https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.15.0.tar.gz
139-
tar xfz libtensorflow-cpu-linux-x86_64-1.15.0.tar.gz -C "${TENSORFLOW_C_LIB_PATH}"
117+
export TFLITE_PATH=~/tflite
118+
mkdir ${TFLITE_PATH}
119+
cd ${TFLITE_PATH}
120+
~/ml-compiler-opt/buildbot/build_tflite.sh
140121
```
141122

142123
## Build LLVM
143124

144125
Build LLVM with the 'development' ML mode, and additional
145126
Fuchsia-specific settings:
146127

147-
```
128+
```shell
148129
cd ${LLVM_SRCDIR}
149130
mkdir build
150131
cd build
@@ -154,9 +135,9 @@ cmake -G Ninja \
154135
-DLINUX_aarch64-unknown-linux-gnu_SYSROOT=${SYSROOT_DIR}/linux-arm64 \
155136
-DFUCHSIA_SDK=${IDK_DIR} \
156137
-DCMAKE_INSTALL_PREFIX= \
157-
-DTENSORFLOW_C_LIB_PATH=${TENSORFLOW_C_LIB_PATH} \
158138
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=On \
159139
-C ${LLVM_SRCDIR}/clang/cmake/caches/Fuchsia-stage2.cmake \
140+
-C ${TFLITE_PATH}/tflite.cmake \
160141
${LLVM_SRCDIR}/llvm
161142

162143
ninja distribution

0 commit comments

Comments
 (0)