Skip to content

Commit

Permalink
Update install_requirements to install --pybind xnnpack by default.
Browse files Browse the repository at this point in the history
Summary:

Regular ./install_requirements.sh will install pybind xnnpack by default. It is necessary for Llama for instance.

It is still backwards compatible with './install_requirements.sh --pybind xnnpack'

One can also turn off explicitly by calling './install_requirement.sh --pybind off'

Test Plan:

Test valid options:

./install_requirements.sh
./install_requirements.sh --pybind xnnpack
./install_requirements.sh --pybind coreml
./install_requirements.sh --pybind coreml xnnpack
./install_requirements.sh --pybind off

Invalid options:

./install_requirements.sh xnnpack
./install_requirements.sh --pybind coreml off
./install_requirements.sh --pybind coreml xnnpack off
./install_requirements.sh off
  • Loading branch information
mergennachin committed Jan 2, 2025
1 parent 3ef78ee commit 683142c
Showing 1 changed file with 24 additions and 4 deletions.
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

0 comments on commit 683142c

Please sign in to comment.