Registry / ai-ml / einx
library0.4.3pypypi✓ verified 24d ago

einx is a Python library that provides a universal interface to formulate tensor operations in frameworks such as Numpy, PyTorch, Jax, Tensorflow, and MLX, using an Einstein-inspired notation. It offers a streamlined approach to complex tensor manipulations, often by compiling operations to backend-specific function calls, which helps minimize overhead. The current version is 0.4.3, with frequent minor releases addressing fixes and adding support for new backends.

pip install einx
INSTALL
IMPORT
SIG · EINX
E
einx
ai-mlpythonv0.4.3
Install
38.2s avg
Import
1564ms
Disk
2232MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 42.35s
py 3.11
✓ —
✓ 39.15s
py 3.12
✓ —
✓ 37s
py 3.13
✓ —
✓ 34.45s
py 3.9
✓ —
1/2 runs
2232MB installed
● package 2232MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

einx
import einx
einx.sum
import einx # ... einx.sum(...)
Most operations are accessed directly from the `einx` module.

This example demonstrates basic tensor operations using `einx` with a NumPy array. `einx` automatically detects and uses an available backend (e.g., NumPy, PyTorch, JAX) for the tensor operations. The string notation defines how axes are manipulated.

import einx import numpy as np # Can be any supported backend like torch, jax, tensorflow, mlx x = np.ones((10, 20, 30)) print(f"Input shape: {x.shape}") # Sum-reduction along the second (vectorized) axis y = einx.sum("a [b] c", x) print(f"Output shape after sum: {y.shape}") # Permute and (un)flatten axes with the identity operation z = einx.id("a (b c) -> (b a) c", x, b=2) print(f"Output shape after id: {z.shape}")
Debug
Known issues
gotchaeinx itself is a lightweight notation library and does not include its own tensor implementation. It requires a separate tensor framework (e.g., NumPy, PyTorch, JAX, TensorFlow) to be installed and available in your environment to perform operations. For PyTorch, explicitly installing with `pip install einx[torch]` is recommended to ensure compatible backend versions.
fix
Ensure your desired tensor backend (e.g., `pip install torch`) is installed. For PyTorch, use `pip install einx[torch]`.
affects: All versions
breakingStarting from `v0.2.1`, compiled `einx` functions no longer implicitly include the `einx` namespace in their dependency graph. Instead, they directly import and use the backend's namespace (e.g., `import torch`). If you were previously relying on `einx` being implicitly available within traced or compiled graphs, this change will break such workflows.
fix
Review any code that traces or compiles `einx` operations and ensure that any necessary backend functions are explicitly imported or accessed via the backend's module rather than assuming `einx`'s presence in the compiled context.
affects: >=0.2.1
gotchaVersion `0.4.3` changed tensor parameter annotations from `typing.TypeVar` to `typing.Any`. This fixed issues where previous strict typing did not always hold (e.g., with mixed-type inputs or backend-dependent output types). While a fix, users relying on strict static analysis with earlier versions might notice changes in type checking behavior or need to adjust their assumptions about tensor type propagation.
fix
Adjust static type checking configurations or explicit type hints to account for `einx`'s more flexible `typing.Any` annotations for tensor parameters.
affects: >=0.4.3
gotchaVersion `0.4.0` fully embraced vectorization as its core abstraction, defining expressions by analogy with loop notation. While intended as an improvement for clarity and consistency, users accustomed to an older understanding of `einx` expressions might need to re-evaluate how complex notations are interpreted, especially concerning implicit loop structures and vectorized operations.
fix
Consult the updated documentation and tutorials (especially the 'How does the notation work?' section) to understand the full vectorization analogy and ensure your `einx` expressions align with this paradigm.
affects: >=0.4.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'einx'
The 'einx' library is not installed in the current Python environment.
fix
Install the 'einx' library using pip: 'pip install einx'.
ImportError: cannot import name 'X' from 'einx'
Attempting to import a non-existent or incorrectly named component 'X' from the 'einx' library.
fix
Verify the correct import statement by consulting the 'einx' documentation for the desired component.
AttributeError: module 'einx' has no attribute 'X'
Trying to access an attribute or function 'X' that does not exist in the 'einx' module.
fix
Check the 'einx' documentation to confirm the existence and correct usage of 'X'.
TypeError: einx.function() missing 1 required positional argument: 'arg'
Calling an 'einx' function without providing a required positional argument.
fix
Review the function's signature in the 'einx' documentation and provide all necessary arguments.
ValueError: einx.function() received an invalid value for argument 'arg'
Passing an invalid value to an 'einx' function's argument.
fix
Ensure that the value provided for 'arg' meets the expected criteria as specified in the 'einx' documentation.
Upgrade
Version history
0.4.3latest on PyPI · released Apr 1, 2026
Audit
Dependencies
numpyoptionalBackend for tensor operations
torchoptionalBackend for tensor operations
jaxoptionalBackend for tensor operations
tensorflowoptionalBackend for tensor operations
mlxoptionalBackend for tensor operations
tinygradoptionalBackend for tensor operations
array-api-compatoptionalRequired for Array API backend support
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
einx — pip install einx · libregistry