Skip to content

Commit 6870f6b

Browse files
author
pytorchbot
committed
2025-05-10 nightly release (b173722)
1 parent e941b88 commit 6870f6b

Some content is hidden

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

66 files changed

+1315
-866
lines changed

.ci/scripts/test_model.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ test_model() {
8787
bash examples/models/llava/install_requirements.sh
8888
STRICT="--no-strict"
8989
fi
90-
if [[ "$MODEL_NAME" == "llama3_2_vision_encoder" || "$MODEL_NAME" == "llama3_2_text_decoder" ]]; then
91-
# Install requirements for llama vision.
92-
bash examples/models/llama3_2_vision/install_requirements.sh
93-
fi
9490
if [[ "${MODEL_NAME}" == "qwen2_5" ]]; then
9591
# Install requirements for export_llama
9692
bash examples/models/llama/install_requirements.sh

.ci/scripts/unittest-linux.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
2424
CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
2525
.ci/scripts/setup-linux.sh "$@"
2626

27-
# Install llama3_2_vision dependencies.
28-
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
29-
3027
.ci/scripts/unittest-linux-cmake.sh
3128
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
3229
# Removing this breaks sccache in the Buck build, apparently

.ci/scripts/unittest-macos.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
2929
# Install llama3_2_vision dependencies.
3030
PYTHON_EXECUTABLE=python \
3131
${CONDA_RUN} --no-capture-output \
32-
./examples/models/llama3_2_vision/install_requirements.sh
3332

3433
.ci/scripts/unittest-macos-cmake.sh
3534
elif [[ "$BUILD_TOOL" == "buck2" ]]; then

.lintrunner.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ exclude_patterns = [
220220
'extension/**',
221221
'kernels/optimized/**',
222222
# Justified <functional> include.
223+
'kernels/portable/cpu/op_bitwise*.cpp',
224+
'kernels/portable/cpu/op_eq.cpp',
225+
'kernels/portable/cpu/op_ge.cpp',
226+
'kernels/portable/cpu/op_gt.cpp',
227+
'kernels/portable/cpu/op_le.cpp',
228+
'kernels/portable/cpu/op_lt.cpp',
229+
'kernels/portable/cpu/op_ne.cpp',
223230
'runtime/kernel/thread_parallel_interface.h',
224231
'scripts/**',
225232
'third-party/**',

CMakeLists.txt

Lines changed: 9 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ print_configured_options()
5959

6060
include(tools/cmake/Utils.cmake)
6161
include(CMakeDependentOption)
62+
include(ExternalProject)
6263

6364
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6465

@@ -242,6 +243,8 @@ option(EXECUTORCH_USE_DL "Use libdl library" ON)
242243

243244
option(EXECUTORCH_BUILD_CADENCE "Build the Cadence DSP backend" OFF)
244245

246+
option(EXECUTORCH_BUILD_CORTEX_M "Build the Cortex-M backend" OFF)
247+
245248
#
246249
# pthreadpool: build pthreadpool library. Disable on unsupported platforms
247250
#
@@ -258,6 +261,8 @@ cmake_dependent_option(
258261
"NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF
259262
)
260263

264+
add_subdirectory(third-party)
265+
261266
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
262267
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
263268
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
@@ -452,81 +457,6 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
452457
endif()
453458
endif()
454459

455-
#
456-
# flatc: Flatbuffer commandline tool to generate .h files from .fbs files
457-
#
458-
cmake_dependent_option(
459-
EXECUTORCH_BUILD_FLATC "Build the flatc executable." ON
460-
"NOT FLATC_EXECUTABLE" OFF
461-
)
462-
463-
set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "")
464-
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "")
465-
set(FLATBUFFERS_BUILD_FLATLIB OFF CACHE BOOL "")
466-
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
467-
set(FLATBUFFERS_INSTALL OFF CACHE BOOL "")
468-
# exir lets users set the alignment of tensor data embedded in the flatbuffer,
469-
# and some users need an alignment larger than the default, which is typically
470-
# 32.
471-
set(FLATBUFFERS_MAX_ALIGNMENT 1024)
472-
473-
if(EXECUTORCH_BUILD_FLATC)
474-
if(FLATC_EXECUTABLE)
475-
# We could ignore this, but it could lead to confusion about which `flatc`
476-
# is actually being used.
477-
message(
478-
FATAL_ERROR "May not set both EXECUTORCH_BUILD_FLATC and FLATC_EXECUTABLE"
479-
)
480-
endif()
481-
482-
# Build flatc for the *host* to generate files as part of the build step.
483-
include(ExternalProject)
484-
ExternalProject_Add(
485-
flatbuffers
486-
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party/flatbuffers
487-
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/flatbuffers
488-
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/flatbuffers
489-
CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON
490-
-DFLATBUFFERS_BUILD_FLATHASH=${FLATBUFFERS_BUILD_FLATHASH}
491-
-DFLATBUFFERS_BUILD_FLATLIB=${FLATBUFFERS_BUILD_FLATLIB}
492-
-DFLATBUFFERS_BUILD_TESTS=${FLATBUFFERS_BUILD_TESTS}
493-
-DFLATBUFFERS_INSTALL=${FLATBUFFERS_INSTALL}
494-
-DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${FLATBUFFERS_MAX_ALIGNMENT}"
495-
# If building for iOS, "unset" these variables to rely on the host (macOS) defaults.
496-
$<$<AND:$<BOOL:${CMAKE_TOOLCHAIN_IOS}>,$<BOOL:$<FILTER:${PLATFORM},EXCLUDE,^MAC>>>:-DCMAKE_OSX_SYSROOT=>
497-
INSTALL_COMMAND ""
498-
BUILD_BYPRODUCTS <BINARY_DIR>/flatc
499-
)
500-
ExternalProject_Get_Property(flatbuffers BINARY_DIR)
501-
if(WIN32)
502-
# flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release
503-
# config, but from CMake's perspective the build type is always Debug.
504-
set(FLATC_EXECUTABLE ${BINARY_DIR}/$<CONFIG>/flatc.exe)
505-
elseif(CMAKE_GENERATOR STREQUAL "Xcode")
506-
set(FLATC_EXECUTABLE ${BINARY_DIR}/$<CONFIG>/flatc)
507-
else()
508-
set(FLATC_EXECUTABLE ${BINARY_DIR}/flatc)
509-
endif()
510-
set(FLATC_EXECUTABLE_BUILT_FROM_SOURCE YES)
511-
endif()
512-
513-
if(NOT FLATC_EXECUTABLE)
514-
message(
515-
WARNING "FLATC_EXECUTABLE not specified, looking for flatc"
516-
)
517-
find_program(FLATC_EXECUTABLE flatc)
518-
519-
if(NOT FLATC_EXECUTABLE)
520-
message(FATAL_ERROR "FLATC_EXECUTABLE must be set when EXECUTORCH_BUILD_FLATC is disabled.")
521-
endif()
522-
endif()
523-
524-
add_executable(flatc IMPORTED GLOBAL)
525-
set_target_properties(flatc PROPERTIES IMPORTED_LOCATION ${FLATC_EXECUTABLE})
526-
527-
if(FLATC_EXECUTABLE_BUILT_FROM_SOURCE)
528-
add_dependencies(flatc flatbuffers)
529-
endif()
530460

