einx
Universal Notation for Tensor Operations in Python
What it is and what it does
einx is a notation system and compiler that lets you write tensor operations once using a string-based syntax and run them across NumPy, PyTorch, JAX, TensorFlow, and MLX without rewriting code. The notation works by analogy to nested loops: you describe how an elementary operation (like addition or dot product) should be vectorized across tensor axes using bracket and parenthesis syntax, and einx compiles that into optimized backend-specific code.
The library supports a large set of built-in operations (reductions, scalar ops, indexing, reshaping, dot products) and also lets you wrap custom Python functions as einx operations using framework-specific adapters like vmap. It's in active development (Alpha status) with low install friction and no known security vulnerabilities.
Use it for:
- Write portable tensor code that runs on NumPy for CPU prototyping and PyTorch or JAX for GPU training without duplicating logic.
- Express complex reshaping, pooling, and gather operations using a single notation instead of chaining framework-specific calls.
- Adapt custom functions (e.g., domain-specific kernels) to einx notation to gain automatic vectorization across batch and spatial dimensions.
- Compile tensor operations to inspectable code snippets for debugging or optimization verification.
- Build machine learning pipelines that can switch backends at runtime by changing only the framework import.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
einx provides a universal notation for expressing tensor operations across multiple frameworks (NumPy, PyTorch, JAX, TensorFlow, MLX) using a single string-based syntax that compiles to optimized code for each backend.
Yes, if you work across multiple tensor frameworks or want a more expressive notation for complex tensor operations. The low install friction, active maintenance, MIT license, and zero known vulnerabilities make it safe to adopt. Start with the quickstart if you're unsure whether the notation fits your workflow—it's most valuable for teams managing multi-backend code or expressing operations that are verbose in native framework syntax.
Install
einx on PyPI
pip
pip install einxuv
uv add einxpoetry
poetry add einxInstalling einx
Before you install
Installation is straightforward with low friction—a pure Python wheel with three stable runtime dependencies (numpy, sympy, frozendict). The package is actively maintained with a recent release and steady commit activity.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install einx
import einx
import numpy as np
x = np.ones((10, 20, 30))
y = einx.sum("a [b] c", x) # Sum-reduction along second axis
print(y.shape)
Requires Python 3.10 or later.
Verify before relying
- Performance characteristics and compilation overhead compared to direct framework calls for simple operations.
- Completeness of operation coverage across all five supported backends (NumPy, PyTorch, JAX, TensorFlow, MLX).
- Whether custom adapters work equally well across all backends or have backend-specific limitations.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, sympy, frozendict |
| Maintenance | actively maintained — 135 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,451,746/month — #3,059 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: einx-0.4.3-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
einshapeEinshape provides a DSL-based interface for…
permissive · top 15,000 on PyPI
einopsEinops provides readable tensor operations…
permissive · top 1,000 on PyPI
opt-einsumOptimizes the contraction order of einsum…
permissive · top 1,000 on PyPI
einops-extsProvides helper functions that extend Einops, a…
permissive · top 15,000 on PyPI
autorayAutoray provides automatic dispatch of array…
permissive · top 15,000 on PyPI
tensordictTensorDict is a batched, nested dictionary…
permissive · top 5,000 on PyPI
mlxMLX is an array framework for machine learning…
permissive · top 5,000 on PyPI
tensorlyTensorLy performs tensor decomposition, tensor…
permissive · top 15,000 on PyPI
tensordict-nightlyTensorDict is a batched, nested dictionary…
permissive · top 15,000 on PyPI
jaxtypingProvides type annotations and runtime…
permissive · top 5,000 on PyPI