einshape
DSL-based reshaping library for JAX and other frameworks
What it is and what it does
Einshape is a DSL-based tensor manipulation library that unifies reshape, squeeze, expand_dims, and transpose operations under a single Einstein-notation-inspired syntax. Instead of chaining multiple function calls or computing permutation indices, you write compact equations like "nhwc->nchw" to transpose or "(mn)hwc->mnhwc" to split dimensions, making complex tensor transformations more readable and less error-prone.
The library works across multiple frameworks by exposing both a high-level API for each and a lower-level parser and engine for custom implementations. It supports advanced features like ellipsis (...) for variable-rank tensors, grouping syntax for dimension factorization, and unit dimensions for squeeze and expand operations. You supply dimension sizes via keyword arguments when they cannot be inferred from the equation.
Use it for:
- Reorder tensor axes for model input formats without manually computing permutation indices.
- Reshape batch and feature dimensions in a single readable operation instead of chained calls.
- Expand or squeeze unit dimensions using compact notation rather than repeated function calls.
- Split or combine dimensions with automatic size inference from keyword arguments.
- Write framework-agnostic tensor transformation code using the parser and engine.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Einshape provides a DSL-based interface for tensor reshaping, squeezing, expanding, and transposing operations using Einstein-notation-style equations across multiple frameworks.
Yes, if you perform frequent tensor reshaping and want more readable transformation code. The DSL is expressive and reduces boilerplate. However, maintenance is dormant (last release 2022-12-19); verify compatibility with your framework version before adopting in production. For occasional reshaping, native operations may be simpler.
Install
einshape on PyPI
pip
pip install einshapeuv
uv add einshapepoetry
poetry add einshapeInstalling einshape
Before you install
Low friction installation with a pure-Python wheel. Maintenance is dormant—last release was 2022-12-19 with no updates since, though the repository remains active with a recent commit on 2024-06-25.
License in practice
Apache 2.0 is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute the package freely provided you include the license notice.
Quickstart
from einshape import jax_einshape as einshape
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = einshape("ij->(ij)", a)
# b is [1, 2, 3, 4]
A compatible tensor framework (JAX or TensorFlow) must be installed separately; einshape does not declare either as a dependency to remain framework-agnostic.
Verify before relying
- Whether the dormant maintenance status affects compatibility with recent framework releases.
- Performance characteristics compared to native reshape and transpose operations.
- Full scope of equation syntax support beyond the documented examples.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — absl-py, numpy, dataclasses |
| Maintenance | dormant — 1,334 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 533,200/month — #6,142 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: einshape-1.0-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
einxeinx provides a universal notation for…
permissive · top 5,000 on PyPI
jaxtypingProvides type annotations and runtime…
permissive · top 5,000 on PyPI
einopsEinops provides readable tensor operations…
permissive · top 1,000 on PyPI
diffraxDiffrax provides numerical solvers for…
permissive · top 15,000 on PyPI
tensordictTensorDict is a batched, nested dictionary…
permissive · top 5,000 on PyPI
transformationsCalculates 4x4 homogeneous transformation…
permissive · top 5,000 on PyPI
tensordict-nightlyTensorDict is a batched, nested dictionary…
permissive · top 15,000 on PyPI
tensorlyTensorLy performs tensor decomposition, tensor…
permissive · top 15,000 on PyPI
einops-extsProvides helper functions that extend Einops, a…
permissive · top 15,000 on PyPI
fast-array-utilsConverts and computes statistics across sparse,…
copyleft · top 15,000 on PyPI