Skip to main content

AnyTensor

Portable tensor ops across NumPy, JAX, PyTorch, and TensorFlow, with a focus on segment / GNN primitives.

Write a helper once; run it on whatever tensor the caller already has. Ordinary math uses the Python Array API via array-api-compat. Segment reductions stay on thin input-adaptive backends.

Docs (motivation, GAT-style case study, design, API): https://swamidass.github.io/anytensor/ — or uv run --group docs mkdocs serve from a checkout (docs/).

We follow Semantic Versioning: breaking changes require a major bump. Portability is backed by cross-backend / symbolic fuzz, a coverage gate, and pytest-run docs examples (Design).

Install

pip install "anytensor @ git+https://github.com/swamidass/anytensor.git"
# optional backends (NumPy is a core dependency)
pip install "anytensor[jax]" "anytensor[torch]" "anytensor[tensorflow]"
# or
pip install "anytensor[all]"

Requires Python ≥3.10. Backend floors: NumPy ≥1.24, JAX ≥0.4.32, PyTorch ≥2.1, TensorFlow ≥2.13.

Quick start

import anytensor as at
import numpy as np

x = np.arange(12.0).reshape(3, 4)
seg_ids = np.array([0, 0, 1])
y = at.segment_sum(x, seg_ids, num_segments=2)

The same call works on JAX / Torch / TF tensors. num_segments is required (JAX convention).

Read next:

Docs / tests (checkout)

uv sync --extra all --group dev --group docs
uv run mkdocs serve
uv run pytest -m "not fuzz" --cov=anytensor --cov-report=term-missing

License

MIT. Backend dispatch patterns adapted from einops; see NOTICE.

Release files for anytensor 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anytensor 1.0.0
File Size Uploaded
anytensor-1.0.0.tar.gz 67.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anytensor 1.0.0
File Interpreter ABI Platform
anytensor-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 100.4 kB

Release files / anytensor-1.0.0.tar.gz

Download URL anytensor-1.0.0.tar.gz
Size 67.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ca331cb14cb02111d2d395e8b67c660649a5ec13195d50e7b7cc1a6646153bf6
BLAKE2b-256 checksum
How to use checksums
76b77c06039bd1a816ea789901a82bccd688ac16e33e990f3033af9591ad2dcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / anytensor-1.0.0-py3-none-any.whl

Download URL anytensor-1.0.0-py3-none-any.whl
Size 32.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
482984c98a1b319cae1ff59a828a357292a648056c5f7cb16baf7dc0d1f5890e
BLAKE2b-256 checksum
How to use checksums
569dc90e5e856b3623e9f16888fa30239d640c97ef2454445ca2a4ee865b2fda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.0

2 release files

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page