Skip to content

Commit bdc3d04

Browse files
haowhsu-quicchenweng-quic
authored andcommitted
Qualcomm AI Engine Direct - LE support
Summary: - enable linux embedded support for toolchain: aarch64-oe-linux-gcc9.3, aarch64-oe-linux-gcc11.2 (SXR1230P, QCS9100) - update document a bit
1 parent b3f3111 commit bdc3d04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+380
-29
lines changed

.ci/scripts/build-qnn-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build_qnn_backend() {
1818
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1919

2020
parallelism=$(( $(nproc) - 1 ))
21-
bash backends/qualcomm/scripts/build.sh --skip_aarch64 --job_number ${parallelism} --release
21+
bash backends/qualcomm/scripts/build.sh --skip_linux_android --skip_linux_embedding --job_number ${parallelism} --release
2222
}
2323

2424
set_up_aot() {

backends/qualcomm/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Please check `generate_qnn_executorch_compiler_spec()` in
2727
- SXR1230P
2828
- SXR2230P
2929
- SXR2330P
30+
- QCS9100
3031

3132
### Adding more supported Chipset
3233
Currently, users cannot add additional chipset models because the chipset ID is not accessible to community users. If you have specific chipset models you wish to add, please contact one of the authors in the `Code Reviews` section at the bottom of this page.

backends/qualcomm/debugger/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ adb = SimpleADB(
5454
device_id=args.device,
5555
host_id=args.host,
5656
soc_model=args.model,
57+
target=args.target,
5758
)
5859
binaries_trace = generate_optrace(
5960
args, adb, f"{args.artifact}/{pte_filename}.pte", example_input

backends/qualcomm/scripts/build.sh

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ fi
1717
usage() {
1818
echo "Usage: Build the aarch64 version of executor runner or the python interface of Qnn Manager"
1919
echo "First, you need to set the environment variable for QNN_SDK_ROOT"
20-
echo ", and if you want to build the aarch64 version of executor runner"
20+
echo ", and if you want to build the android version of executor runner"
2121
echo ", you need to export ANDROID_NDK_ROOT=/path/to/android_ndkXX"
22+
echo "(or export TOOLCHAIN_ROOT_HOST=/path/to/sysroots/xx_host, "
23+
echo "TOOLCHAIN_ROOT_TARGET=/path/to/sysroots/xx_target for linux embedded with --le)"
2224
echo "e.g.: executorch$ ./backends/qualcomm/scripts/build.sh --skip_x86_64"
2325
exit 1
2426
}
@@ -28,8 +30,10 @@ usage() {
2830

2931
BUILD_X86_64="true"
3032
CMAKE_X86_64="build-x86"
31-
BUILD_AARCH64="true"
32-
CMAKE_AARCH64="build-android"
33+
BUILD_ANDROID="true"
34+
CMAKE_ANDROID="build-android"
35+
BUILD_OE_LINUX="false"
36+
CMAKE_OE_LINUX="build-oe-linux"
3337
CLEAN="true"
3438
BUILD_TYPE="RelWithDebInfo"
3539
BUILD_JOB_NUMBER="16"
@@ -42,7 +46,7 @@ if [ -z BUCK2 ]; then
4246
BUCK2="buck2"
4347
fi
4448

45-
long_options=skip_x86_64,skip_aarch64,no_clean,release,job_number:
49+
long_options=skip_x86_64,skip_linux_android,skip_linux_embedding,enable_linux_embedding,no_clean,release,job_number:
4650

4751
parsed_args=$(getopt -a --options '' --longoptions $long_options --name "$0" -- "$@")
4852
eval set -- "$parsed_args"
@@ -51,7 +55,9 @@ eval set -- "$parsed_args"
5155
while true ; do
5256
case "$1" in
5357
--skip_x86_64) BUILD_X86_64="false"; shift;;
54-
--skip_aarch64) BUILD_AARCH64="false"; shift;;
58+
--skip_linux_android) BUILD_ANDROID="false"; shift;;
59+
--skip_linux_embedding) BUILD_OE_LINUX="false"; shift;;
60+
--enable_linux_embedding) BUILD_ANDROID="false"; BUILD_OE_LINUX="true"; shift;;
5561
--no_clean) CLEAN="false"; shift;;
5662
--release) BUILD_TYPE="Release"; shift;;
5763
--job_number) BUILD_JOB_NUMBER="$2"; shift 2;;
@@ -61,13 +67,13 @@ done
6167

6268
PRJ_ROOT="$( cd "$(dirname "$0")/../../.." ; pwd -P)"
6369

64-
if [ "$BUILD_AARCH64" = true ]; then
70+
if [ "$BUILD_ANDROID" = true ]; then
6571
if [[ -z ${ANDROID_NDK_ROOT} ]]; then
6672
echo "Please export ANDROID_NDK_ROOT=/path/to/android_ndkXX"
6773
exit -1
6874
fi
6975

