Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick commits for Qualcomm binary and Android demo app fix #2995

Closed
wants to merge 5 commits into from
Closed
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
22 changes: 13 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,27 @@ add_subdirectory(schema)
# Only contains primitive operators; does not contain portable kernels or other
# full operators. Does not contain any backends.
#

add_library(executorch ${_executorch__srcs})
target_link_libraries(executorch PRIVATE program_schema)
target_link_options_shared_lib(executorch)
add_library(executorch_no_prim_ops ${_executorch_no_prim_ops__srcs})
target_link_libraries(executorch_no_prim_ops PRIVATE program_schema)
# Check if dl exists for this toolchain and only then link it.
find_library(DL_LIBRARY_EXISTS NAMES dl)
# Check if the library was found
if(DL_LIBRARY_EXISTS)
target_link_libraries(executorch PRIVATE dl) # For dladdr()
target_link_libraries(executorch_no_prim_ops PRIVATE dl) # For dladdr()
endif()
target_include_directories(executorch PUBLIC ${_common_include_directories})
target_compile_options(executorch PUBLIC ${_common_compile_options})
target_include_directories(executorch_no_prim_ops PUBLIC ${_common_include_directories})
target_compile_options(executorch_no_prim_ops PUBLIC ${_common_compile_options})
if(MAX_KERNEL_NUM)
target_compile_definitions(executorch
target_compile_definitions(executorch_no_prim_ops
PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM})
endif()

add_library(executorch ${_executorch__srcs})
target_link_libraries(executorch PRIVATE executorch_no_prim_ops)
target_include_directories(executorch PUBLIC ${_common_include_directories})
target_compile_options(executorch PUBLIC ${_common_compile_options})
target_link_options_shared_lib(executorch)

#
# portable_ops_lib: A library to register core ATen ops using portable kernels,
# see kernels/portable/CMakeLists.txt.
Expand Down Expand Up @@ -406,7 +410,7 @@ endif()
# Install `executorch` library as well as `executorch-config.cmake` under
# ${CMAKE_INSTALL_PREFIX}/
install(
TARGETS executorch
TARGETS executorch executorch_no_prim_ops
DESTINATION lib
INCLUDES
DESTINATION ${_common_include_directories})
Expand Down
6 changes: 3 additions & 3 deletions backends/apple/coreml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ target_include_directories(
)
target_link_libraries(
coremldelegate PRIVATE
executorch
executorch_no_prim_ops
)

if(EXECUTORCH_BUILD_SDK)
Expand Down Expand Up @@ -174,7 +174,7 @@ find_library(SQLITE_LIBRARY sqlite3)

