https://github.com/nicholas-miklaucic/eins

One tensor operation is all you need

https://github.com/nicholas-miklaucic/eins

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.3%) to scientific vocabulary

Keywords

array deep-learning einops jax numpy python
Last synced: 6 months ago · JSON representation

Repository

One tensor operation is all you need

Basic Info
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 4
  • Releases: 0
Topics
array deep-learning einops jax numpy python
Created almost 2 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Contributing License Code of conduct

README.md

eins

One tensor operation is all you need

PyPI - Version PyPI - Python Version Contributor Covenant PRs Welcome

What if most of your machine learning model code could be replaced by a single operation? Eins gives you a powerful language to describe array manipulation, making it a one-stop shop for all of your AI needs.

Let's say you want to compute batched pairwise distance between two batches of arrays of points:

python from eins import EinsOp EinsOp('batch n1 d, batch n2 d -> batch n1 n2', combine='add', reduce='l2_norm')(pts1, -pts2)

If you're more interested in deep learning, here is the patch embedding from a vision transformer. That means breaking up an image into patches and then linearly embedding each patch.

python from eins import EinsOp patchify = EinsOp('''b (n_p patch) (n_p patch) c, (patch patch c) emb -> b (n_p n_p) emb''') patches = patchify(images, kernel)

You input the shapes and Eins will figure out what to do.

If you've used einops, then think of Eins as einops with a more ambitious goal—being the only operation you should need for your next deep learning project.

Interested? Check out the tutorial, which walks you through the highlights of Eins with examples of how Eins can make the array operations you know and love more readable, portable, and robust.

To learn more, consult the documentation or the examples.

Installation

console pip install eins

Eins works with anything that implements the Array API, and Eins explicitly promises to support NumPy, PyTorch, and JAX—including full differentiability. You will need one of those libraries to actually use Eins operations.

Features

  • 🧩 A solver that can handle duplicate axes, named constants, and constraints
  • 🚀 Compilation and optimization for high performance without sacrificing readability
  • Split, concatenate, stack, flatten, transpose, normalize, reduce, broadcast, and more
  • Works across frameworks
  • A composable set of unified array operations for portable softmax, power normalization, and more

Roadmap

Eins is still in heavy development. Here's a sense of where we're headed.

Near-Term (weeks)

  • [ ] Updating indexing syntax to match eindex
  • [x] Unit array to indicate zero-dimensional tensors
  • [ ] ... for batching over dynamic numbers of batch axes
  • [ ] Specifying intermediate results to control the order of reduction
  • [ ] Support - and /
  • [ ] Better error reporting
  • [ ] Ways of visualizing and inspecting the computation graph
  • [ ] Typo checking in errors about axes
  • [ ] Multiple outputs, either through arrows or commas

Long-Term (months)

  • [ ] Layers for popular ML frameworks
  • [ ] Automatically optimizing the execution of a specific EinsOp for a specific computer and input size
  • [ ] Completing full support for tensor indexing
  • [ ] Static typing support
  • [ ] Tabulating the model FLOPs/memory usage as a function of named axes
  • [ ] Functionality akin to pack and unpack

Acknowledgements

The excellent einops library inspired this project and its syntax. After working on my own extension to handle indexing, I realized that eindex already had a more coherent vision for what indexing can look like, and so much of that syntax in this library borrows from that one.

Contributing

Any contributions to Eins are welcomed and appreciated! If you're interested in making serious changes or extensions to the syntax of operations, consider reaching out first to make sure we're on the same page. For any code changes, do make sure you're using the project Ruff settings.

License

Eins is distributed under the terms of the MIT license.

Owner

  • Name: Nicholas Miklaucic
  • Login: nicholas-miklaucic
  • Kind: user

A student at Northeastern University, coding in Python and Rust.

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 51
  • Total Committers: 1
  • Avg Commits per committer: 51.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 51
  • Committers: 1
  • Avg Commits per committer: 51.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Nicholas Miklaucic n****c@g****m 51

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 4
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.25
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • nicholas-miklaucic (4)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 25 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
pypi.org: eins

One tensor operation is all you need

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 25 Last month
Rankings
Dependent packages count: 9.6%
Average: 36.5%
Dependent repos count: 63.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/main.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
pyproject.toml pypi
  • array-api-compat *
  • pyparsing *