Skip to content

Commit d8430f8

Browse files
committed
Resolve the conflict
2 parents 12a9263 + 7f96f5a commit d8430f8

File tree

148 files changed

+4443
-1704
lines changed

Some content is hidden

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

148 files changed

+4443
-1704
lines changed

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6ca9ae4f8693639c395544327f7e362441a58c79
1+
a52b4e22571507abc35c2d47de138497190d2e0a

.cmakelintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
filter=+whitespace/extra,-whitespace/indent
1+
filter=-convention/filename,-linelength,-package/consistency,-readability/logic,+readability/mixedcase,-readability/wonkycase,-syntax,-whitespace/eol,+whitespace/extra,-whitespace/indent,-whitespace/mismatch,-whitespace/newline,-whitespace/tabs

.github/workflows/apple.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
"coreml_backend"
7171
"mps_backend"
7272
"portable_backend"
73+
"quantized_backend"
7374
"xnnpack_backend"
7475
)
7576
@@ -89,7 +90,7 @@ jobs:
8990
9091
# Build iOS Frameworks
9192
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
92-
build/build_apple_frameworks.sh --coreml --mps --portable --xnnpack
93+
build/build_apple_frameworks.sh --coreml --mps --portable --quantized --xnnpack
9394
9495
# Bundle iOS Frameworks
9596
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (

.github/workflows/cherry-pick.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Create a cherry pick from a PR
2+
3+
on:
4+
repository_dispatch:
5+
types: [try-cherry-pick]
6+
7+
jobs:
8+
cherry-pick:
9+
name: cherry-pick-pr-${{ github.event.client_payload.pr_num }}
10+
runs-on: ubuntu-latest
11+
environment: cherry-pick-bot
12+
env:
13+
GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
14+
steps:
15+
- name: Checkout repo
16+
id: checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
submodules: true
21+
token: ${{ secrets.GH_PYTORCHBOT_CHERRY_PICK_TOKEN }}
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: '3.10'
27+
cache: pip
28+
29+
# Not the direct dependencies but the script uses trymerge
30+
- run: pip install pyyaml==6.0 rockset==1.0.3
31+
32+
- name: Setup committer id
33+
run: |
34+
git config --global user.name "PyTorch Bot"
35+
git config --global user.email "[email protected]"
36+
37+
- name: Cherry pick the PR
38+
shell: bash
39+
env:
40+
PR_NUM: ${{ github.event.client_payload.pr_num }}
41+
BRANCH: ${{ github.event.client_payload.branch }}
42+
CLASSIFICATION: ${{ github.event.client_payload.classification }}
43+
FIXES: ${{ github.event.client_payload.fixes || '' }}
44+
ACTOR: ${{ github.actor }}
45+
GITHUB_TOKEN: ${{ secrets.GH_PYTORCHBOT_CHERRY_PICK_TOKEN }}
46+
run: |
47+
set -ex
48+
49+
python ./third-party/pytorch/.github/scripts/cherry_pick.py \
50+
--onto-branch "${BRANCH}" \
51+
--classification "${CLASSIFICATION}" \
52+
--fixes "${FIXES}" \
53+
--github-actor "${ACTOR}" \
54+
"${PR_NUM}"
55+
56+
concurrency:
57+
group: cherry-pick-pr-${{ github.event.client_payload.pr_num }}
58+
cancel-in-progress: true

CMakeLists.txt

Lines changed: 71 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ if(NOT EXECUTORCH_ENABLE_LOGGING)
7878
endif()
7979

8080
# Configure log level. Must be one of debug, info, error, fatal.
81-
set(EXECUTORCH_LOG_LEVEL "Info" CACHE STRING
82-
"Build with the given ET_MIN_LOG_LEVEL value")
81+
set(EXECUTORCH_LOG_LEVEL
82+
"Info"
83+
CACHE STRING "Build with the given ET_MIN_LOG_LEVEL value")
8384
string(TOLOWER "${EXECUTORCH_LOG_LEVEL}" LOG_LEVEL_LOWER)
8485
if(LOG_LEVEL_LOWER STREQUAL "debug")
8586
add_definitions(-DET_MIN_LOG_LEVEL=Debug)
@@ -90,9 +91,10 @@ elseif(LOG_LEVEL_LOWER STREQUAL "error")
9091
elseif(LOG_LEVEL_LOWER STREQUAL "fatal")
9192
add_definitions(-DET_MIN_LOG_LEVEL=Fatal)
9293
else()
93-
message(SEND_ERROR
94-
"Unknown log level \"${EXECUTORCH_LOG_LEVEL}\". Expected one of Debug, " +
95-
"Info, Error, or Fatal.")
94+
message(
95+
SEND_ERROR
96+
"Unknown log level \"${EXECUTORCH_LOG_LEVEL}\". Expected one of Debug, "
97+
+ "Info, Error, or Fatal.")
9698
endif()
9799

98100
option(EXECUTORCH_ENABLE_PROGRAM_VERIFICATION
@@ -105,16 +107,15 @@ if(NOT EXECUTORCH_ENABLE_PROGRAM_VERIFICATION)
105107
add_definitions(-DET_ENABLE_PROGRAM_VERIFICATION=0)
106108
endif()
107109

108-
option(EXECUTORCH_ENABLE_EVENT_TRACER
109-
"Build with ET_EVENT_TRACER_ENABLED=ON"
110+
option(EXECUTORCH_ENABLE_EVENT_TRACER "Build with ET_EVENT_TRACER_ENABLED=ON"
110111
OFF)
111112
if(EXECUTORCH_ENABLE_EVENT_TRACER)
112113
add_definitions(-DET_EVENT_TRACER_ENABLED)
113114
endif()
114115

115-
# -ffunction-sections -fdata-sections: breaks function and
116-
# data into sections so they can be properly gc'd. -s: strip symbol.
117-
# -fno-exceptions -fno-rtti: disables exceptions and runtime type.
116+
# -ffunction-sections -fdata-sections: breaks function and data into sections so
117+
# they can be properly gc'd. -s: strip symbol. -fno-exceptions -fno-rtti:
118+
# disables exceptions and runtime type.
118119
set(CMAKE_CXX_FLAGS_RELEASE
119120
"-ffunction-sections -fdata-sections -fno-exceptions -fno-rtti")
120121
if(NOT APPLE)
@@ -132,47 +133,40 @@ endif()
132133

133134
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
134135

135-
# Option to register quantized ops with quantized kernels. See
136-
# kernels/quantized/CMakeLists.txt
137-
option(REGISTER_QUANTIZED_OPS
138-
"Register quantized ops defined in kernels/quantized/" OFF)
136+
option(EXECUTORCH_BUILD_ANDROID_JNI "Build Android JNI" OFF)
137+
138+
option(EXECUTORCH_BUILD_ARM_BAREMETAL
139+
"Build the Arm Baremetal flow for Cortex-M and Ethos-U" OFF)
139140

140-
option(EXECUTORCH_BUILD_SIZE_TEST "Whether to build size test" OFF)
141+
option(EXECUTORCH_BUILD_COREML "Build the Core ML backend" OFF)
141142

142-
# Build xnn_executor_runner which depends on XNNPACK
143-
option(EXECUTORCH_BUILD_XNNPACK
144-
"Build xnn_executor_runner which depends on XNNPACK" OFF)
143+
option(EXECUTORCH_BUILD_EXTENSION_AOT_UTIL "Build the AOT Util extension" OFF)
145144

146-
# Build the vulkan delegate along with the vulkan executor_runner
147-
option(EXECUTORCH_BUILD_VULKAN
148-
"Build the Vulkan delegate and the Vulkan executor_runner" OFF)
145+
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "Build the Data Loader extension"
146+
OFF)
149147

150-
option(EXECUTORCH_BUILD_SDK
151-
"Build the ExecuTorch SDK library and the SDK example runner.")
148+
option(EXECUTORCH_BUILD_EXTENSION_MODULE "Build the Module extension" OFF)
152149

153-
# Build mps_executor_runner which depends on MPSGraph framework
154-
option(EXECUTORCH_BUILD_MPS "Build mps_executor_runner which depends on MPS"
150+
option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL "Build the Runner Util extension"
155151
OFF)
156152

157-
# Build dataloader extension library
158-
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
159-
"Build the extension/data_loader directory" OFF)
153+
option(EXECUTORCH_BUILD_GTESTS "Build googletest based test binaries" OFF)
154+
155+
option(EXECUTORCH_BUILD_MPS "Build the MPS backend" OFF)
156+
157+
option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)
158+
159+
option(EXECUTORCH_BUILD_QNN "Build the Qualcomm backend" OFF)
160160

161-
# Build module extension library
162-
option(EXECUTORCH_BUILD_EXTENSION_MODULE
163-
"Build the extension/module directory" OFF)
161+
option(REGISTER_QUANTIZED_OPS "Build the quantized kernels" OFF)
164162

165-
# Build the runner_util extension library
166-
option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL
167-
"Build the extension/runner_util directory" OFF)
163+
option(EXECUTORCH_BUILD_SDK "Build the ExecuTorch SDK")
168164

169-
# Build test binaries that rely on googletest
170-
option(EXECUTORCH_BUILD_GTESTS
171-
"Build googletest based test binaries" OFF)
165+
option(EXECUTORCH_BUILD_SIZE_TEST "Build the size test" OFF)
172166

173-
# Build the AOT util extension library
174-
option(EXECUTORCH_BUILD_EXTENSION_AOT_UTIL
175-
"Build the extension/aot_util directory" OFF)
167+
option(EXECUTORCH_BUILD_XNNPACK "Build the XNNPACK backend" OFF)
168+
169+
option(EXECUTORCH_BUILD_VULKAN "Build the Vulkan backend" OFF)
176170

177171
if(NOT BUCK2)
178172
set(BUCK2 buck2)
@@ -258,11 +252,21 @@ if(EXECUTORCH_BUILD_FLATC)
258252
)
259253
endif()
260254
set(FLATC_EXECUTABLE flatc)
261-
set(FLATBUFFERS_BUILD_FLATC ON CACHE BOOL "")
262-
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "")
263-
set(FLATBUFFERS_BUILD_FLATLIB OFF CACHE BOOL "")
264-
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
265-
set(FLATBUFFERS_INSTALL OFF CACHE BOOL "")
255+
set(FLATBUFFERS_BUILD_FLATC
256+
ON
257+
CACHE BOOL "")
258+
set(FLATBUFFERS_BUILD_FLATHASH
259+
OFF
260+
CACHE BOOL "")
261+
set(FLATBUFFERS_BUILD_FLATLIB
262+
OFF
263+
CACHE BOOL "")
264+
set(FLATBUFFERS_BUILD_TESTS
265+
OFF
266+
CACHE BOOL "")
267+
set(FLATBUFFERS_INSTALL
268+
OFF
269+
CACHE BOOL "")
266270
add_subdirectory(third-party/flatbuffers)
267271
endif()
268272
if(NOT FLATC_EXECUTABLE)
@@ -309,6 +313,13 @@ endif()
309313
# operators necessary for the models that will run.
310314
#
311315
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/portable)
316+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/optimized)
317+
318+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations)
319+
320+
if(REGISTER_QUANTIZED_OPS)
321+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/quantized)
322+
endif()
312323

