--- id: einshape version: "1.0" license: Apache 2.0 license_treatment: permissive maintenance: dormant --- # einshape — DSL-based reshaping library for JAX and other frameworks License: permissive · Maintenance: dormant · Downloads: 533.2K/mo ## 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 above — 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 pip install einshape uv add einshape 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: unspecified - Install friction: low - Maintenance: dormant - Downloads: 533.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags tensor reshape DSL, einsum-style reshape, array reshaping notation, einshape equations, batch dimension manipulation, tensor axis operations, tensor-manipulation, dsl [View on SkillFed](https://skillfed.io/packages/einshape) · [View on PyPI](https://pypi.org/project/einshape/)