Registry / ai-ml / torch-einops-utils

torch-einops-utils

JSON →
library0.1.4pypypiunverified

torch-einops-utils is a collection of personal utility functions designed to work with PyTorch and Einops, providing convenient abstractions for common tensor manipulations. It is currently at version 0.0.30 and receives frequent updates, indicating active development with rapid iteration.

pip install torch-einops-utils
INSTALL
IMPORT
SIG · TORCH-EINOPS-UTILS
T
torch-einops-utils
ai-mlpythonv0.1.4
Install
67.9s avg
Import
Disk
4787MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.4 · 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
✕ build_error
✓ 74.95s
py 3.11
✕ build_error
✓ 70.65s
py 3.12
✕ build_error
✓ 66.88s
py 3.13
✕ build_error
✓ 59.18s
py 3.9
✕ build_error
1/4 runs
4787MB installed
● package 4787MB
Code
Verified usage

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

EinopsToAndFrom
from torch_einops_utils import EinopsToAndFrom
EinopsToNoOp
from torch_einops_utils import EinopsToNoOp
Rearrange
from torch_einops_utils import Rearrange
Reduce
from torch_einops_utils import Reduce
rearrange_many
from torch_einops_utils import rearrange_many
repeat_many
from torch_einops_utils import repeat_many

This quickstart demonstrates how to use `EinopsToAndFrom`, one of the core utility classes. It shows how to define a custom module that wraps a function or `nn.Module` with specified Einops input and output patterns. The example uses `nn.Identity` and a simple lambda function to illustrate its application.

import torch from torch import nn from torch_einops_utils import EinopsToAndFrom class Foo(EinopsToAndFrom): def __init__(self, fn: nn.Module): # EinopsToAndFrom requires input pattern, output pattern, and a callable/nn.Module super().__init__('b n d', 'b n d', fn) def forward(self, x): # The `fn` provided in __init__ is called within EinopsToAndFrom's forward # after applying the input pattern, and before applying the output pattern. # In this example, 'b n d' -> 'b n d' is a no-op rearrangement # so the fn acts directly on the input shape. return self.fn(x) # Example usage with a simple nn.Identity model = Foo(nn.Identity()) x = torch.randn(1, 10, 32) # Batch, Sequence Length, Dimension y = model(x) print(f"Input shape: {x.shape}") print(f"Output shape: {y.shape}") # Example with a lambda function dummy_fn = lambda z: z * 2 # Multiply by 2 model_lambda = Foo(dummy_fn) y_lambda = model_lambda(x) print(f"Output with lambda: {y_lambda.shape}") print(f"First element value: {y_lambda[0,0,0]:.2f}")
Debug
Known issues
breakingThe API surface can change frequently and without explicit deprecation warnings across `0.0.x` releases, as this library is a collection of personal utilities in active development.
fix
Always pin your `torch-einops-utils` version in `requirements.txt` or `pyproject.toml` (e.g., `torch-einops-utils==0.0.30`) and consult the GitHub commit history before upgrading to a new `0.0.x` version.
affects: All 0.0.x versions
gotchaThis library heavily relies on `einops` syntax for defining tensor manipulations and assumes a strong understanding of PyTorch tensors.
fix
Ensure a strong foundational understanding of `einops` rearrange and reduce patterns, as well as core `torch` tensor operations. Consult the `einops` official documentation if patterns or operations are unclear.
affects: All versions
gotchaAs a 'personal utility functions' library, its design choices might be opinionated or tailored for specific use cases not broadly applicable, which can lead to unexpected behavior if used outside of its intended scope.
fix
Review the source code for specific function behaviors if they deviate from expected generic utility patterns, or if you encounter unexpected results, as the implementations might be optimized for particular scenarios.
affects: All versions
Upgrade
Version history
0.1.4latest on PyPI · released Jun 11, 2026
Audit
Dependencies
torchrequiredCore deep learning framework
einopsrequiredTensor rearrangement and reduction library
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources