Skip to content

Commit 7d532ce

Browse files
authored
Use "pybind" preset when building a wheel (#10951)
### Summary Now that we have presets for pybind, lets use that and eliminate the need to set cmake configurations in `setup.py`. Moreover, we now stop relying on defaults and fully rely on the cmake configurations. This includes relying on `CMakeCache.txt` to determine what features are enabled to determine what extensions to copy. ### Test plan CI + ``` $ rm -rf pip-out && python setup.py bdist_wheel $ rm -rf pip-out && ./install_executorch.sh ``` cc @larryliu0820
1 parent d50f26f commit 7d532ce

File tree

13 files changed

+279
-365
lines changed

13 files changed

+279
-365
lines changed

.ci/scripts/unittest-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
2020
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
2121
source .ci/scripts/setup-vulkan-linux-deps.sh
2222

23+
# We need the runner to test the built library.
2324
PYTHON_EXECUTABLE=python \
24-
CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2526
.ci/scripts/setup-linux.sh "$@"
2627

2728
.ci/scripts/unittest-linux-cmake.sh

.ci/scripts/unittest-macos.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export PATH="${TMP_DIR}:$PATH"
2020
trap 'rm -rfv ${TMP_DIR}' EXIT
2121

2222
# Setup MacOS dependencies as there is no Docker support on MacOS atm
23+
# We need the runner to test the built library.
2324
PYTHON_EXECUTABLE=python \
24-
CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2526
${CONDA_RUN} --no-capture-output \
2627
.ci/scripts/setup-macos.sh "$@"
2728

.ci/scripts/wheel/envvar_base.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@
1111
# Ensure that CMAKE_ARGS is defined before referencing it. Defaults to empty
1212
# if not defined.
1313
export CMAKE_ARGS="${CMAKE_ARGS:-}"
14-
15-
# Link the XNNPACK backend into the pybindings runtime so that users can execute
16-
# ExecuTorch programs that delegate to it.
17-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_XNNPACK=ON"

.ci/scripts/wheel/envvar_macos.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@
99
# any variables so that subprocesses will see them.
1010

1111
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/wheel/envvar_base.sh"
12-
13-
# When building for macOS, link additional backends into the pybindings runtime.
14-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_COREML=ON"
15-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_MPS=ON"

CMakePresets.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
{
2-
"version": 10,
3-
"cmakeMinimumRequired": {
4-
"major": 3,
5-
"minor": 31,
6-
"patch": 0
7-
},
8-
"$comment": "On-device AI across mobile, embedded and edge for PyTorch.",
2+
"version": 6,
93
"configurePresets": [
104
{
115
"name": "common",

backends/openvino/scripts/openvino_build.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,11 @@ main() {
4848
# Set parameters to configure the project with CMake
4949
# Note: Add any additional configuration options you need here
5050
export CMAKE_ARGS="-DEXECUTORCH_BUILD_OPENVINO=ON \
51-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
52-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
53-
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
54-
-DEXECUTORCH_ENABLE_LOGGING=ON \
55-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
56-
-DEXECUTORCH_BUILD_PYBIND=ON"
51+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON"
5752
export CMAKE_BUILD_ARGS="--target openvino_backend"
5853

5954
# Build the package
60-
pip install . --no-build-isolation
55+
./install_executorch.sh
6156

6257
else
6358
echo "Error: Argument is not valid: $build_type"

runtime/executor/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ add_custom_command(
3232
COMMAND
3333
${PYTHON_EXECUTABLE} -m test.models.export_program --modules
3434
"ModuleAdd,ModuleAddHalf,ModuleAddMul,ModuleDynamicCatUnallocatedIO,ModuleIndex,ModuleMultipleEntry,ModuleSimpleTrain,ModuleStateful"
35-
--outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
35+
--outdir "${CMAKE_CURRENT_BINARY_DIR}"
3636
COMMAND
3737
${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAddMul"
38-
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
38+
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}"
3939
COMMAND
4040
${PYTHON_EXECUTABLE} -m test.models.export_delegated_program --modules "ModuleAddMul"
4141
--backend_id "StubBackend" --outdir "${CMAKE_CURRENT_BINARY_DIR}/delegated/" || true

0 commit comments

Comments
 (0)