skillfed

einshape

DSL-based reshaping library for JAX and other frameworks

einshape v1.0 533.2K downloads/30d#6,142 on PyPI111
Permissive license Apache 2.0 DORMANT released

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 einshape

uv

uv add einshape

poetry

poetry add einshape

Installing 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

tensor reshape DSLeinsum-style reshapearray reshaping notationeinshape equationsbatch dimension manipulationtensor axis operations
tensor-manipulationdsl

More Scientific/Engineering packages