diff --git a/install_requirements.py b/install_requirements.py index 18b5d6f9b99..847e59539b0 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -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/...") @@ -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.