Skip to content

Commit 5f96358

Browse files
authored
Merge branch 'main' into update-module-java
2 parents 507f47a + 78fe7ee commit 5f96358

File tree

28 files changed

+75
-85
lines changed

28 files changed

+75
-85
lines changed

CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,33 @@ project(executorch)
4848
# MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION --------------------------------------------------
4949

5050
include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
51+
include(${PROJECT_SOURCE_DIR}/tools/cmake/Utils.cmake)
52+
include(CMakeDependentOption)
53+
include(ExternalProject)
5154

5255
if(NOT CMAKE_CXX_STANDARD)
5356
set(CMAKE_CXX_STANDARD 17)
5457
endif()
5558
announce_configured_options(CMAKE_CXX_STANDARD)
5659

60+
if(NOT CMAKE_SYSTEM_PROCESSOR)
61+
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
62+
endif()
63+
announce_configured_options(CMAKE_SYSTEM_PROCESSOR)
64+
5765
if(NOT CMAKE_BUILD_TYPE)
5866
set(CMAKE_BUILD_TYPE Debug)
5967
endif()
6068
announce_configured_options(CMAKE_BUILD_TYPE)
6169

70+
if(NOT PYTHON_EXECUTABLE)
71+
resolve_python_executable()
72+
endif()
73+
announce_configured_options(PYTHON_EXECUTABLE)
74+
6275
announce_configured_options(CMAKE_CXX_COMPILER_ID)
6376
announce_configured_options(CMAKE_TOOLCHAIN_FILE)
6477
announce_configured_options(BUCK2)
65-
announce_configured_options(PYTHON_EXECUTABLE)
6678

6779
load_build_preset()
6880
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)
@@ -72,10 +84,6 @@ print_configured_options()
7284

7385
# MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION ----------------------------------------------------
7486

75-
include(tools/cmake/Utils.cmake)
76-
include(CMakeDependentOption)
77-
include(ExternalProject)
78-
7987
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8088

8189
# Setup RPATH.
@@ -251,11 +259,6 @@ if(EXECUTORCH_BUILD_TESTS)
251259
include(CTest)
252260
endif()
253261

254-
if(NOT PYTHON_EXECUTABLE)
255-
resolve_python_executable()
256-
endif()
257-
message(STATUS "Using python executable '${PYTHON_EXECUTABLE}'")
258-
259262
# TODO(dbort): Fix these warnings and remove this flag.
260263
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
261264

backends/apple/mps/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ endif()
1818

1919
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2020

21-
if(NOT PYTHON_EXECUTABLE)
22-
resolve_python_executable()
23-
endif()
24-
2521
set(_common_compile_options -Wno-deprecated-declarations)
2622
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
2723

backends/cadence/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)
3030
if(EXECUTORCH_CADENCE_CPU_RUNNER)
3131
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
3232

33-
if(NOT PYTHON_EXECUTABLE)
34-
resolve_python_executable()
35-
endif()
36-
3733
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
3834

3935
# Find prebuilt libraries. executorch package should contain portable_ops_lib,

backends/cadence/fusion_g3/operators/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ endif()
1414
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
1515
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
1616

