Skip to content

Commit a7b886a

Browse files
committed
Update base for Update on "Add new export LLM config"
Differential Revision: [D75263991](https://our.internmc.facebook.com/intern/diff/D75263991) [ghstack-poisoned]
2 parents eeac438 + 01d6441 commit a7b886a

File tree

121 files changed

+4837
-3403
lines changed

Some content is hidden

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

121 files changed

+4837
-3403
lines changed

.ci/scripts/wheel/test_linux.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
test_base.ModelTest(
1515
model=Model.Mv3,
1616
backend=Backend.XnnpackQuantizationDelegation,
17-
)
17+
),
18+
test_base.ModelTest(
19+
model=Model.Mv3,
20+
backend=Backend.CoreMlExportOnly,
21+
),
1822
]
1923
)

.ci/scripts/wheel/test_macos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
),
1818
test_base.ModelTest(
1919
model=Model.Mv3,
20-
backend=Backend.CoreMlTest,
20+
backend=Backend.CoreMlExportAndTest,
2121
),
2222
]
2323
)

.github/workflows/apple-perf.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,7 @@ jobs:
386386
echo "::endgroup::"
387387
388388
echo "::group::Build ExecuTorch iOS frameworks"
389-
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
390-
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
389+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output scripts/build_apple_frameworks.sh
391390
echo "::endgroup::"
392391
393392
# NB: Although exported models can be copied to this directory and bundled together with the

.github/workflows/apple.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ jobs:
156156
"kernels_optimized"
157157
"kernels_portable"
158158
"kernels_quantized"
159+
"threadpool"
159160
)
160161
161162
.ci/scripts/setup-conda.sh
@@ -173,8 +174,7 @@ jobs:
173174
backends/apple/mps/install_requirements.sh
174175
175176
# Build iOS Frameworks
176-
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
177-
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
177+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output scripts/build_apple_frameworks.sh
178178
179179
# Bundle iOS Frameworks
180180
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
@@ -314,8 +314,7 @@ jobs:
314314
echo "::endgroup::"
315315
316316
echo "::group::Build ExecuTorch iOS frameworks"
317-
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
318-
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
317+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output scripts/build_apple_frameworks.sh
319318
echo "::endgroup::"
320319
321320
echo "::group::Build ExecuTorch benchmark app"

.github/workflows/build-presets.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
6666
./install_requirements.sh > /dev/null
6767
cmake --preset ${{ matrix.preset }}
68+
cmake --build cmake-out -j$(( $(nproc) - 1 ))
6869
6970
windows:
7071
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main

.lintrunner.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,14 @@ exclude_patterns = [
386386
"third-party/**",
387387
# TODO: remove exceptions as we migrate
388388
# backends
389-
"backends/arm/quantizer/**",
390-
"backends/arm/test/ops/**",
391389
"backends/vulkan/quantizer/**",
392390
"backends/vulkan/test/**",
393-
"backends/qualcomm/quantizer/**",
394-
"examples/qualcomm/**",
395391
"backends/xnnpack/quantizer/**",
396392
"backends/xnnpack/test/**",
397393
"exir/tests/test_passes.py",
398394
"extension/llm/export/builder.py",
399395
"extension/llm/export/quantizer_lib.py",
400396
"exir/tests/test_memory_planning.py",
401-
"backends/transforms/duplicate_dynamic_quant_chain.py",
402397
"exir/backend/test/demos/test_xnnpack_qnnpack.py",
403398
]
404399

CMakeLists.txt

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ else()
143143
set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
144144
endif()
145145

146+
if(EXECUTORCH_BUILD_TESTS)
147+
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
148+
include(CTest)
149+
endif()
150+
146151
add_subdirectory(third-party)
147152

148153
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
@@ -254,11 +259,6 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
254259
)
255260
endif()
256261

257-
if(EXECUTORCH_BUILD_TESTS)
258-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
259-
include(CTest)
260-
endif()
261-
262262
# TODO(dbort): Fix these warnings and remove this flag.
263263
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
264264

@@ -472,11 +472,6 @@ install(
472472
)
473473
install(FILES tools/cmake/executorch-config.cmake DESTINATION lib/cmake/ExecuTorch)
474474

475-
# Add googletest if any test targets should be built
476-
if(BUILD_TESTING)
477-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/googletest)
478-
endif()
479-
480475
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
481476
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
482477
endif()
@@ -565,8 +560,6 @@ if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)
565560
endif()
566561

567562
if(EXECUTORCH_BUILD_PYBIND)
568-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/pybind11)
569-
570563
if(NOT EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
571564
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/data_loader)
572565
endif()
@@ -602,7 +595,7 @@ if(EXECUTORCH_BUILD_PYBIND)
602595
list(APPEND _dep_libs portable_ops_lib)
603596
endif()
604597

605-
if(EXECUTORCH_BUILD_COREML)
598+
if(EXECUTORCH_BUILD_COREML AND APPLE)
606599
list(APPEND _dep_libs coremldelegate)
607600
endif()
608601

@@ -701,7 +694,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
701694
list(APPEND _executor_runner_libs etdump flatccrt)
702695
endif()
703696

704-
if(EXECUTORCH_BUILD_COREML)
697+
if(EXECUTORCH_BUILD_COREML AND APPLE)
705698
list(APPEND _executor_runner_libs coremldelegate)
706699
endif()
707700

Package.swift

Lines changed: 83 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,30 @@
1919

2020
import PackageDescription
2121

