Skip to content

Commit 11333ba

Browse files
authored
Update __init__.py to load experimental ops even if other C++ ops are not found (#1565)
Update __init__.py to load experimental ops even if other C++ loads are not found
1 parent 1c0ea5b commit 11333ba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: torchao/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
from pathlib import Path
3030

3131
so_files = list(Path(__file__).parent.glob("_C*.so"))
32-
assert len(so_files) == 1, f"Expected one _C*.so file, found {len(so_files)}"
33-
torch.ops.load_library(so_files[0])
34-
from . import ops
32+
if len(so_files) > 0:
33+
assert (
34+
len(so_files) == 1
35+
), f"Expected one _C*.so file, found {len(so_files)}"
36+
torch.ops.load_library(so_files[0])
37+
from . import ops
3538

3639
# The following library contains CPU kernels from torchao/experimental
3740
# They are built automatically by ao/setup.py if on an ARM machine.

0 commit comments

Comments
 (0)