Skip to content

Commit 8841094

Browse files
authored
Add torchao.__version__ (#359)
* Add torchao.__version__ * push
1 parent 2a502f7 commit 8841094

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

torchao/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import torch
22
import logging
33

4+
# We use this "hack" to set torchao.__version__ correctly
5+
# the version of ao is dependent on environment variables for multiple architectures
6+
# For local development this will default to whatever is version.txt
7+
# For release builds this will be set the version+architecture_postfix
8+
from importlib.metadata import version, PackageNotFoundError
9+
try:
10+
__version__ = version("torchao")
11+
except PackageNotFoundError:
12+
__version__ = 'unknown' # In case this logic breaks don't break the build
13+
414
_IS_FBCODE = (
515
hasattr(torch._utils_internal, "IS_FBSOURCE") and
616
torch._utils_internal.IS_FBSOURCE
717
)
8-
918
if not _IS_FBCODE:
1019
try:
1120
from . import _C

0 commit comments

Comments
 (0)