Skip to content

Commit ac975cd

Browse files
authored
Merge branch 'main' into pmu-data-overlay
2 parents 4e6b920 + 3485495 commit ac975cd

Some content is hidden

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

73 files changed

+371
-84
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_embedded --job_number ${parallelism} --release
2222
}
2323

2424
set_up_aot() {

.github/workflows/pull.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,8 @@ jobs:
909909
910910
test-samsung-models-linux:
911911
name: test-samsung-models-linux
912+
# Skip this job if the pull request is from a fork (secrets are not available)
913+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
912914
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
913915
permissions:
914916
id-token: write

backends/aoti/common_shims.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ int32_t aoti_torch_dtype_int32() {
184184
return 3; // PyTorch's int32 dtype code
185185
}
186186

187+
int32_t aoti_torch_dtype_bool() {
188+
return 11; // PyTorch's bool dtype code
189+
}
190+
187191
int32_t aoti_torch_dtype_int64() {
188192
return 4; // PyTorch's int64 dtype code
189193
}

backends/aoti/common_shims.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ int32_t aoti_torch_dtype_int8();
6363
int32_t aoti_torch_dtype_int16();
6464
int32_t aoti_torch_dtype_int32();
6565
int32_t aoti_torch_dtype_int64();
66+
int32_t aoti_torch_dtype_bool();
6667

6768
// Dtype utility function needed by Metal backend
6869
size_t aoti_torch_dtype_element_size(int32_t dtype);

backends/aoti/tests/test_common_shims.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,14 @@ TEST_F(CommonShimsTest, IndependentCaches) {
322322
// Sizes and strides pointers should be different (different caches)
323323
EXPECT_NE(sizes_ptr1, strides_ptr1);
324324
}
325+
326+
// Test all dtype functions return correct PyTorch dtype codes
327+
TEST_F(CommonShimsTest, AllDtypesReturnCorrectValues) {
328+
EXPECT_EQ(aoti_torch_dtype_float32(), 6); // PyTorch's float32 dtype code
329+
EXPECT_EQ(aoti_torch_dtype_bfloat16(), 15); // PyTorch's bfloat16 dtype code
330+
EXPECT_EQ(aoti_torch_dtype_int8(), 1); // PyTorch's int8 dtype code
331+
EXPECT_EQ(aoti_torch_dtype_int16(), 2); // PyTorch's int16 dtype code
332+
EXPECT_EQ(aoti_torch_dtype_int32(), 3); // PyTorch's int32 dtype code
333+
EXPECT_EQ(aoti_torch_dtype_int64(), 4); // PyTorch's int64 dtype code
334+
EXPECT_EQ(aoti_torch_dtype_bool(), 11); // PyTorch's bool dtype code
335+
}

backends/aoti/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ inline executorch::aten::ScalarType dtype_to_scalar_type(int32_t dtype) {
4545
return executorch::aten::ScalarType::Long;
4646
case 6: // PyTorch's float32 dtype code
4747
return executorch::aten::ScalarType::Float;
48+
case 11: // PyTorch's bool dtype code
49+
return executorch::aten::ScalarType::Bool;
4850
case 15: // PyTorch's bfloat16 dtype code
4951
return executorch::aten::ScalarType::BFloat16;
5052
// Future support for additional dtypes can be added here

backends/cuda/runtime/utils.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum class SupportedDTypes : int32_t {
6262
INT32 = 3, // PyTorch's int32 dtype code
6363
INT64 = 4, // PyTorch's int64 dtype code
6464
FLOAT32 = 6, // PyTorch's float32 dtype code
65+
BOOL = 11, // PyTorch's bool dtype code
6566
BFLOAT16 = 15, // PyTorch's bfloat16 dtype code
6667
};
6768

@@ -84,6 +85,7 @@ inline bool is_dtype_supported_in_et_cuda(int32_t dtype) {
8485
case static_cast<int32_t>(SupportedDTypes::INT32):
8586
case static_cast<int32_t>(SupportedDTypes::INT64):
8687
case static_cast<int32_t>(SupportedDTypes::FLOAT32):
88+
case static_cast<int32_t>(SupportedDTypes::BOOL):
8789
case static_cast<int32_t>(SupportedDTypes::BFLOAT16):
8890
return true;
8991
default:
@@ -96,13 +98,14 @@ inline AOTITorchError validate_dtype(int32_t dtype) {
9698
ET_CHECK_OR_RETURN_ERROR(
9799
is_dtype_supported_in_et_cuda(dtype),
98100
InvalidArgument,
99-
"Unsupported dtype: %d. Supported dtypes: %d (int8), %d (int16), %d (int32), %d (int64), %d (float32), %d (bfloat16)",
101+
"Unsupported dtype: %d. Supported dtypes: %d (int8), %d (int16), %d (int32), %d (int64), %d (float32), %d (bool), %d (bfloat16)",
100102
dtype,
101103
static_cast<int32_t>(SupportedDTypes::INT8),
102104
static_cast<int32_t>(SupportedDTypes::INT16),
103105
static_cast<int32_t>(SupportedDTypes::INT32),
104106
static_cast<int32_t>(SupportedDTypes::INT64),
105107
static_cast<int32_t>(SupportedDTypes::FLOAT32),
108+
static_cast<int32_t>(SupportedDTypes::BOOL),
106109
static_cast<int32_t>(SupportedDTypes::BFLOAT16));
107110

108111
return Error::Ok;

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: 101 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ set -o xtrace
2525
usage() {
2626
echo "Usage: Build the aarch64 version of executor runner or the python interface of Qnn Manager"
2727
echo "First, you need to set the environment variable for QNN_SDK_ROOT"
28-
echo ", and if you want to build the aarch64 version of executor runner"
28+
echo ", and if you want to build the android version of executor runner"
2929
echo ", you need to export ANDROID_NDK_ROOT=/path/to/android_ndkXX"
30+
echo "(or export TOOLCHAIN_ROOT_HOST=/path/to/sysroots/xx_host, "
31+
echo "TOOLCHAIN_ROOT_TARGET=/path/to/sysroots/xx_target for linux embedded with --enable_linux_embedded)"
3032
echo "e.g.: executorch$ ./backends/qualcomm/scripts/build.sh --skip_x86_64"
3133
exit 1
3234
}
@@ -36,8 +38,10 @@ usage() {
3638

3739
BUILD_X86_64="true"
3840
CMAKE_X86_64="build-x86"
39-
BUILD_AARCH64="true"
40-
CMAKE_AARCH64="build-android"
41+
BUILD_ANDROID="true"
42+
CMAKE_ANDROID="build-android"
43+
BUILD_OE_LINUX="false"
44+
CMAKE_OE_LINUX="build-oe-linux"
4145
CLEAN="true"
4246
BUILD_TYPE="RelWithDebInfo"
4347
BUILD_JOB_NUMBER="16"
@@ -50,7 +54,7 @@ if [ -z BUCK2 ]; then
5054
BUCK2="buck2"
5155
fi
5256

53-
long_options=skip_x86_64,skip_aarch64,no_clean,release,job_number:
57+
long_options=skip_x86_64,skip_linux_android,skip_linux_embedded,enable_linux_embedded,no_clean,release,job_number:
5458

5559
parsed_args=$(getopt -a --options '' --longoptions $long_options --name "$0" -- "$@")
5660
eval set -- "$parsed_args"
@@ -59,7 +63,9 @@ eval set -- "$parsed_args"
5963
while true ; do
6064
case "$1" in
6165
--skip_x86_64) BUILD_X86_64="false"; shift;;
62-
--skip_aarch64) BUILD_AARCH64="false"; shift;;
66+
--skip_linux_android) BUILD_ANDROID="false"; shift;;
67+
--skip_linux_embedded) BUILD_OE_LINUX="false"; shift;;
68+
--enable_linux_embedded) BUILD_ANDROID="false"; BUILD_OE_LINUX="true"; shift;;
6369
--no_clean) CLEAN="false"; shift;;
6470
--release) BUILD_TYPE="Release"; shift;;
6571
--job_number) BUILD_JOB_NUMBER="$2"; shift 2;;
@@ -69,13 +75,13 @@ done
6975

