Skip to content

Commit 1d34cee

Browse files
shoumikhinfacebook-github-bot
authored andcommitted
Build and upload quantized backend artifacts on CI. (#2615)
Summary: Pull Request resolved: #2615 bypass-github-export-checks Reviewed By: kirklandsign Differential Revision: D55264232 fbshipit-source-id: 7c9a90f254d8ac12d213bd8e35eeb5609d22dd51
1 parent 0a1e855 commit 1d34cee

File tree

5 files changed

+52
-73
lines changed

5 files changed

+52
-73
lines changed

.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 (

build/Utils.cmake

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,43 +33,27 @@ function(executorch_print_configuration_summary)
3333
message(
3434
STATUS
3535
" EXECUTORCH_ENABLE_LOGGING : ${EXECUTORCH_ENABLE_LOGGING}")
36-
message(
37-
STATUS
38-
" EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : ${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}"
39-
)
36+
message(STATUS " EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : "
37+
"${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}")
4038
message(
4139
STATUS " EXECUTORCH_LOG_LEVEL : ${EXECUTORCH_LOG_LEVEL}")
42-
message(
43-
STATUS
44-
" EXECUTORCH_BUILD_ANDROID_JNI : ${EXECUTORCH_BUILD_ANDROID_JNI}"
45-
)
46-
message(
47-
STATUS
48-
" EXECUTORCH_BUILD_ARM_BAREMETAL : ${EXECUTORCH_BUILD_ARM_BAREMETAL}"
49-
)
40+
message(STATUS " EXECUTORCH_BUILD_ANDROID_JNI : "
41+
"${EXECUTORCH_BUILD_ANDROID_JNI}")
42+
message(STATUS " EXECUTORCH_BUILD_ARM_BAREMETAL : "
43+
"${EXECUTORCH_BUILD_ARM_BAREMETAL}")
5044
message(
5145
STATUS
5246
" EXECUTORCH_BUILD_COREML : ${EXECUTORCH_BUILD_COREML}")
53-
message(
54-
STATUS
55-
" EXECUTORCH_BUILD_EXECUTOR_RUNNER : ${EXECUTORCH_BUILD_EXECUTOR_RUNNER}"
56-
)
57-
message(
58-
STATUS
59-
" EXECUTORCH_BUILD_EXTENSION_AOT_UTIL : ${EXECUTORCH_BUILD_EXTENSION_AOT_UTIL}"
60-
)
61-
message(
62-
STATUS
63-
" EXECUTORCH_BUILD_EXTENSION_DATA_LOADER : ${EXECUTORCH_BUILD_EXTENSION_DATA_LOADER}"
64-
)
65-
message(
66-
STATUS
67-
" EXECUTORCH_BUILD_EXTENSION_MODULE : ${EXECUTORCH_BUILD_EXTENSION_MODULE}"
68-
)
69-
message(
70-
STATUS
71-
" EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL : ${EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL}"
72-
)
47+
message(STATUS " EXECUTORCH_BUILD_EXECUTOR_RUNNER : "
48+
"${EXECUTORCH_BUILD_EXECUTOR_RUNNER}")
49+
message(STATUS " EXECUTORCH_BUILD_EXTENSION_AOT_UTIL : "
50+
"${EXECUTORCH_BUILD_EXTENSION_AOT_UTIL}")
51+
message(STATUS " EXECUTORCH_BUILD_EXTENSION_DATA_LOADER : "
52+
"${EXECUTORCH_BUILD_EXTENSION_DATA_LOADER}")
53+
message(STATUS " EXECUTORCH_BUILD_EXTENSION_MODULE : "
54+
"${EXECUTORCH_BUILD_EXTENSION_MODULE}")
55+
message(STATUS " EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL : "
56+
"${EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL}")
7357
message(
7458
STATUS
7559
" EXECUTORCH_BUILD_FLATC : ${EXECUTORCH_BUILD_FLATC}")
@@ -79,10 +63,8 @@ function(executorch_print_configuration_summary)
7963
message(
8064
STATUS
8165
" EXECUTORCH_BUILD_GTESTS : ${EXECUTORCH_BUILD_GTESTS}")
82-
message(
83-
STATUS
84-
" EXECUTORCH_BUILD_HOST_TARGETS : ${EXECUTORCH_BUILD_HOST_TARGETS}"
85-
)
66+
message(STATUS " EXECUTORCH_BUILD_HOST_TARGETS : "
67+
"${EXECUTORCH_BUILD_HOST_TARGETS}")
8668
message(
8769
STATUS " EXECUTORCH_BUILD_MPS : ${EXECUTORCH_BUILD_MPS}")
8870
message(
@@ -91,9 +73,7 @@ function(executorch_print_configuration_summary)
9173
message(
9274
STATUS " EXECUTORCH_BUILD_QNN : ${EXECUTORCH_BUILD_QNN}")
9375
message(
94-
STATUS
95-
" REGISTER_QUANTIZED_OPS : ${REGISTER_QUANTIZED_OPS}"
96-
)
76+
STATUS " REGISTER_QUANTIZED_OPS : ${REGISTER_QUANTIZED_OPS}")
9777
message(
9878
STATUS " EXECUTORCH_BUILD_SDK : ${EXECUTORCH_BUILD_SDK}")
9979
message(

build/build_apple_frameworks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ cmake_build() {
113113
mkdir "$platform" && cd "$platform" || exit 1
114114
cmake "$SOURCE_ROOT_DIR" -G Xcode \
115115
-DCMAKE_BUILD_TYPE="$MODE" \
116+
-DCMAKE_PREFIX_PATH="$($PYTHON -c 'import torch as _; print(_.__path__[0])')" \
116117
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \
117118
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD="c++17" \
118119
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY="libc++" \

examples/portable/custom_ops/CMakeLists.txt

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# `examples/portable/custom_ops/custom_ops_1.cpp`. We also have it registered
1010
# into EXIR in `examples/portable/custom_ops/custom_ops_1.py`. This
1111
# CMakeLists.txt runs a script to generate wrapper code based on the operator
12-
# kernel binding defined in `examples/portable/custom_ops/custom_ops.yaml`.
13-
# Then creates a library that contains both binding wrapper and the
14-
# implementation source file. This library can be linked into ExecuTorch binary
12+
# kernel binding defined in `examples/portable/custom_ops/custom_ops.yaml`. Then
13+
# creates a library that contains both binding wrapper and the implementation
14+
# source file. This library can be linked into ExecuTorch binary
1515
# (`executor_runner` in this example) and it is ready to run models containing
1616
# that custom op.
1717
cmake_minimum_required(VERSION 3.19)
@@ -43,9 +43,8 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
4343
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
4444

4545
find_package(executorch CONFIG REQUIRED)
46-
find_package(
47-
gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party
48-
)
46+
find_package(gflags REQUIRED PATHS
47+
${CMAKE_CURRENT_BINARY_DIR}/../../../third-party)
4948

5049
target_include_directories(executorch INTERFACE ${_common_include_directories})
5150

@@ -63,16 +62,13 @@ option(
6362
#
6463
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
6564
#
66-
set(
67-
EXECUTORCH_SRCS_FILE
68-
"${CMAKE_CURRENT_BINARY_DIR}/../../../executorch_srcs.cmake"
69-
)
65+
set(EXECUTORCH_SRCS_FILE
66+
"${CMAKE_CURRENT_BINARY_DIR}/../../../executorch_srcs.cmake")
7067

7168
extract_sources(${EXECUTORCH_SRCS_FILE})
7269

7370
include(${EXECUTORCH_SRCS_FILE})
7471

75-
7672
# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
7773
# Executorch (for runtime).
7874
if(REGISTER_EXAMPLE_CUSTOM_OP EQUAL 1)
@@ -81,8 +77,8 @@ elseif(REGISTER_EXAMPLE_CUSTOM_OP EQUAL 2)
8177
gen_selected_ops("" "my_ops::mul4.out" "")
8278
endif()
8379
# Expect gen_selected_ops output file to be selected_operators.yaml
84-
generate_bindings_for_kernels(
85-
CUSTOM_OPS_YAML ${CMAKE_CURRENT_LIST_DIR}/custom_ops.yaml)
80+
generate_bindings_for_kernels(CUSTOM_OPS_YAML
81+
${CMAKE_CURRENT_LIST_DIR}/custom_ops.yaml)
8682
message("Generated files ${gen_command_sources}")
8783

8884
# Prepare for C++ libraries.
@@ -93,7 +89,6 @@ if(REGISTER_EXAMPLE_CUSTOM_OP EQUAL 2)
9389
${CMAKE_CURRENT_LIST_DIR}/custom_ops_2.cpp # register my_ops::mul4
9490
${CMAKE_CURRENT_LIST_DIR}/custom_ops_2_out.cpp # register
9591
# my_ops::mul4.out)
96-
)
9792
gen_custom_ops_aot_lib("custom_ops_aot_lib" "${custom_ops_kernel_sources}")
9893
target_include_directories(custom_ops_aot_lib
9994
PUBLIC ${_common_include_directories})
@@ -110,15 +105,12 @@ add_library(custom_kernels ${kernel_sources})
110105
target_link_libraries(custom_kernels PRIVATE executorch)
111106
target_compile_options(custom_kernels PUBLIC ${_common_compile_options})
112107

113-
gen_operators_lib(
114-
"custom_ops_lib"
115-
KERNEL_LIBS custom_kernels
116-
DEPS executorch)
108+
gen_operators_lib("custom_ops_lib" KERNEL_LIBS custom_kernels DEPS executorch)
117109

118110
list(TRANSFORM _executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")
119111

120112
add_executable(custom_ops_executor_runner ${_executor_runner__srcs})
121-
target_link_libraries(custom_ops_executor_runner
122-
custom_ops_lib executorch gflags)
113+
target_link_libraries(custom_ops_executor_runner custom_ops_lib executorch
114+
gflags)
123115
target_compile_options(custom_ops_executor_runner
124116
PUBLIC ${_common_compile_options})

kernels/quantized/CMakeLists.txt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,30 @@ list(TRANSFORM _quantized_kernels__srcs PREPEND "${EXECUTORCH_ROOT}/")
3838
# Executorch (for runtime). Here select all ops in quantized.yaml
3939
gen_selected_ops("${CMAKE_CURRENT_LIST_DIR}/quantized.yaml" "" "")
4040
# Expect gen_selected_ops output file to be selected_operators.yaml
41-
generate_bindings_for_kernels(
42-
CUSTOM_OPS_YAML ${CMAKE_CURRENT_SOURCE_DIR}/quantized.yaml)
41+
generate_bindings_for_kernels(CUSTOM_OPS_YAML
42+
${CMAKE_CURRENT_SOURCE_DIR}/quantized.yaml)
4343
message("Generated files ${gen_command_sources}")
4444

45-
# Build a AOT library to register quantized ops into PyTorch.
46-
set(_quantized_sources
47-
${_quantized_kernels__srcs}
48-
${EXECUTORCH_ROOT}/runtime/core/exec_aten/util/tensor_util_aten.cpp # This
49-
# is a hack
50-
)
51-
gen_custom_ops_aot_lib("quantized_ops_aot_lib" "${_quantized_sources}")
45+
# Not targeting Xcode, because the custom command generating
46+
# kernels/quantized/selected_operators.yaml is attached to multiple targets:
47+
# quantized_ops_aot_lib quantized_ops_lib but none of these is a common
48+
# dependency of the other(s). This is not allowed by the Xcode "new build
49+
# system".
50+
if(NOT CMAKE_GENERATOR STREQUAL "Xcode")
51+
# Build a AOT library to register quantized ops into PyTorch. This is a hack.
52+
set(_quantized_sources
53+
${_quantized_kernels__srcs}
54+
${EXECUTORCH_ROOT}/runtime/core/exec_aten/util/tensor_util_aten.cpp)
55+
gen_custom_ops_aot_lib("quantized_ops_aot_lib" "${_quantized_sources}")
56+
endif()
5257

5358
add_library(quantized_kernels ${_quantized_kernels__srcs})
5459
target_link_libraries(quantized_kernels PRIVATE executorch)
5560
target_compile_options(quantized_kernels PUBLIC ${_common_compile_options})
5661
# Build a library for _quantized_kernels_srcs
5762
#
5863
# quantized_ops_lib: Register quantized ops kernels into Executorch runtime
59-
gen_operators_lib(
60-
"quantized_ops_lib"
61-
KERNEL_LIBS quantized_kernels
62-
DEPS executorch)
64+
gen_operators_lib("quantized_ops_lib" KERNEL_LIBS quantized_kernels DEPS
65+
executorch)
66+
67+
install(TARGETS quantized_kernels quantized_ops_lib DESTINATION lib)

0 commit comments

Comments
 (0)