-
Notifications
You must be signed in to change notification settings - Fork 238
/
Copy path__init__.py
50 lines (43 loc) · 1.46 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import torch
import logging
# torch/nested/_internal/nested_tensor.py:417: UserWarning: Failed to initialize NumPy: No module named 'numpy'
import warnings
warnings.filterwarnings("ignore", message="Failed to initialize NumPy: No module named 'numpy'")
# We use this "hack" to set torchao.__version__ correctly
# the version of ao is dependent on environment variables for multiple architectures
# For local development this will default to whatever is version.txt
# For release builds this will be set the version+architecture_postfix
from importlib.metadata import version, PackageNotFoundError
try:
__version__ = version("torchao")
except PackageNotFoundError:
__version__ = 'unknown' # In case this logic breaks don't break the build
_IS_FBCODE = (
hasattr(torch._utils_internal, "IS_FBSOURCE") and
torch._utils_internal.IS_FBSOURCE
)
if not _IS_FBCODE:
try:
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:
logging.info("Skipping import of cpp extensions")
from torchao.quantization import (
autoquant,
quantize_,
)
from . import dtypes
from . import testing
__all__ = [
"dtypes",
"autoquant",
"quantize_",
"testing",
]
# test-pytorchbot
# test-codev