Skip to content

Commit

Permalink
Remove python version specific usage within extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
janeyx99 committed Nov 12, 2024
1 parent addcb24 commit d8b9345
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def get_extensions():
extension(
"torchao._C",
sources,
py_limited_api=True,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
Expand Down
8 changes: 6 additions & 2 deletions torchao/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
)
if not _IS_FBCODE:
try:
from . import _C
from importlib.util import find_spec
from pathlib import Path
spec = find_spec("torchao")
assert spec is not None, "torchao python module spec is unexpectedly None"
SO_PATH = Path(spec.origin).parent / "_C.abi3.so"
torch.ops.load_library(SO_PATH)
from . import ops
except:
_C = None
logging.info("Skipping import of cpp extensions")

from torchao.quantization import (
Expand Down
3 changes: 0 additions & 3 deletions torchao/csrc/init.cpp

This file was deleted.

0 comments on commit d8b9345

Please sign in to comment.