22-
let debug = "_debug"
23-
let deliverables = [
22+
let debug_suffix = "_debug"
23+
let dependencies_suffix = "_with_dependencies"
24+
25+
func deliverables(_ dict: [String: [String: Any]]) -> [String: [String: Any]] {
26+
dict
27+
.reduce(into: [String: [String: Any]]()) { result, pair in
28+
let (key, value) = pair
29+
result[key] = value
30+
result[key + debug_suffix] = value
31+
}
32+
.reduce(into: [String: [String: Any]]()) { result, pair in
33+
let (key, value) = pair
34+
var newValue = value
35+
if key.hasSuffix(debug_suffix) {
36+
for (k, v) in value where k.hasSuffix(debug_suffix) {
37+
let trimmed = String(k.dropLast(debug_suffix.count))
38+
newValue[trimmed] = v
39+
}
40+
}
41+
result[key] = newValue.filter { !$0.key.hasSuffix(debug_suffix) }
42+
}
43+
}
44+
45+
let products = deliverables([
2446
"backend_coreml": [
2547
"frameworks": [
2648
"Accelerate",
@@ -37,25 +59,62 @@ let deliverables = [
3759
"MetalPerformanceShadersGraph",
3860
],
3961
],
40-
"backend_xnnpack": [:],
41-
"executorch": [:],
62+
"backend_xnnpack": [
63+
"targets": [
64+
"threadpool",
65+
],
66+
],
67+
"executorch": [
68+
"libraries": [
69+
"c++",
70+
],
71+
],
4272
"kernels_custom": [:],
43-
"kernels_optimized": [:],
73+
"kernels_optimized": [
74+
"frameworks": [
75+
"Accelerate",
76+
],
77+
"targets": [
78+
"threadpool",
79+
],
80+
],
4481
"kernels_portable": [:],
4582
"kernels_quantized": [:],
46-
].reduce(into: [String: [String: Any]]()) {
47-
$0[$1.key] = $1.value
48-
$0[$1.key + debug] = $1.value
49-
}.reduce(into: [String: [String: Any]]()) {
50-
var newValue = $1.value
51-
if $1.key.hasSuffix(debug) {
52-
$1.value.forEach { key, value in
53-
if key.hasSuffix(debug) {
54-
newValue[String(key.dropLast(debug.count))] = value
55-
}
56-
}
57-
}
58-
$0[$1.key] = newValue.filter { key, _ in !key.hasSuffix(debug) }
83+
])
84+
85+
let targets = deliverables([
86+
"threadpool": [:],
87+
])
88+
89+
let packageProducts: [Product] = products.keys.map { key -> Product in
90+
.library(name: key, targets: ["\(key)\(dependencies_suffix)"])
91+
}.sorted { $0.name < $1.name }
92+
93+
var packageTargets: [Target] = []
94+
95+
for (key, value) in targets {
96+
packageTargets.append(.binaryTarget(
97+
name: key,
98+
path: "cmake-out/\(key).xcframework"
99+
))
100+
}
101+
102+
for (key, value) in products {
103+
packageTargets.append(.binaryTarget(
104+
name: key,
105+
path: "cmake-out/\(key).xcframework"
106+
))
107+
let target: Target = .target(
108+
name: "\(key)\(dependencies_suffix)",
109+
dependencies: ([key] + (value["targets"] as? [String] ?? []).map {
110+
key.hasSuffix(debug_suffix) ? $0 + debug_suffix : $0
111+
}).map { .target(name: $0) },
112+
path: ".Package.swift/\(key)",
113+
linkerSettings:
114+
(value["frameworks"] as? [String] ?? []).map { .linkedFramework($0) } +
115+
(value["libraries"] as? [String] ?? []).map { .linkedLibrary($0) }
116+
)
117+
packageTargets.append(target)
59118
}
60119

61120
let package = Package(
@@ -64,42 +123,22 @@ let package = Package(
64123
.iOS(.v17),
65124
.macOS(.v10_15),
66125
],
67-
products: deliverables.keys.map { key in
68-
.library(name: key, targets: ["\(key)_dependencies"])
69-
}.sorted { $0.name < $1.name },
70-
targets: deliverables.flatMap { key, value -> [Target] in
71-
[
72-
.binaryTarget(
73-
name: key,
74-
path: "cmake-out/\(key).xcframework"
75-
),
76-
.target(
77-
name: "\(key)_dependencies",
78-
dependencies: [.target(name: key)],
79-
path: ".Package.swift/\(key)",
80-
linkerSettings: [
81-
.linkedLibrary("c++")
82-
] +
83-
(value["frameworks"] as? [String] ?? []).map { .linkedFramework($0) } +
84-
(value["libraries"] as? [String] ?? []).map { .linkedLibrary($0) }
85-
),
86-
]
87-
} + [
126+
products: packageProducts,
127+
targets: packageTargets + [
88128
.testTarget(
89129
name: "tests",
90130
dependencies: [
91-
.target(name: "executorch_debug"),
92-
.target(name: "kernels_portable"),
131+
.target(name: "executorch\(debug_suffix)"),
132+
.target(name: "kernels_optimized\(dependencies_suffix)"),
93133
],
94134
path: "extension/apple/ExecuTorch/__tests__",
95135
resources: [
96-
.copy("resources/add.pte")
136+
.copy("resources/add.pte"),
97137
],
98138
linkerSettings: [
99-
.linkedLibrary("c++"),
100139
.unsafeFlags([
101140
"-Xlinker", "-force_load",
102-
"-Xlinker", "cmake-out/kernels_portable.xcframework/macos-arm64/libkernels_portable_macos.a",
141+
"-Xlinker", "cmake-out/kernels_optimized.xcframework/macos-arm64/libkernels_optimized_macos.a",
103142
])
104143
]
105144
)

0 commit comments

Comments
 (0)