Skip to content

Commit 43f04ff

Browse files
cccclaifacebook-github-bot
authored andcommitted
Update instruction to install flatc (#447)
Summary: See context in D49487908, the `flatc` from `brew install flatbuffers` seems good. Differential Revision: D49530021
1 parent d515135 commit 43f04ff

File tree

2 files changed

+49
-12
lines changed

2 files changed

+49
-12
lines changed

docs/website/docs/tutorials/00_setting_up_executorch.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ To install conda, you can look at the
1515
```bash
1616
conda create -yn executorch python=3.10.0
1717
conda activate executorch
18-
1918
conda install cmake
20-
conda install -c conda-forge flatbuffers
2119
```
2220

2321
### Step 2: Clone the `executorch` repo
@@ -51,7 +49,23 @@ you may need to re-install a new version the PyTorch nightly pip package. The
5149
`TORCH_VERSION` value in this document will be the correct version for the
5250
corresponsing version of the repo.
5351

54-
### Step 4: Generate a program file from an `nn.Module`
52+
### Step 4: Install host build tools
53+
54+
Install [flatc V23.5.9](https://github.com/google/flatbuffers/releases/tag/v23.5.9) as it's a prerequisite for both AOT and runtime.
55+
There are several ways to get the flatc compiler, including
56+
- [MacOS only] `brew install flatbuffers`
57+
- Download a prebuilt binary from https://github.com/google/flatbuffers/releases/tag/v23.5.9
58+
- Build it from `executorch/third-party/flatbuffers`, [following instruction from the official website](https://github.com/google/flatbuffers#quick-start). For example, build for MacOS or Linux with:
59+
```bash
60+
cd executorch/third-party/flatbuffers && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && cmake --build . -j 9
61+
```
62+
- Add the flatc path to $PATH if necessary, like
63+
```
64+
export PATH="/path/to/flatc:$PATH"
65+
```
66+
Once installed, run `flatc --version` to double check that it's the correct version.
67+
68+
### Step 5: Generate a program file from an `nn.Module`
5569

5670
Via python script:
5771
```bash

docs/website/docs/tutorials/cmake_build_system.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,19 @@ rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
123123

124124
# point -DCMAKE_TOOLCHAIN_FILE to the location where ndk is installed
125125
# Run `which buck2`, if it returns empty (meaning the system doesn't know where buck2 is installed), pass in pass in this flag `-DBUCK2=/path/to/buck2` pointing to buck2
126-
cmake -DCMAKE_TOOLCHAIN_FILE=/Users/{user_name}/Library/Android/sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a ..
126+
BUCK2=/path/to/buck2
127+
FLATC=/path/to/flatc
128+
NDK_ROOT=${HOME}/Library/Android/sdk/ndk/25.2.9519653
127129

128-
cd ..
129-
cmake --build cmake-android-out -j9
130+
cmake \
131+
-DCMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake \
132+
-DANDROID_ABI=arm64-v8a \
133+
-DBUCK2="${BUCK2:-$(which buck2)}" \
134+
-DFLATC_EXECUTABLE="${FLATC:-$(which flatc)}" \
135+
..
136+
137+
# Move to the executorch folder and build
138+
cd .. && cmake --build cmake-android-out -j9
130139

131140
# push the binary to an Android device
132141
adb push cmake-android-out/executor_runner /data/local/tmp/executorch
@@ -161,14 +170,28 @@ git clone https://github.com/leetal/ios-cmake.git
161170
```bash
162171
rm -rf cmake-ios-out && mkdir cmake-ios-out && cd cmake-ios-out
163172

164-
# change the platform accordingly, please refer to the table listed in Readme
165-
cmake . -G Xcode -DCMAKE_TOOLCHAIN_FILE=~/ios-cmake/ios.toolchain.cmake -DPLATFORM=SIMULATOR
173+
# change the platform accordingly, please refer to the table listed in [Readme](https://github.com/leetal/ios-cmake#readme)
174+
BUCK2=/path/to/buck2
175+
FLATC=/path/to/flatc
176+
PYTHON=/path/to/miniconda/envs/executorch/bin/python3
177+
# The path to the cloned ios-cmake repo
178+
IOS_CMAKE=/path/to/ios-cmake
179+
180+
cmake \
181+
-G Xcode \
182+
-DCMAKE_TOOLCHAIN_FILE=${IOS_CMAKE}/ios.toolchain.cmake \
183+
-DPLATFORM=SIMULATOR \
184+
-DBUCK2="${BUCK2:-$(which buck2)}" \
185+
-DFLATC_EXECUTABLE="${FLATC:-$(which flatc)}" \
186+
-DPYTHON_EXECUTABLE="${PYTHON:-$(which python3)}" \
187+
..
188+
189+
# Move to the executorch folder and build
190+
cd .. && cmake --build cmake-ios-out -j9
166191

167192
# Create an include folder in cmake-ios-out to include all header files
168-
mkdir include
169-
cp -r ../runtime include
170-
cp -r ../extension include
171-
cp -r ../utils include
193+
(cd cmake-ios-out && mkdir include && cd include && \
194+
ln -s ../../runtime ../../util ../../extension .)
172195
```
173196

174197

0 commit comments

Comments
 (0)