Skip to content

Commit 365de21

Browse files
authored
Merge branch 'main' into milestone2.1
2 parents 94ada53 + a8070ec commit 365de21

File tree

86 files changed

+4366
-657
lines changed

Some content is hidden

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

86 files changed

+4366
-657
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7cda4017ddda554752e89069ae205be5e8388f59
1+
90f1e7bed15ca5e48c61c5b6dc5ad4810524f82f

.ci/scripts/test_phi_3_mini.sh

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,14 @@ NPROC=8
2222
if hash nproc &> /dev/null; then NPROC=$(nproc); fi
2323

2424
cmake_install_executorch_libraries() {
25-
cmake -DPYTHON_EXECUTABLE=python \
26-
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \
27-
-DEXECUTORCH_ENABLE_LOGGING=1 \
28-
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
29-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
30-
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
31-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
32-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
33-
-DEXECUTORCH_BUILD_XNNPACK=ON \
34-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
35-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
36-
-DEXECUTORCH_BUILD_KERNELS_LLM=ON \
37-
-B${BUILD_DIR} .
38-
39-
cmake --build ${BUILD_DIR} -j${NPROC} --target install --config ${BUILD_TYPE}
25+
rm -rf cmake-out
26+
cmake --preset llm -DCMAKE_INSTALL_PREFIX=cmake-out -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
27+
cmake --build cmake-out -j16 --target install --config ${BUILD_TYPE}
4028
}
4129

