Skip to content

Commit 7cf411d

Browse files
committed
Update base for Update on "Use unlifted export pass to tag delegated constants"
Use the unlifted pass to tag constants for delegates. Implications: - Tagging must happen on the unlifted ep.module(), before going into to_edge_transform_and_lower/to_edge. Why? - The unlifted graph contains constants in getattr nodes, which is a convenient way to isolate constants. - After going into to_edge_transform_and_lower/to_edge, transforms happen on the graph_module, which is lifted. - The lifted graph requires the ep graph signature to differentiate constants via the `is_param` function. However, in to_edge.transform, we do not have access to the ep. Baking the ep as an argument via partial function doesn't work, as the ep from earlier may be outdated. This means we are comparing an older ep to a newer graph_module, which may not have corresponding graph signatures etc. Differential Revision: [D79736684](https://our.internmc.facebook.com/intern/diff/D79736684/) [ghstack-poisoned]
2 parents 2db7014 + 9807fbe commit 7cf411d

File tree

129 files changed

+3594
-2409
lines changed

Some content is hidden

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

129 files changed

+3594
-2409
lines changed

.Package.swift/kernels_torchao/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_torchao_debug/dummy.swift

Whitespace-only changes.

.ci/scripts/test_llama_torchao_lowbit.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,22 @@ cmake -DPYTHON_EXECUTABLE=python \
2929
-DEXECUTORCH_ENABLE_LOGGING=1 \
3030
-DCMAKE_BUILD_TYPE=Release \
3131
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
32-
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON \
33-
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON \
34-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3532
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
33+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3634
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3735
-DEXECUTORCH_BUILD_XNNPACK=OFF \
3836
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
3937
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
38+
-DEXECUTORCH_BUILD_KERNELS_TORCHAO=ON \
39+
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON \
40+
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON \
4041
-DEXECUTORCH_BUILD_KERNELS_LLM=ON \
4142
-Bcmake-out .
42-
cmake --build cmake-out -j16 --target install --config Release
43+
cmake --build cmake-out -j16 --config Release --target install
4344

4445
# Install llama runner with torchao
4546
cmake -DPYTHON_EXECUTABLE=python \
46-
-DBUILD_TESTING=OFF \
4747
-DCMAKE_BUILD_TYPE=Release \
48-
-DEXECUTORCH_BUILD_KERNELS_LLM=ON \
49-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
50-
-DEXECUTORCH_BUILD_XNNPACK=OFF \
51-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
52-
-DEXECUTORCH_BUILD_TORCHAO=ON \
5348
-Bcmake-out/examples/models/llama \
5449
examples/models/llama
5550
cmake --build cmake-out/examples/models/llama -j16 --config Release

.ci/scripts/zephyr-utils.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# LICENSE file in the root directory of this source tree.
77

88
download_arm_zephyr_sdk () {
9-
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/zephyr-sdk-0.16.0_linux-x86_64.tar.xz
10-
tar -xf zephyr-sdk-0.16.0_linux-x86_64.tar.xz
11-
rm -f zephyr-sdk-0.16.0_linux-x86_64.tar.xz
9+
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.2/zephyr-sdk-0.17.2_linux-x86_64.tar.xz
10+
tar -xf zephyr-sdk-0.17.2_linux-x86_64.tar.xz
11+
rm -f zephyr-sdk-0.17.2_linux-x86_64.tar.xz
1212
}
1313

