Skip to content

Update install_requirements to install --pybind xnnpack by default. #7473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/source/getting-started-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,19 @@ Alternatively, if you would like to experiment with ExecuTorch quickly and easil
Use the [`--pybind` flag](https://github.com/pytorch/executorch/blob/main/install_requirements.sh#L26-L29) to install with pybindings and dependencies for other backends.
```bash
./install_requirements.sh --pybind <coreml | mps | xnnpack>

# Example: pybindings with CoreML *only*
./install_requirements.sh --pybind coreml

# Example: pybinds with CoreML *and* XNNPACK
./install_requirements.sh --pybind coreml xnnpack
```

By default, `./install_requirements.sh` command installs pybindings for XNNPACK. To disable any pybindings altogether:
```bash
./install_requirements.sh --pybind off
```

After setting up your environment, you are ready to convert your PyTorch programs
to ExecuTorch.

Expand Down
28 changes: 24 additions & 4 deletions install_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,34 @@ def python_is_compatible():
sys.exit(1)

# Parse options.
EXECUTORCH_BUILD_PYBIND = "OFF"

EXECUTORCH_BUILD_PYBIND = ""
CMAKE_ARGS = os.getenv("CMAKE_ARGS", "")
CMAKE_BUILD_ARGS = os.getenv("CMAKE_BUILD_ARGS", "")
USE_PYTORCH_NIGHTLY = True

for arg in sys.argv[1:]:
args = sys.argv[1:]
for arg in args:
if arg == "--pybind":
EXECUTORCH_BUILD_PYBIND = "ON"
pass
elif arg in ["coreml", "mps", "xnnpack"]:
if EXECUTORCH_BUILD_PYBIND == "ON":
if "--pybind" in args:
arg_upper = arg.upper()
EXECUTORCH_BUILD_PYBIND = "ON"
CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{arg_upper}=ON"
else:
print(f"Error: {arg} must follow --pybind")
sys.exit(1)
elif arg == "off":
if "--pybind" in args:
if EXECUTORCH_BUILD_PYBIND == "ON":
print("Cannot turnoff pybind option as it is already set.")
sys.exit(1)
EXECUTORCH_BUILD_PYBIND = "OFF"
else:
print(f"Error: {arg} must follow --pybind")
sys.exit(1)

elif arg == "--clean":
print("Cleaning build artifacts...")
print("Cleaning pip-out/...")
Expand All @@ -100,6 +113,13 @@ def python_is_compatible():
print(f"Error: Unknown option {arg}")
sys.exit(1)

# If --pybind is not set explicitly for backends (e.g., --pybind xnnpack)
# or is not turned off explicitly (--pybind off)
# then install XNNPACK by default.
if EXECUTORCH_BUILD_PYBIND == "":
EXECUTORCH_BUILD_PYBIND = "ON"
CMAKE_ARGS += " -DEXECUTORCH_BUILD_XNNPACK=ON"

# Use ClangCL on Windows.
# ClangCL is an alias to Clang that configures it to work in an MSVC-compatible
# mode. Using it on Windows to avoid compiler compatibility issues for MSVC.
Expand Down
Loading