__init__.py 678 B

12345678910111213141516171819202122232425262728293031
  1. # torch.ao is a package with a lot of interdependencies.
  2. # We will use lazy import to avoid cyclic dependencies here.
  3. from typing import TYPE_CHECKING as _TYPE_CHECKING
  4. if _TYPE_CHECKING:
  5. from types import ModuleType
  6. from torch.ao import ( # noqa: TC004
  7. nn as nn,
  8. ns as ns,
  9. pruning as pruning,
  10. quantization as quantization,
  11. )
  12. __all__ = [
  13. "nn",
  14. "ns",
  15. "pruning",
  16. "quantization",
  17. ]
  18. def __getattr__(name: str) -> "ModuleType":
  19. if name in __all__:
  20. import importlib
  21. return importlib.import_module("." + name, __name__)
  22. raise AttributeError(f"module {__name__!r} has no attribute {name!r}")