Skip to content

Commit 6cd7122

Browse files
Olivia-liupytorchbot
authored andcommitted
Simplify SDK tutorial by moving cmake commands to a script (#3438)
Summary: As titled. Tested the commands on mac locally and they worked. Pull Request resolved: #3438 Reviewed By: Jack-Khuu Differential Revision: D56792240 Pulled By: Olivia-liu fbshipit-source-id: dd62ea2fc788c5e1867d1e50037d7b4fd7e3a3f9 (cherry picked from commit a4ffd96)
1 parent 6a1703e commit 6cd7122

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

docs/source/tutorials_source/sdk-integration-tutorial.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,8 @@ def forward(self, x):
172172
# Use CMake (follow `these instructions <../runtime-build-and-cross-compilation.html#configure-the-cmake-build>`__ to set up cmake) to execute the Bundled Program to generate the ``ETDump``::
173173
#
174174
# cd executorch
175-
# rm -rf cmake-out && mkdir cmake-out && cd cmake-out && cmake -DEXECUTORCH_BUILD_SDK=1 -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=1 ..
176-
# cd ..
177-
# cmake --build cmake-out -j8 -t sdk_example_runner
178-
# ./cmake-out/examples/sdk/sdk_example_runner --bundled_program_path <bundled_program>
175+
# ./examples/sdk/build_sdk_example_runner.sh
176+
# cmake-out/examples/sdk/sdk_example_runner --bundled_program_path="bundled_program.bp"
179177

180178
######################################################################
181179
# Creating an Inspector
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Builds sdk_example_runner and prints its path.
9+
10+
set -euo pipefail
11+
12+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
13+
readonly SCRIPT_DIR
14+
15+
readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../.."
16+
17+
# Allow overriding the number of build jobs. Default to 9.
18+
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-9}"
19+
20+
main() {
21+
cd "${EXECUTORCH_ROOT}"
22+
23+
rm -rf cmake-out
24+
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
25+
-DCMAKE_BUILD_TYPE=Release \
26+
-DEXECUTORCH_BUILD_SDK=ON \
27+
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
28+
-Bcmake-out .
29+
cmake --build cmake-out --target install --config Release
30+
31+
local example_dir=examples/sdk
32+
local build_dir="cmake-out/${example_dir}"
33+
local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
34+
rm -rf ${build_dir}
35+
cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
36+
-DCMAKE_BUILD_TYPE=Release \
37+
-B"${build_dir}" \
38+
"${example_dir}"
39+
cmake --build "${build_dir}" --config Release
40+
41+
local runner="${PWD}/${build_dir}/sdk_example_runner"
42+
if [[ ! -f "${runner}" ]]; then
43+
echo "ERROR: Failed to build ${build_dir}/sdk_example_runner" >&2
44+
exit 1
45+
else
46+
echo "Built ${build_dir}/sdk_example_runner"
47+
fi
48+
}
49+
50+
main "$@"

0 commit comments

Comments
 (0)