target_link_libraries(coremldelegate
PRIVATE
executorch
executorch_no_prim_ops
${ACCELERATE_FRAMEWORK}
${COREML_FRAMEWORK}
${FOUNDATION_FRAMEWORK}
Expand All @@ -185,7 +185,7 @@ target_compile_options(coremldelegate PRIVATE "-fobjc-arc")
target_compile_options(coremldelegate PRIVATE "-fno-exceptions")

if(EXECUTORCH_BUILD_SDK)
target_compile_options(executorch PUBLIC -DET_EVENT_TRACER_ENABLED)
target_compile_options(executorch_no_prim_ops PUBLIC -DET_EVENT_TRACER_ENABLED)
target_compile_options(coremldelegate PRIVATE "-frtti")
target_compile_options(libprotobuf-lite PRIVATE "-frtti")
else()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
C9E7D7952AB3F9BF00CCAE5D /* ETCoreMLModelManagerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D78D2AB3F9BF00CCAE5D /* ETCoreMLModelManagerTests.mm */; };
C9E7D7962AB3F9BF00CCAE5D /* KeyValueStoreTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D78E2AB3F9BF00CCAE5D /* KeyValueStoreTests.mm */; };
C9E7D7A22AB3FBB200CCAE5D /* CoreMLBackendDelegateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D7A12AB3FBB200CCAE5D /* CoreMLBackendDelegateTests.mm */; };
F24817E52BC655E100E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -297,6 +298,7 @@
C9EA3DB22B71A2B200B7D7BD /* CoreML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreML.framework; path = System/Library/Frameworks/CoreML.framework; sourceTree = SDKROOT; };
C9EA3FDE2B73EEA000B7D7BD /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
C9EA3FE52B73EF6300B7D7BD /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libexecutorch_no_prim_ops.a; path = ../libraries/libexecutorch_no_prim_ops.a; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -305,6 +307,7 @@
buildActionMask = 2147483647;
files = (
C94D510F2ABDF87500AF47FD /* Accelerate.framework in Frameworks */,
F24817E52BC655E100E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */,
C94D510E2ABDF86800AF47FD /* libsqlite3.tbd in Frameworks */,
C94D50D92ABD7B2400AF47FD /* CoreML.framework in Frameworks */,
C99883862B95AD7D000953A3 /* libprotobuf-lite.a in Frameworks */,
Expand Down Expand Up @@ -523,6 +526,7 @@
C96560942AABFDCE005F8126 /* libsqlite3.tbd */,
C96560922AABF992005F8126 /* CoreML.framework */,
C96560902AABF982005F8126 /* Accelerate.framework */,
F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */,
C965608D2AABF72A005F8126 /* libexecutorch.a */,
);
name = "Recovered References";
Expand Down
1 change: 1 addition & 0 deletions backends/apple/coreml/scripts/build_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ cmake --build "$CMAKE_PROTOBUF_BUILD_DIR_PATH" -j9 -t libprotobuf-lite
echo "ExecuTorch: Copying libraries"
mkdir "$LIBRARIES_DIR_PATH"
cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch.a" "$LIBRARIES_DIR_PATH"
cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch_no_prim_ops.a" "$LIBRARIES_DIR_PATH"
cp -f "$CMAKE_PROTOBUF_BUILD_DIR_PATH/libprotobuf-lite.a" "$LIBRARIES_DIR_PATH"

#Copy ExecuTorch headers
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/mps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ target_link_libraries(mpsdelegate
PRIVATE
bundled_program
mps_schema
${_executor_runner_libs}
executorch_no_prim_ops
${FOUNDATION_FRAMEWORK}
${METAL_FRAMEWORK}
${MPS_FRAMEWORK}
Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ target_link_libraries(qnn_executorch_backend
qnn_executorch_header
qnn_schema
qnn_manager
executorch
executorch_no_prim_ops
qcir_utils
)
target_link_libraries(utils
Expand Down
2 changes: 1 addition & 1 deletion build/build_apple_frameworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PORTABLE=OFF
QUANTIZED=OFF
XNNPACK=OFF
HEADERS_PATH="include"
EXECUTORCH_FRAMEWORK="executorch:libexecutorch.a,libextension_apple.a,libextension_data_loader.a,libextension_module.a:$HEADERS_PATH"
EXECUTORCH_FRAMEWORK="executorch:libexecutorch.a,libexecutorch_no_prim_ops.a,libextension_apple.a,libextension_data_loader.a,libextension_module.a:$HEADERS_PATH"
COREML_FRAMEWORK="coreml_backend:libcoremldelegate.a:"
CUSTOM_FRAMEWORK="custom_backend:libcustom_ops.a,libcustom_ops_lib.a:"
MPS_FRAMEWORK="mps_backend:libmpsdelegate.a:"
Expand Down
27 changes: 27 additions & 0 deletions build/cmake_deps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ excludes = [
buck_targets = [
"//runtime/executor:program",
]
deps = [
"executorch_no_prim_ops",
]
filters = [
".cpp$",
]


[targets.executorch_no_prim_ops]
buck_targets = [
"//runtime/executor:program_no_prim_ops",
]
deps = [
"program_schema",
]
Expand All @@ -43,6 +55,7 @@ excludes = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
]

[targets.optimized_kernels]
Expand All @@ -59,6 +72,7 @@ excludes = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
"portable_kernels",
]

Expand All @@ -76,6 +90,7 @@ excludes = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
"portable_kernels",
]

Expand All @@ -97,6 +112,7 @@ filters = [
excludes = [
]
deps = [
"executorch_no_prim_ops",
"executorch",
]

Expand All @@ -113,6 +129,7 @@ filters = [
".cpp$",
]
deps = [
"executorch_no_prim_ops",
"executorch",
]

Expand All @@ -125,6 +142,7 @@ filters = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
"extension_data_loader",
]