4230
cmake_build_phi_3_mini() {
43-
cmake -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
44-
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \
31+
cmake -DCMAKE_PREFIX_PATH=${BUILD_DIR} \
4532
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
46-
-DEXECUTORCH_BUILD_KERNELS_LLM=ON \
47-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
48-
-DEXECUTORCH_BUILD_XNNPACK=ON \
49-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
5033
-B${BUILD_DIR}/${MODEL_DIR} \
5134
${MODEL_DIR}
5235

@@ -81,7 +64,7 @@ run_and_verify() {
8164
${BUILD_DIR}/${MODEL_DIR}/phi_3_mini_runner \
8265
--model_path=phi-3-mini.pte \
8366
--tokenizer_path=tokenizer.bin \
84-
--seq_len=128 \
67+
--seq_len=60 \
8568
--temperature=0 \
8669
--prompt="<|system|>
8770
You are a helpful assistant.<|end|>

.github/workflows/pull.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ jobs:
603603
bash examples/models/phi-3-mini/install_requirements.sh
604604
605605
# run e2e (export, tokenizer and runner)
606-
PYTHON_EXECUTABLE=python bash .ci/scripts/test_phi_3_mini.sh
606+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_phi_3_mini.sh Release
607607
608608
test-eval_llama-wikitext-linux:
609609
name: test-eval_llama-wikitext-linux

.github/workflows/trunk.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ jobs:
197197
docker-image: executorch-ubuntu-22.04-arm-sdk
198198
submodules: 'recursive'
199199
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
200-
timeout: 90
200+
timeout: 120
201201
script: |
202202
# The generic Linux job chooses to use base env, not the one setup by the image
203203
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
@@ -800,3 +800,6 @@ jobs:
800800
801801
# Run pytest
802802
PYTHON_EXECUTABLE=python bash backends/nxp/run_unittests.sh
803+
804+
# Run aot example:
805+
PYTHON_EXECUTABLE=python bash examples/nxp/run_aot_example.sh

CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ set(CMAKE_SKIP_BUILD_RPATH OFF)
112112
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
113113
# Automatically add all linked folders that are NOT in the build directory to
114114
# the rpath (per library?)
115-
# TODO: Doesn't work for us right now because we are
116-
# not installing .so's into the correct locations. For example we have
117-
# libcustom_ops_aot_lib.so depending on _portable_lib.so, which was eventually
118-
# put under <site-packages>/executorch/extension/pybindings/ but this rpath is
119-
# not automatically added because at build time it seems `portable_lib` is being
115+
#
116+
# TODO: Doesn't work for us right now because we are not installing .so's into
117+
# the correct locations. For example we have libcustom_ops_aot_lib.so depending
118+
# on _portable_lib.so, which was eventually put under
119+
# <site-packages>/executorch/extension/pybindings/ but this rpath is not
120+
# automatically added because at build time it seems `portable_lib` is being
120121
# built under the same directory, so no extra rpath is being added. To properly
121122
# fix this we need to install `portable_lib` into the correct path.
122123
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
@@ -321,8 +322,9 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
321322
" -fprofile-instr-generate -fcoverage-mapping"
322323
)
323324
else()
324-
message(FATAL_ERROR
325-
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
325+
message(
326+
FATAL_ERROR
327+
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
326328
)
327329
endif()
328330
endif()
@@ -633,8 +635,8 @@ if(EXECUTORCH_BUILD_PYBIND)
633635
endif()
634636

635637
if(EXECUTORCH_BUILD_XNNPACK)
636-
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here otherwise
637-
# uses XNNPACK and microkernel-prod symbols from libtorch_cpu
638+
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here
639+
# otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
638640
list(APPEND _dep_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
639641
endif()
640642

backends/apple/coreml/CMakeLists.txt

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ if(APPLE)
104104
endif()
105105

106106
add_library(coreml_util ${UTIL_SOURCES})
107-
target_include_directories(coreml_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util)
107+
target_include_directories(
108+
coreml_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util
109+
)
108110
if(APPLE)
109111
target_link_libraries(coreml_util PRIVATE ${FOUNDATION_FRAMEWORK})
110112
endif()
@@ -119,21 +121,25 @@ install(
119121

120122
# CoreML inmemoryfs
121123

122-
set(
123-
INMEMORYFS_SOURCES
124-
runtime/inmemoryfs/inmemory_filesystem.cpp
125-
runtime/inmemoryfs/memory_buffer.cpp
126-
runtime/inmemoryfs/memory_stream.cpp
127-
runtime/inmemoryfs/reversed_memory_stream.cpp
124+
set(INMEMORYFS_SOURCES
125+
runtime/inmemoryfs/inmemory_filesystem.cpp
126+
runtime/inmemoryfs/memory_buffer.cpp runtime/inmemoryfs/memory_stream.cpp
127+
runtime/inmemoryfs/reversed_memory_stream.cpp
128128
)
129129
if(APPLE)
130-
list(APPEND INMEMORYFS_SOURCES runtime/inmemoryfs/inmemory_filesystem_utils.mm)
130+
list(APPEND INMEMORYFS_SOURCES
131+
runtime/inmemoryfs/inmemory_filesystem_utils.mm
132+
)
131133
endif()
132134

133135
add_library(coreml_inmemoryfs ${INMEMORYFS_SOURCES})
134-
target_include_directories(coreml_inmemoryfs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs)
136+
target_include_directories(
137+
coreml_inmemoryfs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs
138+
)
135139
if(APPLE)
136-
target_link_libraries(coreml_inmemoryfs PRIVATE coreml_util ${FOUNDATION_FRAMEWORK})
140+
target_link_libraries(
141+
coreml_inmemoryfs PRIVATE coreml_util ${FOUNDATION_FRAMEWORK}
142+
)
137143
endif()
138144
target_compile_options(coreml_inmemoryfs PUBLIC -fPIC)
139145

@@ -148,17 +154,12 @@ install(
148154

149155
if(EXECUTORCH_BUILD_PYBIND)
150156
pybind11_add_module(
151-
executorchcoreml
152-
SHARED
153-
runtime/inmemoryfs/inmemory_filesystem_py.cpp
154-
runtime/inmemoryfs/inmemory_filesystem_utils.cpp
157+
executorchcoreml SHARED runtime/inmemoryfs/inmemory_filesystem_py.cpp
158+
runtime/inmemoryfs/inmemory_filesystem_utils.cpp
155159
)
156160
target_link_libraries(
157-
executorchcoreml
158-
PRIVATE
159-
coreml_util
160-
coreml_inmemoryfs
161-
nlohmann_json::nlohmann_json
161+
executorchcoreml PRIVATE coreml_util coreml_inmemoryfs
162+
nlohmann_json::nlohmann_json
162163
)
163164
target_compile_options(executorchcoreml PUBLIC -fPIC)
164165
endif()
@@ -179,8 +180,12 @@ if(APPLE)
179180
coremldelegate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/delegate
180181
)
181182
target_include_directories(coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/..)
182-
target_include_directories(coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/runtime/core/portable_type/c10)
183-
target_compile_definitions(coremldelegate PRIVATE C10_USING_CUSTOM_GENERATED_MACROS)
183+
target_include_directories(
184+
coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/runtime/core/portable_type/c10
185+
)
186+
target_compile_definitions(
187+
coremldelegate PRIVATE C10_USING_CUSTOM_GENERATED_MACROS
188+
)
184189

185190
if(EXECUTORCH_BUILD_DEVTOOLS)
186191
target_sources(coremldelegate PRIVATE ${SDK_SOURCES} ${PROTOBUF_SOURCES})
@@ -200,13 +205,9 @@ if(APPLE)
200205

201206
target_link_libraries(
202207
coremldelegate
203-
PUBLIC coreml_util
204-
coreml_inmemoryfs
205-
PRIVATE executorch_core
206-
${ACCELERATE_FRAMEWORK}
207-
${COREML_FRAMEWORK}
208-
${FOUNDATION_FRAMEWORK}
209-
${SQLITE_LIBRARY}
208+
PUBLIC coreml_util coreml_inmemoryfs
209+
PRIVATE executorch_core ${ACCELERATE_FRAMEWORK} ${COREML_FRAMEWORK}
210+
${FOUNDATION_FRAMEWORK} ${SQLITE_LIBRARY}
210211
)
211212

212213
target_link_options_shared_lib(coremldelegate)
@@ -218,13 +219,8 @@ if(APPLE)
218219
endif()
219220

220221
target_compile_options(
221-
coremldelegate
222-
PRIVATE
223-
-fobjc-arc
224-
-fno-exceptions
225-
-x objective-c++
226-
-Wno-null-character
227-
-Wno-receiver-expr
222+
coremldelegate PRIVATE -fobjc-arc -fno-exceptions -x objective-c++
223+
-Wno-null-character -Wno-receiver-expr
228224
)
229225

230226
if(EXECUTORCH_BUILD_DEVTOOLS)

backends/arm/quantizer/arm_quantizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
@functools.lru_cache
6262
def get_symmetric_quantization_config(
63-
is_per_channel: bool = False,
63+
is_per_channel: bool = True,
6464
is_qat: bool = False,
6565
is_dynamic: bool = False,
6666
act_qmin: int = -128,

backends/arm/test/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
arm_executor_runner_exists,
1919
corstone300_installed,
2020
corstone320_installed,
21+
model_converter_installed,
2122
)
2223
from executorch.backends.arm.tosa_specification import TosaSpecification
2324
from executorch.exir.backend.compile_spec_schema import CompileSpec
@@ -245,6 +246,13 @@ def get_u85_compile_spec_unbuilt(
245246
)
246247
"""Xfails a test if Corsone320 FVP is not installed, or if the executor runner is not built"""
247248

249+
SkipIfNoModelConverter = pytest.mark.skipif(
250+
condition=not (model_converter_installed()),
251+
raises=FileNotFoundError,
252+
reason="Did not find model-converter on path",
253+
)
254+
"""Xfails a test if model-converter is not installed"""
255+
248256
xfail_type = str | tuple[str, type[Exception]]
249257

250258

backends/arm/test/misc/test_bn_relu_folding_qat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def test_qat_tosa_BI(model: torch.nn.Module):
5959
"quantize",
6060
Quantize(
6161
quantizer=quantizer,
62-
quantization_config=get_symmetric_quantization_config(is_qat=True),
62+
quantization_config=get_symmetric_quantization_config(
63+
is_qat=True, is_per_channel=False
64+
),
6365
is_qat=True,
6466
),
6567
)

backends/arm/test/ops/test_add.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
from typing import Tuple
99

10-
import pytest
11-
1210
import torch
1311
from executorch.backends.arm.arm_backend import get_tosa_spec
1412
from executorch.backends.arm.quantizer import arm_quantizer
@@ -190,7 +188,7 @@ def test_add_tensor_u85_BI_2(test_data: input_t2):
190188

191189

192190
@common.parametrize("test_data", Add.test_data)
193-
@pytest.mark.skip(reason="Model converter not yet made available")
191+
@common.SkipIfNoModelConverter
194192
def test_add_tensor_vgf_fp(test_data: input_t1):
195193
pipeline = VgfPipeline[input_t1](
196194
Add(), test_data(), aten_op, exir_op, tosa_version="TOSA-1.0+FP"
@@ -199,7 +197,7 @@ def test_add_tensor_vgf_fp(test_data: input_t1):
199197

200198

201199
@common.parametrize("test_data", Add.test_data)
202-
@pytest.mark.skip(reason="Model converter not yet made available")
200+
@common.SkipIfNoModelConverter
203201
def test_add_tensor_vgf_int(test_data: input_t1):
204202
pipeline = VgfPipeline[input_t1](
205203
Add(),

0 commit comments

Comments
 (0)