1414
setup_zephyr_et_module () {

.github/workflows/trunk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
9393
# TODO @Bujji: Should see if this can be moved into the docker image itself
9494
download_arm_zephyr_sdk
95-
./zephyr-sdk-0.16.0/setup.sh -c -t arm-zephyr-eabi
95+
./zephyr-sdk-0.17.2/setup.sh -c -t arm-zephyr-eabi
9696
cd $ZEPHYR_PROJ_ROOT
9797
setup_zephyr_et_module
9898
@@ -485,7 +485,7 @@ jobs:
485485
eval "$(conda shell.bash hook)"
486486
487487
# Install requirements
488-
${CONDA_RUN} EXECUTORCH_BUILD_TORCHAO=1 python install_executorch.py
488+
${CONDA_RUN} EXECUTORCH_BUILD_KERNELS_TORCHAO=1 python install_executorch.py
489489
${CONDA_RUN} sh examples/models/llama/install_requirements.sh
490490
491491
# Run test

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[submodule "backends/arm/third-party/ethos-u-core-driver"]
22
path = backends/arm/third-party/ethos-u-core-driver
33
url = https://git.gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-core-driver.git
4-
[submodule "backends/arm/third-party/serialization_lib"]
5-
path = backends/arm/third-party/serialization_lib
6-
url = https://git.gitlab.arm.com/tosa/tosa-serialization.git
74
[submodule "backends/vulkan/third-party/Vulkan-Headers"]
85
path = backends/vulkan/third-party/Vulkan-Headers
96
url = https://github.com/KhronosGroup/Vulkan-Headers

CMakeLists.txt

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
cmake_minimum_required(VERSION 3.29)
5151
project(executorch)
5252

53+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
54+
5355
include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
56+
include(${PROJECT_SOURCE_DIR}/tools/cmake/Codegen.cmake)
5457
include(${PROJECT_SOURCE_DIR}/tools/cmake/Utils.cmake)
5558
include(CMakeDependentOption)
5659
include(ExternalProject)
@@ -123,8 +126,6 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
123126
# Instead please use `find_package(executorch REQUIRED)` in the example
124127
# directory and add a new executable in the example `CMakeLists.txt`.
125128

126-
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
127-
128129
if(NOT EXECUTORCH_ENABLE_LOGGING)
129130
# Avoid pulling in the logging strings, which can be large. Note that this
130131
# will set the compiler flag for all targets in this directory, and for all
@@ -278,29 +279,6 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
278279
)
279280
endif()
280281

281-
if(EXECUTORCH_BUILD_KERNELS_TORCHAO)
282-
set(TORCHAO_BUILD_ATEN_OPS OFF)
283-
set(TORCHAO_BUILD_EXECUTORCH_OPS ON)
284-
set(TORCHAO_BUILD_CPU_AARCH64 ON)
285-
set(TORCHAO_ENABLE_ARM_NEON_DOT ON)
286-
287-
list(
288-
APPEND
289-
TORCHAO_INCLUDE_DIRS
290-
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include
291-
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include
292-
${EXECUTORCH_ROOT}/third-party/ao
293-
)
294-
295-
set(EXECUTORCH_INCLUDE_DIRS ${TORCHAO_INCLUDE_DIRS})
296-
297-
add_subdirectory(
298-
${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental
299-
)
300-
executorch_target_link_options_shared_lib(torchao_ops_executorch)
301-
list(APPEND _executorch_kernels torchao_ops_executorch)
302-
endif()
303-
304282
if(EXECUTORCH_BUILD_TESTS)
305283
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
306284
include(CTest)
@@ -343,6 +321,7 @@ if(NOT EXECUTORCH_SRCS_FILE)
343321
message(STATUS "executorch: Generating source lists")
344322
set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/executorch_srcs.cmake")
345323
extract_sources(${EXECUTORCH_SRCS_FILE})
324+
executorch_validate_build_variables()
346325
endif()
347326

348327
# This file defines the `_<target>__srcs` variables used below.
@@ -705,6 +684,65 @@ if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)
705684
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/threadpool)
706685
endif()
707686