7076
PRJ_ROOT="$( cd "$(dirname "$0")/../../.." ; pwd -P)"
7177

72-
if [ "$BUILD_AARCH64" = true ]; then
78+
if [ "$BUILD_ANDROID" = true ]; then
7379
if [[ -z ${ANDROID_NDK_ROOT} ]]; then
7480
echo "Please export ANDROID_NDK_ROOT=/path/to/android_ndkXX"
7581
exit -1
7682
fi
7783

78-
BUILD_ROOT=$PRJ_ROOT/$CMAKE_AARCH64
84+
BUILD_ROOT=$PRJ_ROOT/$CMAKE_ANDROID
7985
if [ "$CLEAN" = true ]; then
8086
rm -rf $BUILD_ROOT && mkdir $BUILD_ROOT
8187
else
@@ -143,6 +149,94 @@ if [ "$BUILD_AARCH64" = true ]; then
143149
cmake --build $LLAMA_EXAMPLE_ROOT -j$BUILD_JOB_NUMBER
144150
fi
145151

152+
if [ "$BUILD_OE_LINUX" = true ]; then
153+
if [[ -z ${TOOLCHAIN_ROOT_HOST} ]]; then
154+
echo "Please export e.g. TOOLCHAIN_ROOT_HOST=/path/to/sysroots/x86_64-qtisdk-linux"
155+
exit -1
156+
fi
157+
if [[ -z ${TOOLCHAIN_ROOT_TARGET} ]]; then
158+
echo "Please export e.g. TOOLCHAIN_ROOT_TARGET=/path/to/sysroots/armv8a-oe-linux"
159+
exit -1
160+
fi
161+
162+
BUILD_ROOT=$PRJ_ROOT/$CMAKE_OE_LINUX
163+
if [ "$CLEAN" = true ]; then
164+
rm -rf $BUILD_ROOT && mkdir $BUILD_ROOT
165+
else
166+
# Force rebuild flatccrt for the correct platform
167+
cd $BUILD_ROOT/third-party/flatcc && make clean
168+
fi
169+
170+
TOOLCHAN_PREFIX=$TOOLCHAIN_ROOT_HOST/usr/bin/aarch64-oe-linux/aarch64-oe-linux-
171+
cd $BUILD_ROOT
172+
cmake .. \
173+
-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT \
174+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
175+
-DCMAKE_C_COMPILER=${TOOLCHAN_PREFIX}gcc \
176+
-DCMAKE_CXX_COMPILER=${TOOLCHAN_PREFIX}g++ \
177+
-DCMAKE_SYSROOT=$TOOLCHAIN_ROOT_TARGET \
178+
-DCMAKE_SYSTEM_NAME=Linux \
179+
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
180+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
181+
-DEXECUTORCH_BUILD_QNN=ON \
182+
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
183+
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON \
184+
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON \
185+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
186+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
187+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
188+
-DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON \
189+
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
190+
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
191+
-DEXECUTORCH_ENABLE_LOGGING=ON \
192+
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
193+
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
194+
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
195+
-B$BUILD_ROOT
196+
197+
cmake --build $BUILD_ROOT -j$BUILD_JOB_NUMBER --target install
198+
199+
EXAMPLE_ROOT=examples/qualcomm
200+
CMAKE_PREFIX_PATH="${BUILD_ROOT};${BUILD_ROOT}/third-party/gflags;"
201+
202+
cmake $PRJ_ROOT/$EXAMPLE_ROOT \
203+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
204+
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
205+
-DSUPPORT_REGEX_LOOKAHEAD=ON \
206+
-DBUILD_TESTING=OFF \
207+
-DEXECUTORCH_ENABLE_LOGGING=ON \
208+
-DCMAKE_C_COMPILER=${TOOLCHAN_PREFIX}gcc \
209+
-DCMAKE_CXX_COMPILER=${TOOLCHAN_PREFIX}g++ \
210+
-DCMAKE_SYSROOT=$TOOLCHAIN_ROOT_TARGET \
211+
-DCMAKE_SYSTEM_NAME=Linux \
212+
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
213+
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
214+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
215+
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
216+
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
217+
-B$EXAMPLE_ROOT
218+
219+
cmake --build $EXAMPLE_ROOT -j$BUILD_JOB_NUMBER
220+
221+
LLAMA_EXAMPLE_ROOT=examples/models/llama
222+
cmake $PRJ_ROOT/$LLAMA_EXAMPLE_ROOT \
223+
-DBUILD_TESTING=OFF \
224+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
225+
-DCMAKE_C_COMPILER=${TOOLCHAN_PREFIX}gcc \
226+
-DCMAKE_CXX_COMPILER=${TOOLCHAN_PREFIX}g++ \
227+
-DCMAKE_SYSROOT=$TOOLCHAIN_ROOT_TARGET \
228+
-DCMAKE_SYSTEM_NAME=Linux \
229+
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
230+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
231+
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
232+
-DEXECUTORCH_ENABLE_LOGGING=ON \
233+
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
234+
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
235+
-B$LLAMA_EXAMPLE_ROOT
236+
237+
cmake --build $LLAMA_EXAMPLE_ROOT -j$BUILD_JOB_NUMBER
238+
fi
239+
146240
if [ "$BUILD_X86_64" = true ]; then
147241
BUILD_ROOT=$PRJ_ROOT/$CMAKE_X86_64
148242
if [ "$CLEAN" = true ]; then

0 commit comments

Comments
 (0)