Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion backends/qualcomm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ add_compile_options("-Wall" "-Werror" "-Wno-sign-compare")
# which can be ignored by GNU. So we make it a warning, not an error in GNU.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options("-Wno-error=attributes")
add_link_options("-flto=auto")
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
Expand All @@ -67,7 +68,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
# --gc-sections is added by torch.
add_compile_options(
"-O3" "-ffunction-sections" "-fdata-sections" "-frtti"
"-Wno-unused-command-line-argument"
)
endif()

Expand Down Expand Up @@ -259,6 +259,22 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
pybind11_strip(PyQnnWrapperAdaptor)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
# need to allow exceptions in pybind
set(_pybind_compile_options
-Wno-deprecated-declarations
-fPIC
-frtti
-fexceptions
)
target_compile_options(
PyQnnManagerAdaptor PUBLIC ${_pybind_compile_options}
)
target_compile_options(
PyQnnWrapperAdaptor PUBLIC ${_pybind_compile_options}
)
endif()

add_subdirectory(
${QNN_EXECUTORCH_ROOT_DIR}/aot/python
${CMAKE_CURRENT_BINARY_DIR}/qnn_executorch/python
Expand Down
14 changes: 10 additions & 4 deletions backends/qualcomm/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ if [ "$BUILD_AARCH64" = true ]; then
echo "Please export ANDROID_NDK_ROOT=/path/to/android_ndkXX"
exit -1
fi

BUILD_ROOT=$PRJ_ROOT/$CMAKE_AARCH64
if [ "$CLEAN" = true ]; then
rm -rf $BUILD_ROOT && mkdir $BUILD_ROOT
else
# Force rebuild flatccrt for the correct platform
cd $BUILD_ROOT/sdk && make clean
fi

cd $BUILD_ROOT
Expand Down Expand Up @@ -103,15 +107,17 @@ if [ "$BUILD_AARCH64" = true ]; then
fi

if [ "$BUILD_X86_64" = true ]; then
# Build python interface
BUILD_ROOT=$PRJ_ROOT/$CMAKE_X86_64
if [ "$CLEAN" = true ]; then
rm -rf $BUILD_ROOT && mkdir $BUILD_ROOT
else
# Force rebuild flatccrt for the correct platform
cd $BUILD_ROOT/sdk && make clean
fi

cd $BUILD_ROOT
# TODO: Use CMAKE_BUILD_TYPE=RelWithDebInfo, and handle flatcc issues
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT \
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
-DEXECUTORCH_BUILD_QNN=ON \
Expand All @@ -131,7 +137,7 @@ if [ "$BUILD_X86_64" = true ]; then
CMAKE_PREFIX_PATH="${BUILD_ROOT}/lib/cmake/ExecuTorch;${BUILD_ROOT}/third-party/gflags;"

cmake $PRJ_ROOT/$EXAMPLE_ROOT \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
Expand Down
8 changes: 3 additions & 5 deletions examples/qualcomm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ list(PREPEND _qnn_executor_runner__srcs
)
# preprocess llama runner src files
list(TRANSFORM _qnn_llama_runner__srcs PREPEND "${EXECUTORCH_SOURCE_DIR}/")
list(FILTER _qnn_llama_runner__srcs EXCLUDE REGEX ".*runner.cpp$")
list(FILTER _qnn_llama_runner__srcs EXCLUDE REGEX ".*(/runner/).*")
message(ERROR ${_qnn_llama_runner__srcs})
list(PREPEND _qnn_llama_runner__srcs
${CMAKE_CURRENT_LIST_DIR}/executor_runner/qnn_llama_runner.cpp
${CMAKE_CURRENT_LIST_DIR}/llama2/runner/runner.cpp
${CMAKE_CURRENT_LIST_DIR}/llama2/runner/runner.h
)
# preprocess qaihub llama runner src files
list(TRANSFORM _qnn_qaihub_llama_runner__srcs PREPEND "${EXECUTORCH_SOURCE_DIR}/")
list(FILTER _qnn_qaihub_llama_runner__srcs EXCLUDE REGEX ".*runner.cpp*$")
list(FILTER _qnn_qaihub_llama_runner__srcs EXCLUDE REGEX ".*(/runner/).*")
list(PREPEND _qnn_qaihub_llama_runner__srcs
${CMAKE_CURRENT_LIST_DIR}/executor_runner/qnn_qaihub_llama_runner.cpp
${CMAKE_CURRENT_LIST_DIR}/llama2/qaihub_runner/runner.cpp
Expand All @@ -103,9 +104,6 @@ target_link_libraries(
qnn_executor_runner qnn_executorch_backend full_portable_ops_lib etdump
${FLATCCRT_LIB} gflags
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_options(qnn_executor_runner PUBLIC -fsanitize=undefined)
endif()

# build llama runner
add_executable(qnn_llama_runner ${_qnn_llama_runner__srcs})
Expand Down
9 changes: 4 additions & 5 deletions examples/qualcomm/llama2/qaihub_runner/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@

#include <executorch/examples/qualcomm/llama2/qaihub_runner/runner.h>
#include <executorch/extension/evalue_util/print_evalue.h>
#include <executorch/extension/llm/runner/util.h>
#include <executorch/extension/llm/tokenizer/bpe_tokenizer.h>
#include <executorch/extension/runner_util/managed_tensor.h>
#include <executorch/runtime/core/exec_aten/exec_aten.h>
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
#include <executorch/runtime/platform/log.h>

#include <ctime>
#include <memory>
#include <sstream>

#include <executorch/examples/models/llama2/runner/util.h>
#include <executorch/runtime/core/exec_aten/exec_aten.h>
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
#include <executorch/runtime/platform/log.h>

#if defined(__aarch64__)
#include "arm_neon.h"
#endif
Expand Down
9 changes: 4 additions & 5 deletions examples/qualcomm/llama2/runner/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@

#include <executorch/examples/qualcomm/llama2/runner/runner.h>
#include <executorch/extension/evalue_util/print_evalue.h>
#include <executorch/extension/llm/runner/util.h>
#include <executorch/extension/llm/tokenizer/bpe_tokenizer.h>
#include <executorch/extension/runner_util/managed_tensor.h>
#include <executorch/runtime/core/exec_aten/exec_aten.h>
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
#include <executorch/runtime/platform/log.h>

#include <ctime>
#include <memory>
#include <sstream>

#include <executorch/examples/models/llama2/runner/util.h>
#include <executorch/runtime/core/exec_aten/exec_aten.h>
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
#include <executorch/runtime/platform/log.h>

namespace torch {
namespace executor {

Expand Down
4 changes: 4 additions & 0 deletions sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ set(FLATCC_REFLECTION
OFF
CACHE BOOL ""
)
set(FLATCC_DEBUG_CLANG_SANITIZE
OFF
CACHE BOOL ""
)
set(_flatcc_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/flatcc)
add_subdirectory(${_flatcc_source_dir} ${CMAKE_BINARY_DIR}/third-party/flatcc)

Expand Down