313324
#
314325
# gflags: Commandline flag host library.
@@ -336,11 +347,10 @@ cmake_dependent_option(
336347
EXECUTORCH_BUILD_HOST_TARGETS OFF)
337348
if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
338349
# Baseline libraries that executor_runner will link against.
339-
set(_executor_runner_libs executorch portable_ops_lib gflags)
350+
set(_executor_runner_libs executorch optimized_native_cpu_ops_lib gflags)
340351

341352
# Generate lib to register quantized ops
342353
if(REGISTER_QUANTIZED_OPS)
343-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/quantized)
344354
list(APPEND _executor_runner_libs quantized_ops_lib)
345355
endif()
346356

@@ -384,7 +394,6 @@ if(EXECUTORCH_BUILD_EXTENSION_AOT_UTIL)
384394
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/aot_util)
385395
endif()
386396

387-
option(EXECUTORCH_BUILD_XNNPACK "Build the backends/xnnpack directory" OFF)
388397
if(EXECUTORCH_BUILD_XNNPACK)
389398
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
390399
endif()
@@ -393,36 +402,28 @@ if(EXECUTORCH_BUILD_VULKAN)
393402
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
394403
endif()
395404

396-
option(EXECUTORCH_BUILD_ANDROID_JNI "Build Android JNI" OFF)
397405
if(EXECUTORCH_BUILD_ANDROID_JNI)
398406
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/models/llama2/runner)
399407
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
400408
endif()
401409

402-
option(EXECUTORCH_BUILD_QNN "Build the backends/qualcomm directory" OFF)
403410
if(EXECUTORCH_BUILD_QNN)
404411
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
405412
endif()
406413

407-
option(EXECUTORCH_BUILD_ARM_BAREMETAL
408-
"Build the Arm Baremetal flow for Cortex-M and Ethos-U" OFF)
409414
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
410415
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
411416
endif()
412417

413-
option(EXECUTORCH_BUILD_MPS "Build the MPS Backend" OFF)
414418
if(EXECUTORCH_BUILD_MPS)
415419
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/mps)
416420
endif()
417421

418-
option(EXECUTORCH_BUILD_COREML "Build the Core ML Backend" OFF)
419422
if(EXECUTORCH_BUILD_COREML)
420423
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
421424
endif()
422425

