torch-einops-utils 0.0.23__tar.gz → 0.0.24__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.
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/PKG-INFO +1 -1
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/pyproject.toml +1 -1
- torch_einops_utils-0.0.24/tests/test_device.py +8 -0
- torch_einops_utils-0.0.24/torch_einops_utils/device.py +20 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/.github/workflows/python-publish.yml +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/.github/workflows/test.yml +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/.gitignore +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/LICENSE +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/README.md +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/tests/test_save_load.py +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/tests/test_utils.py +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/torch_einops_utils/__init__.py +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/torch_einops_utils/save_load.py +0 -0
- {torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/torch_einops_utils/torch_einops_utils.py +0 -0
|
@@ -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,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
|
{torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/.github/workflows/python-publish.yml
RENAMED
|
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
|
{torch_einops_utils-0.0.23 → torch_einops_utils-0.0.24}/torch_einops_utils/torch_einops_utils.py
RENAMED
|
File without changes
|