Einops

Einops

โ˜… 4 ๐Ÿ”– 2500 saves ๐Ÿ’ฐ Free GitHub

Einops is a widely loved open-source Python library that makes tensor operations readable: reshaping, transposing, repeating and reducing arrays are written as short, self-documenting patterns instead of chains of view, transpose and squeeze calls. Published on GitHub under the MIT license, it has earned more than 9,600 stars and was still actively maintained in 2026.

Overview

The library provides a small set of operations โ€” rearrange, reduce, repeat and the einops.layers modules โ€” that work the same way across PyTorch, TensorFlow, JAX, NumPy, CuPy, MLX and other array frameworks. Because the notation names each axis explicitly, code written with einops documents itself and is far less prone to silent shape bugs. It has become a standard ingredient in transformer and diffusion codebases, where attention heads, patches and channels are constantly being split and merged. The patterns also serve as executable documentation of tensor shapes: a reader can see exactly which dimensions are combined, repeated or reduced without mentally simulating index arithmetic, and einops validates the pattern against the actual tensor at runtime, catching mismatches early with a readable error.

Key Features

  • One notation for tensor operations across PyTorch, TensorFlow, JAX, NumPy and more
  • rearrange, reduce and repeat operations with named, checkable axes
  • Framework-specific layers for PyTorch, TensorFlow/Keras and Flax models
  • EinopsError messages that explain exactly which axes did not match
  • Zero heavy dependencies and broad compatibility with existing model code
  • Extensive documentation and tutorials at einops.rocks

๐Ÿ’ณ Pricing

Einops is completely free and open source under the MIT license, installable from PyPI with pip.

The project also maintains extensive tutorials, and its operations are a staple of modern deep-learning codebases โ€” many practitioners first meet einops when reading a transformer implementation, where it has effectively become part of the shared vocabulary for describing tensor shapes.

Who Is It For

It is for deep learning engineers, researchers and students who write tensor-heavy code โ€” especially transformers, vision models and diffusion pipelines โ€” and want shape manipulations they can read, review and trust at a glance.

๐Ÿš€ Visit Einops Official Site

๐Ÿšฉ Report an issue