Skip to content

Commit

Permalink
Add torchao.__version__ (#359)
Browse files Browse the repository at this point in the history
* Add torchao.__version__

* push
  • Loading branch information
msaroufim authored Jun 13, 2024
1 parent 2a502f7 commit 8841094
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion torchao/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import torch
import logging

# 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 . import _C
Expand Down

0 comments on commit 8841094

Please sign in to comment.