Skip to content

fix USE_CPP=0 during local build #1812

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 12 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def read_version(file_path="version.txt"):

import platform

build_torchao_experimental = (
build_cpp = (
use_cpp == "1"
and platform.machine().startswith("arm64")
and platform.system() == "Darwin"
Expand Down Expand Up @@ -75,9 +75,9 @@ def use_debug_mode():
CUDAExtension,
)

build_torchao_experimental_mps = (
build_cpp_mps = (
os.getenv("TORCHAO_BUILD_EXPERIMENTAL_MPS") == "1"
and build_torchao_experimental
and build_cpp
and torch.mps.is_available()
)

Expand Down Expand Up @@ -188,7 +188,7 @@ def build_cmake(self, ext):
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)

build_mps_ops = "ON" if build_torchao_experimental_mps else "OFF"
build_mps_ops = "ON" if build_cpp_mps else "OFF"

subprocess.check_call(
[
Expand All @@ -214,6 +214,9 @@ def __init__(self, name, sourcedir=""):


def get_extensions():
if not build_cpp:
return []

debug_mode = use_debug_mode()
if debug_mode:
print("Compiling in debug mode")
Expand Down Expand Up @@ -309,13 +312,12 @@ def get_extensions():
)
)

if build_torchao_experimental:
ext_modules.append(
CMakeExtension(
"torchao.experimental",
sourcedir="torchao/experimental",
)
ext_modules.append(
CMakeExtension(
"torchao.experimental",
sourcedir="torchao/experimental",
)
)

return ext_modules

Expand Down
Loading