Registry / ai-ml / einops-exts

einops-exts

JSON →
library0.0.4pypypiunverified

einops-exts provides personal helper functions and extensions for the `einops` tensor manipulation library, primarily focusing on deep learning frameworks. It is currently at version 0.0.4 and has an irregular release cadence, with the latest release in January 2023.

pip install einops-exts
INSTALL
IMPORT
SIG · EINOPS-EXTS
E
einops-exts
ai-mlpythonv0.0.4
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.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
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

EinopsToAndFrom
from einops_exts import EinopsToAndFrom
from einops_exts import EinopsToAndFrom

This quickstart demonstrates the `EinopsToAndFrom` layer, a common utility in `einops-exts.torch`, which facilitates tensor shape transformations for PyTorch modules that expect specific dimension orders (e.g., `Conv2d` expecting channel-first data).

import torch from torch import nn from einops_exts.torch import EinopsToAndFrom # Define a simple PyTorch model using EinopsToAndFrom class MyModel(nn.Module): def __init__(self): super().__init__() self.transform = EinopsToAndFrom('b h w c -> b c h w', 'b c h w -> b h w c', nn.Identity()) self.conv = nn.Conv2d(3, 64, kernel_size=3, padding=1) def forward(self, x): # Input x is expected as (batch, height, width, channels) x = self.transform(x) # Transforms to (batch, channels, height, width) for Conv2d x = self.conv(x) x = self.transform(x) # Transforms back to (batch, height, width, channels) return x # Example usage model = MyModel() input_tensor = torch.randn(1, 64, 64, 3) # Batch 1, 64x64, 3 channels output_tensor = model(input_tensor) print(f"Input shape: {input_tensor.shape}") print(f"Output shape: {output_tensor.shape}")
Debug
Known issues
gotchaAs an extension library, `einops-exts` critically depends on `einops`. Incorrect `einops` pattern strings within `einops-exts` operations will lead to runtime errors due to shape mismatches or invalid axis compositions/decompositions. Users should be familiar with `einops` notation.
fix
Thoroughly test `einops` patterns. Refer to the `einops` documentation for correct notation and common transformations.
affects: All versions
gotchaWhile the core `einops` library is framework-agnostic, `einops-exts` primarily provides utilities for PyTorch (e.g., `einops_exts.torch`). Users attempting to use it with other frameworks (TensorFlow, JAX, NumPy) should verify if specific extensions exist for those backends, as direct use of PyTorch-specific modules will fail.
fix
Ensure you are using the correct submodule (e.g., `einops_exts.torch`) for your chosen deep learning framework. If no specific submodule exists, the functionality might not be supported for that framework.
affects: All versions
breakingThe library is in an early development stage (0.0.x versioning). While no explicit breaking changes are documented for `einops-exts` itself, its API might evolve rapidly, and changes in its core dependency (`einops`) could indirectly lead to breaking behavior.
fix
Pin `einops-exts` and `einops` to specific versions in your `requirements.txt` or `pyproject.toml` to prevent unexpected breakages. Regularly review the GitHub repository for updates and changes before upgrading.
affects: <1.0.0
Upgrade
Version history
0.0.4latest on PyPI · released Jan 5, 2023
Audit
Dependencies
einopsrequiredThis library provides extensions for `einops` and is a core dependency.
torchoptionalMany extensions are implemented for PyTorch, making it a common practical dependency.
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
einops-exts — pip install einops-exts · libregistry