@@ -53,7 +53,7 @@ For more details and troubleshooting, refer to the official Microsoft WSL instal
5353👉 [ Install WSL | Microsoft Learn] ( https://learn.microsoft.com/en-us/windows/wsl/install )
5454
5555### Hardware:
56- You will need an Android smartphone with adb-connected running on one of below Qualcomm SoCs:
56+ You will need an Android / Linux device with adb-connected running on one of below Qualcomm SoCs:
5757 - SA8295
5858 - SM8450 (Snapdragon 8 Gen 1)
5959 - SM8475 (Snapdragon 8 Gen 1+)
@@ -62,7 +62,7 @@ You will need an Android smartphone with adb-connected running on one of below Q
6262 - SM8750 (Snapdragon 8 Elite)
6363 - SSG2115P
6464 - SSG2125P
65- - SXR1230P
65+ - SXR1230P (Linux Embedded)
6666 - SXR2230P
6767 - SXR2330P
6868
@@ -73,6 +73,7 @@ This example is verified with SM8550 and SM8450.
7373 - Follow ExecuTorch recommended Python version.
7474 - A compiler to compile AOT parts, e.g., the GCC compiler comes with Ubuntu LTS.
7575 - [ Android NDK] ( https://developer.android.com/ndk ) . This example is verified with NDK 26c.
76+ - (Optional) Target toolchain for linux embedded platform.
7677 - [ Qualcomm AI Engine Direct SDK] ( https://developer.qualcomm.com/software/qualcomm-ai-engine-direct-sdk )
7778 - Click the "Get Software" button to download a version of QNN SDK.
7879 - However, at the moment of updating this tutorial, the above website doesn't provide QNN SDK newer than 2.22.6.
@@ -131,8 +132,11 @@ The above script is actively used. It is updated more frquently than this tutori
131132An example usage is
132133``` bash
133134cd $EXECUTORCH_ROOT
135+ # android target
134136./backends/qualcomm/scripts/build.sh
135- # or
137+ # (optional) linux embedded target
138+ ./backends/qualcomm/scripts/build.sh --le
139+ # for release build
136140./backends/qualcomm/scripts/build.sh --release
137141```
138142
@@ -148,11 +152,14 @@ cd build-x86
148152# Please refer to the above build.sh for latest workable commands.
149153cmake .. \
150154 -DCMAKE_INSTALL_PREFIX=$PWD \
155+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
151156 -DEXECUTORCH_BUILD_QNN=ON \
152157 -DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
153158 -DEXECUTORCH_BUILD_DEVTOOLS=ON \
154159 -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
155160 -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
161+ -DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
162+ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
156163 -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
157164 -DPYTHON_EXECUTABLE=python3
158165
@@ -177,17 +184,23 @@ A example `qnn_executor_runner` executable would be used to run the compiled `pt
177184Commands to build ` qnn_executor_runner ` for Android:
178185
179186``` bash
187+ export ANDROID_NDK_ROOT=/path/to/android_ndk_r26c/..
188+
180189cd $EXECUTORCH_ROOT
181190mkdir build-android
182191cd build-android
183192# build executorch & qnn_executorch_backend
184193cmake .. \
185194 -DCMAKE_INSTALL_PREFIX=$PWD \
195+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
186196 -DEXECUTORCH_BUILD_QNN=ON \
187197 -DQNN_SDK_ROOT=$QNN_SDK_ROOT \
188198 -DEXECUTORCH_BUILD_DEVTOOLS=ON \
189199 -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
190200 -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
201+ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
202+ -DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
203+ -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
191204 -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
192205 -DPYTHON_EXECUTABLE=python3 \
193206 -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT /build/cmake/android.toolchain.cmake \
@@ -199,6 +212,7 @@ cmake .. \
199212cmake --build $PWD --target install -j$( nproc)
200213
201214cmake ../examples/qualcomm \
215+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
202216 -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT /build/cmake/android.toolchain.cmake \
203217 -DANDROID_ABI=' arm64-v8a' \
204218 -DANDROID_PLATFORM=android-30 \
@@ -214,6 +228,61 @@ cmake --build examples/qualcomm -j$(nproc)
214228ls examples/qualcomm
215229```
216230
231+ (Optional) Commands to build ` qnn_executor_runner ` for Linux Embedded:
232+
233+ ``` bash
234+ export TOOLCHAIN_ROOT_HOST=/path/to/sysroots/HOST # e.g. x86_64-qtisdk-linux
235+ export TOOLCHAIN_ROOT_TARGET=/path/to/sysroots/TARGET # e.g. armv8a-oe-linux
236+
237+ cd $EXECUTORCH_ROOT
238+ mkdir build-oe-linux
239+ cd build-oe-linux
240+ # build executorch & qnn_executorch_backend
241+ cmake .. \
242+ -DCMAKE_INSTALL_PREFIX=$PWD \
243+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
244+ -DCMAKE_C_COMPILER=${TOOLCHAIN_ROOT_HOST} /usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc \
245+ -DCMAKE_CXX_COMPILER=${TOOLCHAIN_ROOT_HOST} /usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++ \
246+ -DCMAKE_SYSROOT=$TOOLCHAIN_ROOT_TARGET \
247+ -DCMAKE_SYSTEM_NAME=Linux \
248+ -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
249+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
250+ -DEXECUTORCH_BUILD_CPUINFO=OFF \
251+ -DEXECUTORCH_BUILD_QNN=ON \
252+ -DQNN_SDK_ROOT=$QNN_SDK_ROOT \
253+ -DEXECUTORCH_BUILD_DEVTOOLS=ON \
254+ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
255+ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
256+ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
257+ -DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
258+ -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
259+ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
260+ -DPYTHON_EXECUTABLE=python3 \
261+
262+ # nproc is used to detect the number of available CPU.
263+ # If it is not applicable, please feel free to use the number you want.
264+ cmake --build $PWD --target install -j$( nproc)
265+
266+ cmake ../examples/qualcomm \
267+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
268+ -DCMAKE_PREFIX_PATH=" $PWD /lib/cmake/ExecuTorch;$PWD /third-party/gflags;" \
269+ -DCMAKE_C_COMPILER=${TOOLCHAIN_ROOT_HOST} /usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc \
270+ -DCMAKE_CXX_COMPILER=${TOOLCHAIN_ROOT_HOST} /usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++ \
271+ -DCMAKE_SYSROOT=$TOOLCHAIN_ROOT_TARGET \
272+ -DCMAKE_SYSTEM_NAME=Linux \
273+ -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
274+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
275+ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
276+ -DPYTHON_EXECUTABLE=python3 \
277+ -Bexamples/qualcomm
278+
279+ cmake --build examples/qualcomm -j$( nproc)
280+
281+ # qnn_executor_runner can be found under examples/qualcomm
282+ # The full path is $EXECUTORCH_ROOT/build-oe-linux/examples/qualcomm/qnn_executor_runner
283+ ls examples/qualcomm
284+ ```
285+
217286** Note:** If you want to build for release, add ` -DCMAKE_BUILD_TYPE=Release ` to the ` cmake ` command options.
218287
219288
@@ -351,7 +420,10 @@ I 00:00:00.364875 executorch:qnn_executor_runner.cpp:425] Write etdump to etdump
351420The model is merely executed. If we want to feed real inputs and get model outputs, we can use
352421``` bash
353422cd $EXECUTORCH_ROOT
423+ # android
354424python -m examples.qualcomm.scripts.deeplab_v3 -b build-android -m SM8550 --download -s < device_serial>
425+ # (optional) linux embedded
426+ python -m examples.qualcomm.scripts.deeplab_v3 -b build-oe-linux -m SXR1230P --download -s < device_serial> -t aarch64-oe-linux-gcc-9.3
355427```
356428The ` <device_serial> ` can be found by ` adb devices ` command.
357429
0 commit comments