70-
BUILD_ROOT=$PRJ_ROOT/$CMAKE_AARCH64
76+
BUILD_ROOT=$PRJ_ROOT/$CMAKE_ANDROID
7177
if [ "$CLEAN" = true ]; then
7278
rm -rf $BUILD_ROOT && mkdir $BUILD_ROOT
7379
else
@@ -134,6 +140,72 @@ if [ "$BUILD_AARCH64" = true ]; then
134140
cmake --build $LLAMA_EXAMPLE_ROOT -j$BUILD_JOB_NUMBER
135141
fi
136142

143+
if [ "$BUILD_OE_LINUX" = true ]; then
144+
if [[ -z ${TOOLCHAIN_ROOT_HOST} ]]; then
145+
echo "Please export e.g. TOOLCHAIN_ROOT_HOST=/path/to/sysroots/x86_64-qtisdk-linux"
146+
exit -1
147+
fi
148+
if [[ -z ${TOOLCHAIN_ROOT_TARGET} ]]; then
149+
echo "Please export e.g. TOOLCHAIN_ROOT_TARGET=/path/to/sysroots/armv8a-oe-linux"
150+
exit -1
151+
fi
152+
153+
BUILD_ROOT=$PRJ_ROOT/$CMAKE_OE_LINUX
154+
if [ "$CLEAN" = true ]; then
155+
rm -rf $BUILD_ROOT && mkdir $BUILD_ROOT
156+
else
157+
# Force rebuild flatccrt for the correct platform
158+
cd $BUILD_ROOT/third-party/flatcc && make clean
159+
fi
160+
161+
TOOLCHAN_PREFIX=$TOOLCHAIN_ROOT_HOST/usr/bin/aarch64-oe-linux/aarch64-oe-linux-
162+
cd $BUILD_ROOT
163+
cmake .. \
164+
-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT \
165+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
166+
-DCMAKE_C_COMPILER=${TOOLCHAN_PREFIX}gcc \
167+
-DCMAKE_CXX_COMPILER=${TOOLCHAN_PREFIX}g++ \
168+
-DCMAKE_SYSROOT=$TOOLCHAIN_ROOT_TARGET \
169+
-DCMAKE_SYSTEM_NAME=Linux \
170+
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
171+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
172+
-DEXECUTORCH_BUILD_CPUINFO=OFF \
173+
-DEXECUTORCH_BUILD_QNN=ON \
174+
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
175+
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON \
176+
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON \
177+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
178+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
179+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
180+
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
181+
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
182+
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
183+
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
184+
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
185+
-B$BUILD_ROOT
186+
187+
cmake --build $BUILD_ROOT -j$BUILD_JOB_NUMBER --target install
188+
189+
EXAMPLE_ROOT=examples/qualcomm
190+
CMAKE_PREFIX_PATH="${BUILD_ROOT};${BUILD_ROOT}/third-party/gflags;"
191+
192+
cmake $PRJ_ROOT/$EXAMPLE_ROOT \
193+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
194+
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
195+
-DCMAKE_C_COMPILER=${TOOLCHAN_PREFIX}gcc \
196+
-DCMAKE_CXX_COMPILER=${TOOLCHAN_PREFIX}g++ \
197+
-DCMAKE_SYSROOT=$TOOLCHAIN_ROOT_TARGET \
198+
-DCMAKE_SYSTEM_NAME=Linux \
199+
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
200+
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
201+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
202+
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
203+
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
204+
-B$EXAMPLE_ROOT
205+
206+
cmake --build $EXAMPLE_ROOT -j$BUILD_JOB_NUMBER
207+
fi
208+
137209
if [ "$BUILD_X86_64" = true ]; then
138210
BUILD_ROOT=$PRJ_ROOT/$CMAKE_X86_64
139211
if [ "$CLEAN" = true ]; then

backends/qualcomm/serialization/qc_compiler_spec.fbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum QcomChipset: int {
4343
SXR1230P = 45,
4444
SXR2230P = 53,
4545
SXR2330P = 75,
46+
QCS9100 = 77,
4647
}
4748

4849
/// Indicate the information of the specified SoC.

backends/qualcomm/serialization/qc_schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class QcomChipset(IntEnum):
4949
SXR1230P = 45 # v73
5050
SXR2230P = 53 # v69
5151
SXR2330P = 75 # v79
52+
QCS9100 = 77 # v73
5253

5354

5455
@dataclass
@@ -69,6 +70,7 @@ class SocInfo:
6970
QcomChipset.SXR1230P: SocInfo(QcomChipset.SXR1230P, HtpInfo(HtpArch.V73, 2)),
7071
QcomChipset.SXR2230P: SocInfo(QcomChipset.SXR2230P, HtpInfo(HtpArch.V69, 8)),
7172
QcomChipset.SXR2330P: SocInfo(QcomChipset.SXR2330P, HtpInfo(HtpArch.V79, 8)),
73+
QcomChipset.QCS9100: SocInfo(QcomChipset.QCS9100, HtpInfo(HtpArch.V73, 8)),
7274
}
7375

7476

0 commit comments

Comments
 (0)