531461
#
532462
# program_schema: Generated .h files from schema/*.fbs inputs
@@ -715,6 +645,10 @@ if(EXECUTORCH_BUILD_XNNPACK)
715645
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
716646
endif()
717647

648+
if(EXECUTORCH_BUILD_CORTEX_M)
649+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/cortex_m)
650+
endif()
651+
718652
if(EXECUTORCH_BUILD_DEVTOOLS)
719653
if(NOT EXECUTORCH_BUILD_ARM_BAREMETAL)
720654
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER

backends/apple/mps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ endforeach()
4242
add_custom_command(
4343
OUTPUT ${_mps_schema__outputs}
4444
COMMAND
45-
${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --scoped-enums -o
45+
flatc --cpp --cpp-std c++11 --scoped-enums -o
4646
"${_mps_schema__include_dir}/executorch/backends/apple/mps"
4747
${_mps_schema__srcs}
4848
WORKING_DIRECTORY ${EXECUTORCH_ROOT}

backends/arm/scripts/build_executorch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ cmake \
129129
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
130130
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
131131
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
132+
-DEXECUTORCH_BUILD_CORTEX_M=ON \
132133
-DEXECUTORCH_ENABLE_LOGGING=ON \
133134
${build_devtools_flags} \
134135
${build_with_etdump_flags} \

backends/arm/scripts/pre-push

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
# non-interactive mode. "$#" gives the number of positional arguments.
99
[ "$#" -eq 0 ] && is_script_interactive=1 || is_script_interactive=0
1010

11-
RESET='\e[0m'
12-
RED='\e[31m'
13-
GREEN='\e[32m'
14-
YELLOW='\e[33m'
15-
BLUE='\e[34m'
11+
if [ $is_script_interactive -eq 1 ]; then
12+
RESET='\e[0m'
13+
RED='\e[31m'
14+
GREEN='\e[32m'
15+
YELLOW='\e[33m'
16+
BLUE='\e[34m'
17+
fi
1618

1719
INFO="${BLUE}[INFO]${RESET}"
1820
WARNING="${YELLOW}[WARNING]${RESET}"

backends/arm/test/test_arm_baremetal.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ test_pytest_ops() { # Test ops and other things
8383
test_pytest_models() { # Test ops and other things
8484
echo "${TEST_SUITE_NAME}: Run pytest"
8585

86-
examples/models/llama3_2_vision/install_requirements.sh
87-
8886
# Prepare for pytest
8987
backends/arm/scripts/build_executorch.sh
9088

@@ -117,8 +115,6 @@ test_pytest_ops_ethosu_fvp() { # Same as test_pytest but also sometime verify us
117115
test_pytest_models_ethosu_fvp() { # Same as test_pytest but also sometime verify using Corstone FVP
118116
echo "${TEST_SUITE_NAME}: Run pytest with fvp"
119117

120-
examples/models/llama3_2_vision/install_requirements.sh
121-
122118
# Prepare Corstone-3x0 FVP for pytest
123119
backends/arm/scripts/build_executorch.sh
124120
backends/arm/scripts/build_portable_kernels.sh
@@ -154,6 +150,13 @@ test_run_ethosu_fvp() { # End to End model tests using run.sh
154150
echo "${TEST_SUITE_NAME}: Test ethos-u target Ethos-U85"
155151
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u85-128 --model_name=add
156152
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u85-128 --model_name=mul
153+
154+
# Cortex-M op tests
155+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=qadd --bundleio
156+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=qops --bundleio
157+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=qops --bundleio --no_delegate --portable_kernels="aten::sub.out,aten::add.out,aten::mul.out"
158+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u85-128 --model_name=qops --bundleio
159+
157160
echo "${TEST_SUITE_NAME}: PASS"
158161
}
159162

backends/cortex_m/CMakeLists.txt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Kernel library for Cortex-M operators. Please keep this file formatted by running:
8+
# ~~~
9+
# cmake-format -i CMakeLists.txt
10+
# ~~~
11+
cmake_minimum_required(VERSION 3.19)
12+
13+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
14+
if(NOT CMAKE_CXX_STANDARD)
15+
set(CMAKE_CXX_STANDARD 17)
16+
endif()
17+
18+
# Source root directory for executorch.
19+
if(NOT EXECUTORCH_ROOT)
20+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
21+
endif()
22+
23+
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
24+
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
25+
26+
if(NOT PYTHON_EXECUTABLE)
27+
resolve_python_executable()
28+
endif()
29+
30+
# Cortex-M ops kernel sources
31+
set(_cortex_m_kernels__srcs
32+
${CMAKE_CURRENT_SOURCE_DIR}/ops/op_quantize_per_tensor.cpp
33+
${CMAKE_CURRENT_SOURCE_DIR}/ops/op_dequantize_per_tensor.cpp
34+
)
35+
36+
# Generate C++ bindings to register kernels into Executorch (for runtime).
37+
# Here select all ops in operators.yaml
38+
set(_yaml_file ${CMAKE_CURRENT_LIST_DIR}/ops/operators.yaml)
39+
gen_selected_ops(LIB_NAME "cortex_m_ops_lib" OPS_SCHEMA_YAML "${_yaml_file}")
40+
41+
# Generate bindings for the kernels
42+
generate_bindings_for_kernels(
43+
LIB_NAME "cortex_m_ops_lib" CUSTOM_OPS_YAML "${_yaml_file}"
44+
)
45+
message("Generated files ${gen_command_sources}")
46+
47+
# Build a library for _cortex_m_kernels_srcs
48+
add_library(cortex_m_kernels ${_cortex_m_kernels__srcs})
49+
target_link_libraries(cortex_m_kernels PRIVATE executorch)
50+
target_compile_options(cortex_m_kernels PUBLIC ${_common_compile_options})
51+
52+
# cortex_m_ops_lib: Register Cortex-M ops kernels into Executorch runtime
53+
gen_operators_lib(
54+
LIB_NAME "cortex_m_ops_lib" KERNEL_LIBS cortex_m_kernels DEPS executorch
55+
)
56+
57+
install(
58+
TARGETS cortex_m_kernels cortex_m_ops_lib
59+
DESTINATION lib
60+
PUBLIC_HEADER DESTINATION include/executorch/backends/cortex_m/ops/
61+
)

0 commit comments

Comments
 (0)