Expand All @@ -137,6 +155,7 @@ filters = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
]

# ---------------------------------- extension end ----------------------------------
Expand All @@ -154,6 +173,7 @@ excludes = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
"portable_kernels",
"quantized_kernels",
]
Expand All @@ -169,6 +189,7 @@ excludes = [
"^codegen",
]
deps = [
"executorch_no_prim_ops",
"executorch",
]
# ---------------------------------- binary end ----------------------------------
Expand All @@ -185,6 +206,7 @@ excludes = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
"portable_kernels",
]

Expand All @@ -197,6 +219,7 @@ filters = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
]

[targets.mps_schema]
Expand All @@ -222,6 +245,7 @@ excludes = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
"xnnpack_backend",
"portable_kernels",
]
Expand All @@ -235,6 +259,7 @@ filters = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
]

[targets.xnnpack_dynamic_quant_utils]
Expand Down Expand Up @@ -275,6 +300,7 @@ excludes = [
]
deps = [
"executorch",
"executorch_no_prim_ops",
"optimized_kernels",
"xnnpack_backend",
]
Expand All @@ -292,6 +318,7 @@ excludes = [
deps = [
"custom_ops",
"executorch",
"executorch_no_prim_ops",
"extension_data_loader",
"extension_module",
"portable_kernels",
Expand Down
33 changes: 13 additions & 20 deletions build/executorch-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,20 @@
cmake_minimum_required(VERSION 3.19)

set(_root "${CMAKE_CURRENT_LIST_DIR}/../..")
add_library(executorch STATIC IMPORTED)
find_library(
EXECUTORCH_LIBRARY_PATH executorch
HINTS "${_root}"
CMAKE_FIND_ROOT_PATH_BOTH
)
set_target_properties(
executorch PROPERTIES IMPORTED_LOCATION "${EXECUTORCH_LIBRARY_PATH}"
)
target_include_directories(executorch INTERFACE ${_root})
set(required_lib_list executorch executorch_no_prim_ops portable_kernels)
foreach(lib ${required_lib_list})
set(lib_var "LIB_${lib}")
add_library(${lib} STATIC IMPORTED)
find_library(
${lib_var} ${lib} HINTS "${_root}" CMAKE_FIND_ROOT_PATH_BOTH
)
set_target_properties(
${lib} PROPERTIES IMPORTED_LOCATION "${${lib_var}}"
)
target_include_directories(${lib} INTERFACE ${_root})
endforeach()

add_library(portable_kernels STATIC IMPORTED)
find_library(
PORTABLE_KERNELS_PATH portable_kernels
HINTS "${_root}"
CMAKE_FIND_ROOT_PATH_BOTH
)
set_target_properties(
portable_kernels PROPERTIES IMPORTED_LOCATION "${PORTABLE_KERNELS_PATH}"
)
target_include_directories(portable_kernels INTERFACE ${_root})
target_link_libraries(executorch INTERFACE executorch_no_prim_ops)

if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(FLATCCRT_LIB flatccrt_d)
Expand Down
7 changes: 6 additions & 1 deletion docs/source/build-run-qualcomm-ai-engine-direct-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Python APIs on x64 are required to compile models to Qualcomm AI Engine Direct b

```bash
cd $EXECUTORCH_ROOT
# Workaround for fbs files in exir/_serialize
cp schema/program.fbs exir/_serialize/program.fbs
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs

mkdir build_x86_64
cd build_x86_64
cmake .. -DEXECUTORCH_BUILD_QNN=ON -DQNN_SDK_ROOT=${QNN_SDK_ROOT}
Expand All @@ -138,8 +142,8 @@ mkdir build_android
cd build_android
# build executorch & qnn_executorch_backend
cmake .. \
-DBUCK2=buck2 \
-DCMAKE_INSTALL_PREFIX=$PWD \
-DEXECUTORCH_BUILD_SDK=ON \
-DEXECUTORCH_BUILD_QNN=ON \
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
Expand Down Expand Up @@ -220,6 +224,7 @@ So, we can run `qnn_executor_runner` like
```bash
adb push ./deeplab_v3/dlv3_qnn.pte ${DEVICE_DIR}
adb push ${EXECUTORCH_ROOT}/build_android/examples/qualcomm/qnn_executor_runner ${DEVICE_DIR}
adb push ${EXECUTORCH_ROOT}/build_android/lib/libqnn_executorch_backend.so ${DEVICE_DIR}
adb shell "cd ${DEVICE_DIR} \
&& export LD_LIBRARY_PATH=${DEVICE_DIR} \
&& export ADSP_LIBRARY_PATH=${DEVICE_DIR} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
C94D51662ACFCBCB00AF47FD /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C94D51652ACFCBCB00AF47FD /* Accelerate.framework */; };
C94D51682ACFCC7100AF47FD /* libcoremldelegate.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C94D51672ACFCC7100AF47FD /* libcoremldelegate.a */; };
C988D69D2B998CDE00979CF6 /* libprotobuf-lite.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C988D69C2B998CD700979CF6 /* libprotobuf-lite.a */; };
F24817E72BC65B2000E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F24817E62BC65B2000E80D98 /* libexecutorch_no_prim_ops.a */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -41,6 +42,7 @@
C94D51652ACFCBCB00AF47FD /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
C94D51672ACFCC7100AF47FD /* libcoremldelegate.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcoremldelegate.a; path = libraries/libcoremldelegate.a; sourceTree = "<group>"; };
C988D69C2B998CD700979CF6 /* libprotobuf-lite.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libprotobuf-lite.a"; path = "libraries/libprotobuf-lite.a"; sourceTree = "<group>"; };
F24817E62BC65B2000E80D98 /* libexecutorch_no_prim_ops.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libexecutorch_no_prim_ops.a; path = libraries/libexecutorch_no_prim_ops.a; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -49,6 +51,7 @@
buildActionMask = 2147483647;
files = (
38626BB52B225A890059413D /* libetdump.a in Frameworks */,
F24817E72BC65B2000E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */,
38626BB42B225A560059413D /* libflatccrt.a in Frameworks */,
C94D51682ACFCC7100AF47FD /* libcoremldelegate.a in Frameworks */,
C94D51662ACFCBCB00AF47FD /* Accelerate.framework in Frameworks */,
Expand Down Expand Up @@ -90,6 +93,7 @@
C94D515C2ACFCBA000AF47FD /* libexecutorch.a */,
C94D51612ACFCBBA00AF47FD /* libsqlite3.tbd */,
C94D51672ACFCC7100AF47FD /* libcoremldelegate.a */,
F24817E62BC65B2000E80D98 /* libexecutorch_no_prim_ops.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down
1 change: 1 addition & 0 deletions examples/apple/coreml/scripts/build_executor_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ cp -rf "$COREML_DIR_PATH/runtime/include/" "$INCLUDE_DIR_PATH"
echo "ExecuTorch: Copying libraries"
mkdir "$LIBRARIES_DIR_PATH"
find "$CMAKE_BUILD_DIR_PATH/" -name 'libexecutorch.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH" \;
find "$CMAKE_BUILD_DIR_PATH/" -name 'libexecutorch_no_prim_ops.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH" \;
find "$CMAKE_BUILD_DIR_PATH/" -name 'libetdump.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH" \;
find "$CMAKE_BUILD_DIR_PATH/" -name 'libcoremldelegate.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH" \;
find "$CMAKE_BUILD_DIR_PATH/" -name 'libprotobuf-lite.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH" \;
Expand Down
5 changes: 5 additions & 0 deletions examples/arm/executor_runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ add_library(executorch STATIC IMPORTED)
set_property(TARGET executorch PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/libexecutorch.a")

add_library(executorch_no_prim_ops STATIC IMPORTED)
set_property(TARGET executorch_no_prim_ops PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/libexecutorch_no_prim_ops.a")
target_link_libraries(executorch INTERFACE executorch_no_prim_ops)

add_library(executorch_delegate_ethos_u STATIC IMPORTED)
set_property(TARGET executorch_delegate_ethos_u PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/backends/arm/libexecutorch_delegate_ethos_u.a")
Expand Down
Loading
Loading