687+
if(EXECUTORCH_BUILD_KERNELS_TORCHAO)
688+
if(NOT TARGET cpuinfo)
689+
message(
690+
FATAL_ERROR
691+
"EXECUTORCH_BUILD_KERNELS_TORCHAO requires EXECUTORCH_BUILD_CPUINFO be set ON"
692+
)
693+
endif()
694+
if(NOT TARGET pthreadpool)
695+
message(
696+
FATAL_ERROR
697+
"EXECUTORCH_BUILD_KERNELS_TORCHAO requires EXECUTORCH_BUILD_PTHREADPOOL be set ON"
698+
)
699+
endif()
700+
701+
# Configure TorchAO kernels
702+
set(TORCHAO_BUILD_ATEN_OPS OFF)
703+
set(TORCHAO_BUILD_EXECUTORCH_OPS ON)
704+
set(TORCHAO_BUILD_CPU_AARCH64 ON)
705+
set(TORCHAO_ENABLE_ARM_NEON_DOT ON)
706+
set(TORCHAO_BUILD_KLEIDIAI ON)
707+
708+
# TorchAO kernels look for EXECUTORCH_INCLUDE_DIRS
709+
if(DEFINED EXECUTORCH_INCLUDE_DIRS)
710+
message(FATAL_ERROR "EXECUTORCH_INCLUDE_DIRS is already defined")
711+
endif()
712+
set(EXECUTORCH_INCLUDE_DIRS
713+
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include
714+
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include
715+
)
716+
add_subdirectory(
717+
${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental
718+
)
719+
unset(EXECUTORCH_INCLUDE_DIRS)
720+
721+
executorch_target_link_options_shared_lib(torchao_ops_executorch)
722+
list(APPEND _executorch_kernels torchao_ops_executorch)
723+
724+
install(
725+
TARGETS torchao_ops_executorch torchao_kernels_aarch64
726+
EXPORT ExecuTorchTargets
727+
DESTINATION lib
728+
INCLUDES
729+
DESTINATION ${_common_include_directories}
730+
)
731+
# If using KleidiAI and XNNPACK has not installed it already, install it
732+
if(TORCHAO_BUILD_KLEIDIAI AND NOT (EXECUTORCH_BUILD_XNNPACK
733+
AND EXECUTORCH_XNNPACK_ENABLE_KLEIDI)
734+
)
735+
install(
736+
TARGETS kleidiai
737+
EXPORT ExecuTorchTargets
738+
DESTINATION lib
739+
INCLUDES
740+
DESTINATION ${_common_include_directories}
741+
)
742+
endif()
743+
744+
endif()
745+
708746
if(EXECUTORCH_BUILD_PYBIND)
709747

710748
# Add codegen tools subdirectory for selective_build pybind module

CMakePresets.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@
66
"hidden": true,
77
"binaryDir": "${sourceDir}/cmake-out"
88
},
9+
{
10+
"name": "android-arm64-v8a",
11+
"displayName": "Build executorch core and JNI bindings on android arm64-v8a",
12+
"inherits": ["common"],
13+
"binaryDir": "${sourceDir}/cmake-out-android-arm64-v8a",
14+
"cacheVariables": {
15+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/android.cmake",
16+
"ANDROID_ABI": "arm64-v8a"
17+
},
18+
"condition": {
19+
"type": "inList",
20+
"string": "${hostSystemName}",
21+
"list": ["Darwin", "Linux", "Windows"]
22+
}
23+
},
24+
{
25+
"name": "android-x86_64",
26+
"displayName": "Build executorch core and JNI bindings on android x86_64",
27+
"inherits": ["common"],
28+
"binaryDir": "${sourceDir}/cmake-out-android-x86_64",
29+
"cacheVariables": {
30+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/android.cmake",
31+
"ANDROID_ABI": "x86_64"
32+
},
33+
"condition": {
34+
"type": "inList",
35+
"string": "${hostSystemName}",
36+
"list": ["Darwin", "Linux", "Windows"]
37+
}
38+
},
939
{
1040
"name": "macos",
1141
"displayName": "Build ExecuTorch for macOS",

Package.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ let products = deliverables([
8484
],
8585
],
8686
"kernels_quantized": [:],
87+
"kernels_torchao": [
88+
"targets": [
89+
"threadpool",
90+
],
91+
],
8792
])
8893

8994
let targets = deliverables([

backends/apple/coreml/TARGETS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ runtime.python_test(
120120
"test/*.py",
121121
]),
122122
deps = [
123-
"fbsource//third-party/pypi/coremltools:coremltools",
124123
"fbsource//third-party/pypi/pytest:pytest",
125124
":partitioner",
126125
":quantizer",

0 commit comments

Comments
 (0)