anytensor 1.0.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.
- anytensor-1.0.0/.gitignore +183 -0
- anytensor-1.0.0/CHANGELOG.md +6 -0
- anytensor-1.0.0/LICENSE +21 -0
- anytensor-1.0.0/NOTICE +10 -0
- anytensor-1.0.0/PKG-INFO +86 -0
- anytensor-1.0.0/README.md +55 -0
- anytensor-1.0.0/anytensor/__init__.py +208 -0
- anytensor-1.0.0/anytensor/_version.py +24 -0
- anytensor-1.0.0/anytensor/backends.py +675 -0
- anytensor-1.0.0/anytensor/core.py +926 -0
- anytensor-1.0.0/anytensor/jraph/__init__.py +0 -0
- anytensor-1.0.0/anytensor/jraph/util.py +0 -0
- anytensor-1.0.0/anytensor/namespace.py +188 -0
- anytensor-1.0.0/anytensor/segment.py +465 -0
- anytensor-1.0.0/anytensor/semantics.py +112 -0
- anytensor-1.0.0/anytensor/torchscript.py +124 -0
- anytensor-1.0.0/anytensor/typing.py +104 -0
- anytensor-1.0.0/changelog.d/.gitkeep +0 -0
- anytensor-1.0.0/changelog.d/001.added.md +1 -0
- anytensor-1.0.0/changelog.d/backend-floors.changed.md +1 -0
- anytensor-1.0.0/changelog.d/design-explainer.added.md +1 -0
- anytensor-1.0.0/changelog.d/docs-examples.added.md +1 -0
- anytensor-1.0.0/changelog.d/docs-intro.added.md +1 -0
- anytensor-1.0.0/changelog.d/min-backends.added.md +1 -0
- anytensor-1.0.0/changelog.d/stability.added.md +1 -0
- anytensor-1.0.0/changelog.d/torch-compile-docs.changed.md +1 -0
- anytensor-1.0.0/ci/min-versions.txt +25 -0
- anytensor-1.0.0/docs/api/anytensor.md +9 -0
- anytensor-1.0.0/docs/api/core.md +7 -0
- anytensor-1.0.0/docs/api/index.md +15 -0
- anytensor-1.0.0/docs/api/namespace.md +10 -0
- anytensor-1.0.0/docs/api/segment.md +7 -0
- anytensor-1.0.0/docs/api/semantics_api.md +7 -0
- anytensor-1.0.0/docs/contributing.md +81 -0
- anytensor-1.0.0/docs/design.md +288 -0
- anytensor-1.0.0/docs/examples.md +206 -0
- anytensor-1.0.0/docs/index.md +230 -0
- anytensor-1.0.0/docs/release.md +69 -0
- anytensor-1.0.0/docs/semantics.md +54 -0
- anytensor-1.0.0/docs/usage.md +135 -0
- anytensor-1.0.0/mkdocs.yml +76 -0
- anytensor-1.0.0/pyproject.toml +177 -0
- anytensor-1.0.0/test/__init__.py +0 -0
- anytensor-1.0.0/test/conftest.py +104 -0
- anytensor-1.0.0/test/docs_sybil.py +74 -0
- anytensor-1.0.0/test/helpers.py +43 -0
- anytensor-1.0.0/test/test_backend_contracts.py +144 -0
- anytensor-1.0.0/test/test_boundaries.py +136 -0
- anytensor-1.0.0/test/test_coverage_gaps.py +310 -0
- anytensor-1.0.0/test/test_cross_backend_fuzz.py +752 -0
- anytensor-1.0.0/test/test_device.py +14 -0
- anytensor-1.0.0/test/test_hypothesis.py +121 -0
- anytensor-1.0.0/test/test_nan_utils.py +91 -0
- anytensor-1.0.0/test/test_ops.py +330 -0
- anytensor-1.0.0/test/test_segment_semantics.py +61 -0
- anytensor-1.0.0/test/test_symbolic_fuzz.py +260 -0
- anytensor-1.0.0/test/test_tf_namespace.py +56 -0
- anytensor-1.0.0/test/test_torchscript.py +121 -0
- anytensor-1.0.0/test/test_typecheck.py +31 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Public package: resolve deps from pyproject; do not commit lock.
|
|
2
|
+
uv.lock
|
|
3
|
+
.python-version
|
|
4
|
+
.envrc
|
|
5
|
+
anytensor/_version.py
|
|
6
|
+
|
|
7
|
+
*.ipynb
|
|
8
|
+
|
|
9
|
+
# Byte-compiled / optimized / DLL files
|
|
10
|
+
__pycache__/
|
|
11
|
+
*.py[cod]
|
|
12
|
+
*$py.class
|
|
13
|
+
|
|
14
|
+
# C extensions
|
|
15
|
+
*.so
|
|
16
|
+
|
|
17
|
+
# Distribution / packaging
|
|
18
|
+
.Python
|
|
19
|
+
build/
|
|
20
|
+
develop-eggs/
|
|
21
|
+
dist/
|
|
22
|
+
downloads/
|
|
23
|
+
eggs/
|
|
24
|
+
.eggs/
|
|
25
|
+
lib/
|
|
26
|
+
lib64/
|
|
27
|
+
parts/
|
|
28
|
+
sdist/
|
|
29
|
+
var/
|
|
30
|
+
wheels/
|
|
31
|
+
share/python-wheels/
|
|
32
|
+
*.egg-info/
|
|
33
|
+
.installed.cfg
|
|
34
|
+
*.egg
|
|
35
|
+
MANIFEST
|
|
36
|
+
|
|
37
|
+
# PyInstaller
|
|
38
|
+
# Usually these files are written by a python script from a template
|
|
39
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
40
|
+
*.manifest
|
|
41
|
+
*.spec
|
|
42
|
+
|
|
43
|
+
# Installer logs
|
|
44
|
+
pip-log.txt
|
|
45
|
+
pip-delete-this-directory.txt
|
|
46
|
+
|
|
47
|
+
# Unit test / coverage reports
|
|
48
|
+
htmlcov/
|
|
49
|
+
.tox/
|
|
50
|
+
.nox/
|
|
51
|
+
.coverage
|
|
52
|
+
.coverage.*
|
|
53
|
+
.cache
|
|
54
|
+
nosetests.xml
|
|
55
|
+
coverage.xml
|
|
56
|
+
*.cover
|
|
57
|
+
*.py,cover
|
|
58
|
+
.hypothesis/
|
|
59
|
+
.pytest_cache/
|
|
60
|
+
cover/
|
|
61
|
+
|
|
62
|
+
# Translations
|
|
63
|
+
*.mo
|
|
64
|
+
*.pot
|
|
65
|
+
|
|
66
|
+
# Django stuff:
|
|
67
|
+
*.log
|
|
68
|
+
local_settings.py
|
|
69
|
+
db.sqlite3
|
|
70
|
+
db.sqlite3-journal
|
|
71
|
+
|
|
72
|
+
# Flask stuff:
|
|
73
|
+
instance/
|
|
74
|
+
.webassets-cache
|
|
75
|
+
|
|
76
|
+
# Scrapy stuff:
|
|
77
|
+
.scrapy
|
|
78
|
+
|
|
79
|
+
# Sphinx documentation
|
|
80
|
+
docs/_build/
|
|
81
|
+
|
|
82
|
+
# PyBuilder
|
|
83
|
+
.pybuilder/
|
|
84
|
+
target/
|
|
85
|
+
|
|
86
|
+
# Jupyter Notebook
|
|
87
|
+
.ipynb_checkpoints
|
|
88
|
+
|
|
89
|
+
# IPython
|
|
90
|
+
profile_default/
|
|
91
|
+
ipython_config.py
|
|
92
|
+
|
|
93
|
+
# pyenv
|
|
94
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
95
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
96
|
+
# .python-version
|
|
97
|
+
|
|
98
|
+
# pipenv
|
|
99
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
100
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
101
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
102
|
+
# install all needed dependencies.
|
|
103
|
+
#Pipfile.lock
|
|
104
|
+
|
|
105
|
+
# UV
|
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
107
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
108
|
+
# commonly ignored for libraries.
|
|
109
|
+
#uv.lock
|
|
110
|
+
|
|
111
|
+
# poetry
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
113
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
114
|
+
# commonly ignored for libraries.
|
|
115
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
116
|
+
#poetry.lock
|
|
117
|
+
|
|
118
|
+
# pdm
|
|
119
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
120
|
+
#pdm.lock
|
|
121
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
122
|
+
# in version control.
|
|
123
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
124
|
+
.pdm.toml
|
|
125
|
+
.pdm-python
|
|
126
|
+
.pdm-build/
|
|
127
|
+
|
|
128
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
129
|
+
__pypackages__/
|
|
130
|
+
|
|
131
|
+
# Celery stuff
|
|
132
|
+
celerybeat-schedule
|
|
133
|
+
celerybeat.pid
|
|
134
|
+
|
|
135
|
+
# SageMath parsed files
|
|
136
|
+
*.sage.py
|
|
137
|
+
|
|
138
|
+
# Environments
|
|
139
|
+
.env
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Ruff stuff:
|
|
179
|
+
.ruff_cache/
|
|
180
|
+
|
|
181
|
+
# PyPI configuration file
|
|
182
|
+
.pypirc
|
|
183
|
+
artifacts/
|
anytensor-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 S. Joshua Swamidass
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
anytensor-1.0.0/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
AnyTensor
|
|
2
|
+
Copyright (c) 2025 S. Joshua Swamidass
|
|
3
|
+
|
|
4
|
+
This product includes software derived from einops
|
|
5
|
+
(https://github.com/arogozhnikov/einops), specifically the multi-backend
|
|
6
|
+
dispatch pattern adapted in anytensor/backends.py.
|
|
7
|
+
|
|
8
|
+
einops is Copyright (c) 2018 Alex Rogozhnikov and is available under the
|
|
9
|
+
MIT License. See https://github.com/arogozhnikov/einops/blob/main/LICENSE
|
|
10
|
+
for the full text of that license.
|
anytensor-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: anytensor
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Portable tensor ops across NumPy, JAX, PyTorch, and TensorFlow, with segment/GNN primitives.
|
|
5
|
+
Project-URL: Repository, https://github.com/swamidass/anytensor
|
|
6
|
+
Project-URL: Issues, https://github.com/swamidass/anytensor/issues
|
|
7
|
+
Project-URL: Documentation, https://swamidass.github.io/anytensor/
|
|
8
|
+
Author-email: "S. Joshua Swamidass" <swamidass@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: array-api-compat>=1.15
|
|
14
|
+
Requires-Dist: einops>=0.8.1
|
|
15
|
+
Requires-Dist: jaxtyping>=0.2.34
|
|
16
|
+
Requires-Dist: numpy>=1.24
|
|
17
|
+
Provides-Extra: all
|
|
18
|
+
Requires-Dist: beartype>=0.18; extra == 'all'
|
|
19
|
+
Requires-Dist: jax>=0.4.32; extra == 'all'
|
|
20
|
+
Requires-Dist: tensorflow>=2.13; extra == 'all'
|
|
21
|
+
Requires-Dist: torch>=2.1; extra == 'all'
|
|
22
|
+
Provides-Extra: jax
|
|
23
|
+
Requires-Dist: jax>=0.4.32; extra == 'jax'
|
|
24
|
+
Provides-Extra: tensorflow
|
|
25
|
+
Requires-Dist: tensorflow>=2.13; extra == 'tensorflow'
|
|
26
|
+
Provides-Extra: torch
|
|
27
|
+
Requires-Dist: torch>=2.1; extra == 'torch'
|
|
28
|
+
Provides-Extra: typecheck
|
|
29
|
+
Requires-Dist: beartype>=0.18; extra == 'typecheck'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# AnyTensor
|
|
33
|
+
|
|
34
|
+
Portable tensor ops across **NumPy**, **JAX**, **PyTorch**, and **TensorFlow**, with a focus on **segment / GNN** primitives.
|
|
35
|
+
|
|
36
|
+
Write a helper once; run it on whatever tensor the caller already has. Ordinary math uses the [Python Array API](https://data-apis.org/array-api/latest/) via [`array-api-compat`](https://github.com/data-apis/array-api-compat). Segment reductions stay on thin input-adaptive backends.
|
|
37
|
+
|
|
38
|
+
**Docs** (motivation, GAT-style case study, design, API): <https://swamidass.github.io/anytensor/> — or `uv run --group docs mkdocs serve` from a checkout ([`docs/`](docs/index.md)).
|
|
39
|
+
|
|
40
|
+
We follow [Semantic Versioning](https://semver.org/): breaking changes require a **major** bump. Portability is backed by cross-backend / symbolic fuzz, a coverage gate, and pytest-run docs examples ([Design](docs/design.md#how-we-keep-the-contract-honest)).
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install "anytensor @ git+https://github.com/swamidass/anytensor.git"
|
|
46
|
+
# optional backends (NumPy is a core dependency)
|
|
47
|
+
pip install "anytensor[jax]" "anytensor[torch]" "anytensor[tensorflow]"
|
|
48
|
+
# or
|
|
49
|
+
pip install "anytensor[all]"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Requires Python ≥3.10. Backend floors: NumPy ≥1.24, JAX ≥0.4.32, PyTorch ≥2.1, TensorFlow ≥2.13.
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import anytensor as at
|
|
58
|
+
import numpy as np
|
|
59
|
+
|
|
60
|
+
x = np.arange(12.0).reshape(3, 4)
|
|
61
|
+
seg_ids = np.array([0, 0, 1])
|
|
62
|
+
y = at.segment_sum(x, seg_ids, num_segments=2)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The same call works on JAX / Torch / TF tensors. `num_segments` is **required** (JAX convention).
|
|
66
|
+
|
|
67
|
+
Read next:
|
|
68
|
+
|
|
69
|
+
- [Home / motivation](docs/index.md) — why AnyTensor, GAT neighbor-softmax case study across four backends
|
|
70
|
+
- [Design](docs/design.md) — principles, edge cases, **testing as contract**, SemVer
|
|
71
|
+
- [Usage](docs/usage.md) — promotion, segment helpers, `torch.compile`, typing
|
|
72
|
+
- [Surprising differences](docs/semantics.md) — NaN / ±inf / graph / GPU gotchas from fuzz
|
|
73
|
+
- [API reference](docs/api/index.md) — generated from docstrings
|
|
74
|
+
- [Contributing](docs/contributing.md) — tests, fuzz, docs build
|
|
75
|
+
|
|
76
|
+
## Docs / tests (checkout)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
uv sync --extra all --group dev --group docs
|
|
80
|
+
uv run mkdocs serve
|
|
81
|
+
uv run pytest -m "not fuzz" --cov=anytensor --cov-report=term-missing
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT. Backend dispatch patterns adapted from [einops](https://github.com/arogozhnikov/einops); see `NOTICE`.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# AnyTensor
|
|
2
|
+
|
|
3
|
+
Portable tensor ops across **NumPy**, **JAX**, **PyTorch**, and **TensorFlow**, with a focus on **segment / GNN** primitives.
|
|
4
|
+
|
|
5
|
+
Write a helper once; run it on whatever tensor the caller already has. Ordinary math uses the [Python Array API](https://data-apis.org/array-api/latest/) via [`array-api-compat`](https://github.com/data-apis/array-api-compat). Segment reductions stay on thin input-adaptive backends.
|
|
6
|
+
|
|
7
|
+
**Docs** (motivation, GAT-style case study, design, API): <https://swamidass.github.io/anytensor/> — or `uv run --group docs mkdocs serve` from a checkout ([`docs/`](docs/index.md)).
|
|
8
|
+
|
|
9
|
+
We follow [Semantic Versioning](https://semver.org/): breaking changes require a **major** bump. Portability is backed by cross-backend / symbolic fuzz, a coverage gate, and pytest-run docs examples ([Design](docs/design.md#how-we-keep-the-contract-honest)).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install "anytensor @ git+https://github.com/swamidass/anytensor.git"
|
|
15
|
+
# optional backends (NumPy is a core dependency)
|
|
16
|
+
pip install "anytensor[jax]" "anytensor[torch]" "anytensor[tensorflow]"
|
|
17
|
+
# or
|
|
18
|
+
pip install "anytensor[all]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires Python ≥3.10. Backend floors: NumPy ≥1.24, JAX ≥0.4.32, PyTorch ≥2.1, TensorFlow ≥2.13.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import anytensor as at
|
|
27
|
+
import numpy as np
|
|
28
|
+
|
|
29
|
+
x = np.arange(12.0).reshape(3, 4)
|
|
30
|
+
seg_ids = np.array([0, 0, 1])
|
|
31
|
+
y = at.segment_sum(x, seg_ids, num_segments=2)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The same call works on JAX / Torch / TF tensors. `num_segments` is **required** (JAX convention).
|
|
35
|
+
|
|
36
|
+
Read next:
|
|
37
|
+
|
|
38
|
+
- [Home / motivation](docs/index.md) — why AnyTensor, GAT neighbor-softmax case study across four backends
|
|
39
|
+
- [Design](docs/design.md) — principles, edge cases, **testing as contract**, SemVer
|
|
40
|
+
- [Usage](docs/usage.md) — promotion, segment helpers, `torch.compile`, typing
|
|
41
|
+
- [Surprising differences](docs/semantics.md) — NaN / ±inf / graph / GPU gotchas from fuzz
|
|
42
|
+
- [API reference](docs/api/index.md) — generated from docstrings
|
|
43
|
+
- [Contributing](docs/contributing.md) — tests, fuzz, docs build
|
|
44
|
+
|
|
45
|
+
## Docs / tests (checkout)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uv sync --extra all --group dev --group docs
|
|
49
|
+
uv run mkdocs serve
|
|
50
|
+
uv run pytest -m "not fuzz" --cov=anytensor --cov-report=term-missing
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT. Backend dispatch patterns adapted from [einops](https://github.com/arogozhnikov/einops); see `NOTICE`.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
from . import backends
|
|
2
|
+
from .backends import get_backend
|
|
3
|
+
|
|
4
|
+
# Import einops functions, which work the same way as anytensor.
|
|
5
|
+
from einops import einsum, pack, unpack, rearrange, reduce
|
|
6
|
+
|
|
7
|
+
from .segment import (
|
|
8
|
+
segment_sum,
|
|
9
|
+
segment_max,
|
|
10
|
+
segment_min,
|
|
11
|
+
segment_mean,
|
|
12
|
+
segment_count,
|
|
13
|
+
segment_variance,
|
|
14
|
+
segment_normalize,
|
|
15
|
+
segment_softmax,
|
|
16
|
+
segment_min_or_constant,
|
|
17
|
+
segment_max_or_constant,
|
|
18
|
+
partition_softmax,
|
|
19
|
+
enable_torchscript,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
from .core import (
|
|
23
|
+
repeat,
|
|
24
|
+
take,
|
|
25
|
+
exp,
|
|
26
|
+
log,
|
|
27
|
+
sum,
|
|
28
|
+
min,
|
|
29
|
+
max,
|
|
30
|
+
mean,
|
|
31
|
+
prod,
|
|
32
|
+
shape,
|
|
33
|
+
cumsum,
|
|
34
|
+
reshape,
|
|
35
|
+
transpose,
|
|
36
|
+
concatenate,
|
|
37
|
+
stack,
|
|
38
|
+
maximum,
|
|
39
|
+
minimum,
|
|
40
|
+
sqrt,
|
|
41
|
+
rsqrt,
|
|
42
|
+
where,
|
|
43
|
+
clip,
|
|
44
|
+
astype,
|
|
45
|
+
cast,
|
|
46
|
+
zeros_like,
|
|
47
|
+
ones_like,
|
|
48
|
+
full_like,
|
|
49
|
+
zeros,
|
|
50
|
+
ones,
|
|
51
|
+
full,
|
|
52
|
+
arange,
|
|
53
|
+
matmul,
|
|
54
|
+
inf,
|
|
55
|
+
ninf,
|
|
56
|
+
nan,
|
|
57
|
+
pi,
|
|
58
|
+
e,
|
|
59
|
+
newaxis,
|
|
60
|
+
finfo,
|
|
61
|
+
iinfo,
|
|
62
|
+
dtype,
|
|
63
|
+
is_nan,
|
|
64
|
+
is_finite,
|
|
65
|
+
is_inf,
|
|
66
|
+
isnan,
|
|
67
|
+
isfinite,
|
|
68
|
+
isinf,
|
|
69
|
+
fill_nan,
|
|
70
|
+
nan_fill,
|
|
71
|
+
fill_nan_mask,
|
|
72
|
+
nan_fill_mask,
|
|
73
|
+
nan_to_num,
|
|
74
|
+
equal_nan,
|
|
75
|
+
promote,
|
|
76
|
+
promote_scalars,
|
|
77
|
+
promote_options,
|
|
78
|
+
align_arrays,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
from .semantics import empty_segment_identity
|
|
82
|
+
from .typing import (
|
|
83
|
+
ArrayT,
|
|
84
|
+
Axes,
|
|
85
|
+
Bool,
|
|
86
|
+
DtypeLike,
|
|
87
|
+
Float,
|
|
88
|
+
FloatArray,
|
|
89
|
+
Inexact,
|
|
90
|
+
Int,
|
|
91
|
+
IntArray,
|
|
92
|
+
Integer,
|
|
93
|
+
Num,
|
|
94
|
+
Real,
|
|
95
|
+
SegmentIds,
|
|
96
|
+
SegmentOut,
|
|
97
|
+
SegmentValues,
|
|
98
|
+
ShapeLike,
|
|
99
|
+
ShapeSize,
|
|
100
|
+
Shaped,
|
|
101
|
+
ShapedArray,
|
|
102
|
+
enable_typecheck,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
from ._version import __version__
|
|
107
|
+
except ImportError: # pragma: no cover
|
|
108
|
+
__version__ = "0.0.0"
|
|
109
|
+
|
|
110
|
+
__all__ = [
|
|
111
|
+
"backends",
|
|
112
|
+
"get_backend",
|
|
113
|
+
"ArrayT",
|
|
114
|
+
"Axes",
|
|
115
|
+
"Bool",
|
|
116
|
+
"DtypeLike",
|
|
117
|
+
"Float",
|
|
118
|
+
"FloatArray",
|
|
119
|
+
"Inexact",
|
|
120
|
+
"Int",
|
|
121
|
+
"IntArray",
|
|
122
|
+
"Integer",
|
|
123
|
+
"Num",
|
|
124
|
+
"Real",
|
|
125
|
+
"SegmentIds",
|
|
126
|
+
"SegmentOut",
|
|
127
|
+
"SegmentValues",
|
|
128
|
+
"ShapeLike",
|
|
129
|
+
"ShapeSize",
|
|
130
|
+
"Shaped",
|
|
131
|
+
"ShapedArray",
|
|
132
|
+
"enable_typecheck",
|
|
133
|
+
"einsum",
|
|
134
|
+
"pack",
|
|
135
|
+
"unpack",
|
|
136
|
+
"rearrange",
|
|
137
|
+
"reduce",
|
|
138
|
+
"segment_sum",
|
|
139
|
+
"segment_max",
|
|
140
|
+
"segment_min",
|
|
141
|
+
"segment_mean",
|
|
142
|
+
"segment_count",
|
|
143
|
+
"segment_variance",
|
|
144
|
+
"segment_normalize",
|
|
145
|
+
"segment_softmax",
|
|
146
|
+
"segment_min_or_constant",
|
|
147
|
+
"segment_max_or_constant",
|
|
148
|
+
"partition_softmax",
|
|
149
|
+
"enable_torchscript",
|
|
150
|
+
"repeat",
|
|
151
|
+
"take",
|
|
152
|
+
"exp",
|
|
153
|
+
"log",
|
|
154
|
+
"sum",
|
|
155
|
+
"min",
|
|
156
|
+
"max",
|
|
157
|
+
"mean",
|
|
158
|
+
"prod",
|
|
159
|
+
"shape",
|
|
160
|
+
"cumsum",
|
|
161
|
+
"reshape",
|
|
162
|
+
"transpose",
|
|
163
|
+
"concatenate",
|
|
164
|
+
"stack",
|
|
165
|
+
"maximum",
|
|
166
|
+
"minimum",
|
|
167
|
+
"sqrt",
|
|
168
|
+
"rsqrt",
|
|
169
|
+
"where",
|
|
170
|
+
"clip",
|
|
171
|
+
"astype",
|
|
172
|
+
"cast",
|
|
173
|
+
"zeros_like",
|
|
174
|
+
"ones_like",
|
|
175
|
+
"full_like",
|
|
176
|
+
"zeros",
|
|
177
|
+
"ones",
|
|
178
|
+
"full",
|
|
179
|
+
"arange",
|
|
180
|
+
"matmul",
|
|
181
|
+
"inf",
|
|
182
|
+
"ninf",
|
|
183
|
+
"nan",
|
|
184
|
+
"pi",
|
|
185
|
+
"e",
|
|
186
|
+
"newaxis",
|
|
187
|
+
"finfo",
|
|
188
|
+
"iinfo",
|
|
189
|
+
"dtype",
|
|
190
|
+
"is_nan",
|
|
191
|
+
"is_finite",
|
|
192
|
+
"is_inf",
|
|
193
|
+
"isnan",
|
|
194
|
+
"isfinite",
|
|
195
|
+
"isinf",
|
|
196
|
+
"fill_nan",
|
|
197
|
+
"nan_fill",
|
|
198
|
+
"fill_nan_mask",
|
|
199
|
+
"nan_fill_mask",
|
|
200
|
+
"nan_to_num",
|
|
201
|
+
"equal_nan",
|
|
202
|
+
"promote",
|
|
203
|
+
"promote_scalars",
|
|
204
|
+
"promote_options",
|
|
205
|
+
"align_arrays",
|
|
206
|
+
"empty_segment_identity",
|
|
207
|
+
"__version__",
|
|
208
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '1.0.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 0, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|