423-
option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)
424426
if(EXECUTORCH_BUILD_PYBIND)
425-
426427
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/pybind11)
427428

428429
if(NOT EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
@@ -459,8 +460,7 @@ if(EXECUTORCH_BUILD_PYBIND)
459460
util
460461
${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp
461462
${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
462-
${CMAKE_CURRENT_SOURCE_DIR}/util/read_file.cpp
463-
)
463+
${CMAKE_CURRENT_SOURCE_DIR}/util/read_file.cpp)
464464
target_include_directories(util PUBLIC ${_common_include_directories}
465465
${TORCH_INCLUDE_DIRS})
466466
target_compile_options(util PUBLIC ${_pybind_compile_options})
@@ -472,20 +472,19 @@ if(EXECUTORCH_BUILD_PYBIND)
472472
PUBLIC EXECUTORCH_PYTHON_MODULE_NAME=portable_lib)
473473
target_include_directories(portable_lib PRIVATE ${TORCH_INCLUDE_DIRS})
474474
target_compile_options(portable_lib PUBLIC ${_pybind_compile_options})
475-
target_link_libraries(portable_lib
476-
PUBLIC
477-
${TORCH_PYTHON_LIBRARY}
478-
bundled_program
479-
etdump
480-
executorch
481-
extension_data_loader
482-
portable_ops_lib
483-
util
484-
torch
485-
${PYBIND_LINK_COREML}
486-
${PYBIND_LINK_MPS}
487-
${PYBIND_LINK_XNNPACK}
488-
)
475+
target_link_libraries(
476+
portable_lib
477+
PUBLIC ${TORCH_PYTHON_LIBRARY}
478+
bundled_program
479+
etdump
480+
executorch
481+
extension_data_loader
482+
portable_ops_lib
483+
util
484+
torch
485+
${PYBIND_LINK_COREML}
486+
${PYBIND_LINK_MPS}
487+
${PYBIND_LINK_XNNPACK})
489488

490489
install(TARGETS portable_lib
491490
LIBRARY DESTINATION executorch/extension/pybindings)

backends/apple/coreml/runtime/sdk/ETCoreMLModelAnalyzer.mm

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
9191
configuration:(MLModelConfiguration *)configuration
9292
assetManager:(ETCoreMLAssetManager *)assetManager
9393
error:(NSError * __autoreleasing *)error {
94-
if (![modelAsset keepAliveAndReturnError:error]) {
94+
if (modelAsset && ![modelAsset keepAliveAndReturnError:error]) {
9595
return nil;
9696
}
9797

@@ -123,11 +123,6 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
123123
modelAsset.contentURL.path);
124124
}
125125

126-
ETCoreMLModelProfiler *profiler = [[ETCoreMLModelProfiler alloc] initWithCompiledModelAsset:model.asset
127-
outputNames:model.orderedOutputNames
128-
configuration:configuration
129-
error:error];
130-
131126
self = [super init];
132127
if (self) {
133128
_model = model;
@@ -136,7 +131,6 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
136131
_configuration = configuration;
137132
_pathToSymbolNameMap = pathToSymbolNameMap;
138133
_executor = [[ETCoreMLDefaultModelExecutor alloc] initWithModel:model];
139-
_profiler = profiler;
140134
}
141135

142136
return self;
@@ -147,12 +141,22 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
147141
eventLogger:(const executorchcoreml::ModelEventLogger *)eventLogger
148142
error:(NSError * __autoreleasing *)error {
149143
if (self.profiler == nil) {
144+
ETCoreMLModelProfiler *profiler = [[ETCoreMLModelProfiler alloc] initWithCompiledModelAsset:self.model.asset
145+
outputNames:self.model.orderedOutputNames
146+
configuration:self.configuration
147+
error:error];
148+
self.profiler = profiler;
149+
}
150+
151+
152+
if (!self.profiler) {
150153
ETCoreMLLogErrorAndSetNSError(error,
151154
ETCoreMLErrorModelProfilingNotSupported,
152155
"%@: Model profiling is only available for macOS >= 14.4, iOS >= 17.4, tvOS >= 17.4 and watchOS >= 10.4.",
153156
NSStringFromClass(ETCoreMLModelAnalyzer.class));
154157
return nil;
155158
}
159+
156160
NSArray<MLMultiArray *> *modelOutputs = nil;
157161
NSArray<ETCoreMLModelStructurePath *> *operationPaths = self.profiler.operationPaths;
158162
ETCoreMLModelProfilingResult *profilingInfos = [self.profiler profilingInfoForOperationsAtPaths:operationPaths

0 commit comments

Comments
 (0)