nshutils 0.20.0__tar.gz → 0.22.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nshutils-0.20.0 → nshutils-0.22.0}/PKG-INFO +5 -5
- {nshutils-0.20.0 → nshutils-0.22.0}/pyproject.toml +4 -5
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/actsave/_saver.py +6 -4
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/config.py +3 -3
- {nshutils-0.20.0 → nshutils-0.22.0}/README.md +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/__init__.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/__init__.pyi +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/actsave/__init__.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/actsave/_loader.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/collections.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/display.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/logging.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/__init__.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/_base.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/_monkey_patch_all.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/jax_.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/numpy_.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/torch_.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/lovely/utils.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/snoop.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/typecheck.py +0 -0
- {nshutils-0.20.0 → nshutils-0.22.0}/src/nshutils/util.py +0 -0
@@ -1,11 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: nshutils
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.22.0
|
4
4
|
Summary:
|
5
5
|
Author: Nima Shoghi
|
6
6
|
Author-email: nimashoghi@gmail.com
|
7
|
-
Requires-Python: >=3.
|
7
|
+
Requires-Python: >=3.9,<4.0
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
9
10
|
Classifier: Programming Language :: Python :: 3.10
|
10
11
|
Classifier: Programming Language :: Python :: 3.11
|
11
12
|
Classifier: Programming Language :: Python :: 3.12
|
@@ -16,14 +17,13 @@ Provides-Extra: snoop
|
|
16
17
|
Requires-Dist: beartype
|
17
18
|
Requires-Dist: jaxtyping
|
18
19
|
Requires-Dist: lazy-loader
|
19
|
-
Requires-Dist: nshconfig
|
20
20
|
Requires-Dist: numpy
|
21
21
|
Requires-Dist: pysnooper ; extra == "extra"
|
22
22
|
Requires-Dist: pysnooper ; extra == "snoop"
|
23
23
|
Requires-Dist: rich[jupyter] ; extra == "extra"
|
24
24
|
Requires-Dist: rich[jupyter] ; extra == "pprint"
|
25
|
-
Requires-Dist: treescope ; extra == "extra"
|
26
|
-
Requires-Dist: treescope ; extra == "pprint"
|
25
|
+
Requires-Dist: treescope ; (python_version >= "3.10") and (extra == "extra")
|
26
|
+
Requires-Dist: treescope ; (python_version >= "3.10") and (extra == "pprint")
|
27
27
|
Requires-Dist: typing-extensions
|
28
28
|
Requires-Dist: uuid7
|
29
29
|
Project-URL: Homepage, https://github.com/nimashoghi/nshutils
|
@@ -1,9 +1,9 @@
|
|
1
1
|
[project]
|
2
2
|
name = "nshutils"
|
3
|
-
version = "0.
|
3
|
+
version = "0.22.0"
|
4
4
|
description = ""
|
5
5
|
authors = [{ name = "Nima Shoghi", email = "nimashoghi@gmail.com" }]
|
6
|
-
requires-python = ">=3.
|
6
|
+
requires-python = ">=3.9,<4.0"
|
7
7
|
readme = "README.md"
|
8
8
|
|
9
9
|
dependencies = [
|
@@ -13,13 +13,12 @@ dependencies = [
|
|
13
13
|
"jaxtyping",
|
14
14
|
"beartype",
|
15
15
|
"uuid7",
|
16
|
-
"nshconfig",
|
17
16
|
]
|
18
17
|
|
19
18
|
[project.optional-dependencies]
|
20
19
|
snoop = ["pysnooper"]
|
21
|
-
pprint = ["rich[jupyter]", "treescope"]
|
22
|
-
extra = ["pysnooper", "rich[jupyter]", "treescope"]
|
20
|
+
pprint = ["rich[jupyter]", "treescope; python_version >= '3.10'"]
|
21
|
+
extra = ["pysnooper", "rich[jupyter]", "treescope; python_version >= '3.10'"]
|
23
22
|
|
24
23
|
[project.urls]
|
25
24
|
homepage = "https://github.com/nimashoghi/nshutils"
|
@@ -9,7 +9,7 @@ from dataclasses import dataclass
|
|
9
9
|
from functools import wraps
|
10
10
|
from logging import getLogger
|
11
11
|
from pathlib import Path
|
12
|
-
from typing import TYPE_CHECKING, Generic,
|
12
|
+
from typing import TYPE_CHECKING, Generic, Literal, cast, overload
|
13
13
|
|
14
14
|
import numpy as np
|
15
15
|
from typing_extensions import Never, ParamSpec, TypeAliasType, TypeVar, override
|
@@ -22,15 +22,17 @@ if not TYPE_CHECKING:
|
|
22
22
|
import torch # type: ignore
|
23
23
|
|
24
24
|
Tensor = torch.Tensor
|
25
|
+
_torch_installed = True
|
25
26
|
except ImportError:
|
26
27
|
torch = None
|
28
|
+
_torch_installed = False
|
27
29
|
|
28
30
|
Tensor = Never
|
29
31
|
else:
|
30
32
|
import torch # type: ignore
|
31
33
|
|
32
34
|
Tensor = torch.Tensor
|
33
|
-
|
35
|
+
_torch_installed: Literal[True] = True
|
34
36
|
|
35
37
|
log = getLogger(__name__)
|
36
38
|
|
@@ -41,7 +43,7 @@ ValueOrLambda = TypeAliasType("ValueOrLambda", Value | Callable[..., Value])
|
|
41
43
|
|
42
44
|
|
43
45
|
def _torch_is_scripting() -> bool:
|
44
|
-
if
|
46
|
+
if _torch_installed:
|
45
47
|
return False
|
46
48
|
|
47
49
|
return torch.jit.is_scripting()
|
@@ -56,7 +58,7 @@ def _to_numpy(activation: Value) -> np.ndarray:
|
|
56
58
|
return np.array(activation)
|
57
59
|
elif isinstance(activation, np.ndarray):
|
58
60
|
return activation
|
59
|
-
elif isinstance(activation, Tensor):
|
61
|
+
elif _torch_installed and isinstance(activation, Tensor):
|
60
62
|
activation_ = activation.detach()
|
61
63
|
if activation_.is_floating_point():
|
62
64
|
# NOTE: We need to convert to float32 because [b]float16 is not supported by numpy
|
@@ -1,15 +1,15 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
from dataclasses import dataclass
|
3
4
|
from typing import ClassVar
|
4
5
|
|
5
|
-
import nshconfig as C
|
6
6
|
from typing_extensions import Self
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
@dataclass
|
10
|
+
class LovelyConfig:
|
10
11
|
"""
|
11
12
|
This class is used to manage the configuration of the Lovely library.
|
12
|
-
It inherits from the Config class in the nshconfig module.
|
13
13
|
"""
|
14
14
|
|
15
15
|
precision: int = 3
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|