torch-einops-utils 0.0.23__py3-none-any.whl → 0.0.24__py3-none-any.whl
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.
- torch_einops_utils/device.py +20 -0
- {torch_einops_utils-0.0.23.dist-info → torch_einops_utils-0.0.24.dist-info}/METADATA +1 -1
- torch_einops_utils-0.0.24.dist-info/RECORD +8 -0
- torch_einops_utils-0.0.23.dist-info/RECORD +0 -7
- {torch_einops_utils-0.0.23.dist-info → torch_einops_utils-0.0.24.dist-info}/WHEEL +0 -0
- {torch_einops_utils-0.0.23.dist-info → torch_einops_utils-0.0.24.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from itertools import chain
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
from torch.nn import Module
|
|
5
|
+
|
|
6
|
+
# helpers
|
|
7
|
+
|
|
8
|
+
def exists(v):
|
|
9
|
+
return v is not None
|
|
10
|
+
|
|
11
|
+
# infer the device for a module
|
|
12
|
+
|
|
13
|
+
def module_device(m: Module):
|
|
14
|
+
|
|
15
|
+
first_param_or_buffer = next(chain(m.parameters(), m.buffers()), None)
|
|
16
|
+
|
|
17
|
+
if not exists(first_param_or_buffer):
|
|
18
|
+
return None
|
|
19
|
+
|
|
20
|
+
return first_param_or_buffer.device
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: torch-einops-utils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.24
|
|
4
4
|
Summary: Personal utility functions
|
|
5
5
|
Project-URL: Homepage, https://pypi.org/project/torch-einops-utils/
|
|
6
6
|
Project-URL: Repository, https://github.com/lucidrains/torch-einops-utils
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
torch_einops_utils/__init__.py,sha256=l7S9xJOlbMfwofQD3RI2Z4QxT3H713XSPc1zN_kF4Ww,982
|
|
2
|
+
torch_einops_utils/device.py,sha256=2BFn_RqyNqsThlvjh_Un4bNSkYovUHlNzKF0scq6gaY,366
|
|
3
|
+
torch_einops_utils/save_load.py,sha256=K-i7nmLyXBHdAfBLN3rGQzI3NVf6RRwF_GcrKQnfQsc,2669
|
|
4
|
+
torch_einops_utils/torch_einops_utils.py,sha256=raKFiWpRgGE7Vf7tTqkokU9525gr54lJMpQy_jnUTVI,6498
|
|
5
|
+
torch_einops_utils-0.0.24.dist-info/METADATA,sha256=7WdwsdDrjmI1YuCpyGUkDN0wh1N4X3vyhPbF2mWdK6I,2139
|
|
6
|
+
torch_einops_utils-0.0.24.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
7
|
+
torch_einops_utils-0.0.24.dist-info/licenses/LICENSE,sha256=e6AOF7Z8EFdK3IdcL0x0fLw4cY7Q0d0kNR0o0TmBewM,1066
|
|
8
|
+
torch_einops_utils-0.0.24.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
torch_einops_utils/__init__.py,sha256=l7S9xJOlbMfwofQD3RI2Z4QxT3H713XSPc1zN_kF4Ww,982
|
|
2
|
-
torch_einops_utils/save_load.py,sha256=K-i7nmLyXBHdAfBLN3rGQzI3NVf6RRwF_GcrKQnfQsc,2669
|
|
3
|
-
torch_einops_utils/torch_einops_utils.py,sha256=raKFiWpRgGE7Vf7tTqkokU9525gr54lJMpQy_jnUTVI,6498
|
|
4
|
-
torch_einops_utils-0.0.23.dist-info/METADATA,sha256=vN8uy5uFGwLhsIqkEXwf8uvzvmpVH9Vm2gprQjrzKqw,2139
|
|
5
|
-
torch_einops_utils-0.0.23.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
-
torch_einops_utils-0.0.23.dist-info/licenses/LICENSE,sha256=e6AOF7Z8EFdK3IdcL0x0fLw4cY7Q0d0kNR0o0TmBewM,1066
|
|
7
|
-
torch_einops_utils-0.0.23.dist-info/RECORD,,
|
|
File without changes
|
{torch_einops_utils-0.0.23.dist-info → torch_einops_utils-0.0.24.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|