17-
if(NOT PYTHON_EXECUTABLE)
18-
resolve_python_executable()
19-
endif()
20-
2117
# ATen compliant ops that are needed to run this model.
2218
set(_aten_ops__srcs
2319
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/activation_ops_util.cpp"

backends/cadence/hifi/operators/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ endif()
1414
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
1515
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
1616

17-
if(NOT PYTHON_EXECUTABLE)
18-
resolve_python_executable()
19-
endif()
20-
2117
# ATen compliant ops that are needed to run this model.
2218
set(_aten_ops__srcs
2319
"${EXECUTORCH_ROOT}/backends/cadence/hifi/operators/op_add.cpp"

backends/cadence/reference/operators/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ endif()
1414
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
1515
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
1616

17-
if(NOT PYTHON_EXECUTABLE)
18-
resolve_python_executable()
19-
endif()
20-
2117
# ATen compliant ops that are needed to run this model.
2218
set(_aten_ops__srcs
2319
"${CMAKE_CURRENT_SOURCE_DIR}/op_add.cpp"

backends/cortex_m/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ endif()
2323
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2424
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
2525

26-
if(NOT PYTHON_EXECUTABLE)
27-
resolve_python_executable()
28-
endif()
29-
3026
# Cortex-M ops kernel sources
3127
set(_cortex_m_kernels__srcs
3228
${CMAKE_CURRENT_SOURCE_DIR}/ops/op_quantize_per_tensor.cpp

backends/mediatek/preprocess.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from executorch.exir.backend.compile_spec_schema import CompileSpec
2121

2222
SKIP_COMPILE_SPEC_KEYS = {"ImportForever"}
23+
REQUIRED_COMPILE_SPEC_KEYS = {"platform-config"}
24+
SUPPORTED_PLATFORM_CONFIGS = {"mt6989", "mt6991"}
2325

2426

2527
def assert_default_dim_order(edge_graph_module: torch.fx.GraphModule) -> None:
@@ -47,6 +49,28 @@ def preprocess(
4749
cls, edge_program: ExportedProgram, module_compile_spec: List[CompileSpec]
4850
) -> PreprocessResult:
4951

52+
# Validate CompileSpec settings
53+
compile_spec_keys = [spec.key for spec in module_compile_spec]
54+
if len(compile_spec_keys) != len(set(compile_spec_keys)):
55+
raise RuntimeError(
56+
"Unsupported duplicated keys in the CompileSpec settings."
57+
)
58+
if not REQUIRED_COMPILE_SPEC_KEYS.issubset(set(compile_spec_keys)):
59+
raise RuntimeError(
60+
"Following keys are required in the CompileSpec settings: {}."
61+
"".format(REQUIRED_COMPILE_SPEC_KEYS)
62+
)
63+
platform = [
64+
spec.value.decode("utf-8")
65+
for spec in module_compile_spec
66+
if spec.key == "platform-config"
67+
][0]
68+
if platform not in SUPPORTED_PLATFORM_CONFIGS:
69+
raise ValueError(
70+
"Unsupported value of platform-config CompileSpec. Given {} but expected to be one "
71+
"of {}.".format(platform, SUPPORTED_PLATFORM_CONFIGS)
72+
)
73+
5074
# Make sure all inputs are contiguous_format or NCHW or default dim order
5175
assert_default_dim_order(edge_program.graph_module)
5276

@@ -64,8 +88,7 @@ def preprocess(
6488
if name_to_node_mappings[name].meta["val"].dtype == torch.float32
6589
]
6690

67-
# This default compile options are only for mt6989 SOC
68-
compile_options = ["--arch=mdla5.1,edpa1.0", "--relax-fp32", "--opt=3"]
91+
compile_options = ["--relax-fp32", "--opt=3"]
6992
for spec in module_compile_spec:
7093
if spec.key in SKIP_COMPILE_SPEC_KEYS:
7194
continue

backends/vulkan/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ if(NOT RUNTIME_PATH)
2424
set(RUNTIME_PATH ${CMAKE_CURRENT_SOURCE_DIR}/runtime)
2525
endif()
2626

27-
if(NOT PYTHON_EXECUTABLE)
28-
set(PYTHON_EXECUTABLE python3)
29-
endif()
30-
3127
# Include this file to access target_link_options_shared_lib This is required to
3228
# provide access to target_link_options_shared_lib which allows libraries to be
3329
# linked with the --whole-archive flag. This is required for libraries that

backends/vulkan/test/op_tests/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ find_library(LIB_TORCH torch HINTS ${TORCH_INSTALL_PREFIX}/lib)
4545
find_library(LIB_TORCH_CPU torch_cpu HINTS ${TORCH_INSTALL_PREFIX}/lib)
4646
find_library(LIB_C10 c10 HINTS ${TORCH_INSTALL_PREFIX}/lib)
4747

48-
if(NOT PYTHON_EXECUTABLE)
49-
set(PYTHON_EXECUTABLE python3)
50-
endif()
51-
5248
# Third party include paths
5349

5450
set(VULKAN_THIRD_PARTY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party)

backends/xnnpack/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ endif()
2525

2626
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2727

28-
if(NOT PYTHON_EXECUTABLE)
29-
resolve_python_executable()
30-
endif()
31-
3228
# NB: Enabling this will serialize execution of delegate instances Keeping this
3329
# OFF by default to maintain existing behavior, to be revisited.
3430
option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE

configurations/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ endif()
1818

1919
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2020

21-
if(NOT PYTHON_EXECUTABLE)
22-
resolve_python_executable()
23-
endif()
24-
2521
set(_common_compile_options -Wno-deprecated-declarations)
2622

2723
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)

examples/mediatek/aot_utils/oss_utils/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
NeuropilotQuantizer,
1515
Precision,
1616
)
17+
from executorch.exir.backend.backend_details import CompileSpec
1718
from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
1819

1920

@@ -48,7 +49,7 @@ def build_executorch_binary(
4849
edge_compile_config = exir.EdgeCompileConfig(_check_ir_validity=False)
4950
# skipped op names are used for deeplabV3 model
5051
neuro_partitioner = NeuropilotPartitioner(
51-
[],
52+
[CompileSpec("platform-config", b"mt6989")],
5253
op_names_to_skip={
5354
"aten_convolution_default_106",
5455
"aten_convolution_default_107",

examples/mediatek/model_export_scripts/llama.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,11 @@ def export_to_et_ir(
350350

351351
print("Delegating Edge Program to Neuropilot Backend")
352352
compile_spec = [
353-
CompileSpec("gno", struct.pack("3s", b"LTS")),
354-
CompileSpec("gno-exp", struct.pack("0s", b"")),
355-
CompileSpec("gno-non-4d-tiling", struct.pack("0s", b"")),
353+
CompileSpec("gno", b"LTS"),
354+
CompileSpec("gno-exp", b""),
355+
CompileSpec("gno-non-4d-tiling", b""),
356356
CompileSpec("ImportForever", struct.pack("?", True)),
357+
CompileSpec("platform-config", b"mt6989"),
357358
]
358359
partitioner = NeuropilotPartitioner(compile_spec)
359360
delegated_program = edge_program.to_backend(partitioner)

examples/models/llama/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ Note for Mac users: There's a known linking issue with Xcode 15.1. Refer to the
295295
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
296296
-DEXECUTORCH_BUILD_XNNPACK=ON \
297297
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
298+
-DSUPPORT_REGEX_LOOKAHEAD=ON
298299
-Bcmake-out/examples/models/llama \
299300
examples/models/llama
300301
@@ -353,6 +354,7 @@ cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
353354
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
354355
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
355356
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
357+
-DSUPPORT_REGEX_LOOKAHEAD=ON
356358
-Bcmake-out-android/examples/models/llama \
357359
examples/models/llama
358360

examples/models/llama/export_llama_lib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ def _prepare_for_llama_export(args) -> LLMEdgeManager:
719719
preq_mode=args.preq_mode,
720720
preq_group_size=args.preq_group_size,
721721
preq_embedding_quantize=args.preq_embedding_quantize,
722+
local_global_attention=args.local_global_attention,
722723
)
723724
)
724725

@@ -1447,7 +1448,7 @@ def _get_source_transforms( # noqa
14471448
transforms.append(
14481449
partial(
14491450
replace_kv_cache_with_ring_kv_cache,
1450-
layer_sizes=args.local_global_attention,
1451+
layer_sizes=local_global_attention,
14511452
)
14521453
)
14531454

examples/models/qwen3/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@ cmake-out/examples/models/llama/llama_main
8686
```
8787

8888
To run the model on an example iOS or Android app, see the Llama README's [Step 5: Build Mobile apps](../llama/README.md#step-5-build-mobile-apps) section.
89+
90+
### FAQ
91+
For more help with exporting or running this model, feel free to ask in our [discord channel](https://lnkd.in/gWCM4ViK).

extension/flat_tensor/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ add_custom_command(
2222
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
2323
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
2424
COMMAND
25-
python -m test.models.export_program --modules "ModuleAddMul"
25+
${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAddMul"
2626
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
2727
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
2828
)

extension/llm/custom_ops/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ if(NOT CMAKE_CXX_STANDARD)
1111
set(CMAKE_CXX_STANDARD 17)
1212
endif()
1313

14-
if(NOT PYTHON_EXECUTABLE)
15-
set(PYTHON_EXECUTABLE python3)
16-
endif()
17-
1814
# Source root directory for executorch.
1915
if(NOT EXECUTORCH_ROOT)
2016
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)

extension/module/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ add_custom_command(
2424
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
2525
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
2626
COMMAND
27-
python3 -m test.models.export_program --modules "ModuleAdd"
27+
${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAdd"
2828
--outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
2929
COMMAND
30-
python3 -m test.models.export_program --modules "ModuleAddMul"
30+
${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAddMul"
3131
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
3232
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
3333
)

extension/runner_util/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake)
1919

2020
add_custom_command(
2121
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte"
22-
COMMAND python3 -m test.models.export_program --modules "ModuleAdd" --outdir
22+
COMMAND ${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAdd" --outdir
2323
"${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
2424
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
2525
)

kernels/optimized/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ list(APPEND _common_compile_options -DET_BUILD_WITH_BLAS)
3636
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
3737
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
3838

39-
if(NOT PYTHON_EXECUTABLE)
40-
resolve_python_executable()
41-
endif()
4239
# Build cpublas.
4340
list(TRANSFORM _optimized_cpublas__srcs PREPEND "${EXECUTORCH_ROOT}/")
4441
add_library(cpublas STATIC ${_optimized_cpublas__srcs})

kernels/portable/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ set(_common_compile_options -Wno-deprecated-declarations)
2626
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2727
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
2828

29-
if(NOT PYTHON_EXECUTABLE)
30-
resolve_python_executable()
31-
endif()
32-
3329
# Portable kernel sources TODO(larryliu0820): use buck2 to gather the sources
3430
file(GLOB_RECURSE _portable_kernels__srcs
3531
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/*.cpp"

kernels/quantized/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ set(_common_compile_options -Wno-deprecated-declarations)
2929
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
3030
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
3131

32-
if(NOT PYTHON_EXECUTABLE)
33-
resolve_python_executable()
34-
endif()
35-
3632
# Quantized ops kernel sources TODO(larryliu0820): use buck2 to gather the
3733
# sources
3834
list(TRANSFORM _quantized_kernels__srcs PREPEND "${EXECUTORCH_ROOT}/")

kernels/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ foreach(kernel ${_kernels})
4242
"${_wrapper_dir}/supported_features.h"
4343
COMMAND mkdir -p ${_wrapper_dir}
4444
COMMAND
45-
python kernels/test/gen_supported_features.py
45+
${PYTHON_EXECUTABLE} kernels/test/gen_supported_features.py
4646
kernels/${kernel}/test/supported_features_def.yaml >
4747
${_wrapper_dir}/supported_features.cpp
4848
COMMAND
49-
python kernels/test/gen_supported_features.py
49+
${PYTHON_EXECUTABLE} kernels/test/gen_supported_features.py
5050
kernels/test/supported_features.yaml >
5151
${_wrapper_dir}/supported_features.h
5252
WORKING_DIRECTORY "${EXECUTORCH_ROOT}"

runtime/executor/method.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ Result<Method> Method::load(
754754
temp_allocator = platform_allocator;
755755
}
756756
Method method(program, memory_manager, event_tracer, temp_allocator);
757-
757+
ET_LOG(Debug, "Loading method: %s.", s_plan->name()->c_str());
758758
Error err = method.init(s_plan, named_data_map);
759759
if (err != Error::Ok) {
760760
return err;
@@ -1522,6 +1522,7 @@ Error Method::execute() {
15221522
initialized(),
15231523
NotSupported,
15241524
"Cannot execute until method has been initialized.");
1525+
ET_LOG(Debug, "Executing method: %s.", method_meta().name());
15251526

15261527
// Chains are executed sequentially today, but future async designs may
15271528
// branch and run many in parallel or out of order.

0 commit comments

Comments
 (0)