fferflo/einx
Universal Notation for Tensor Operations in Python
What it solves
einx simplifies the complex process of formulating tensor operations across different machine learning frameworks. It eliminates the need to manually write tedious reshape, transpose, and squeeze operations by providing a universal, high-level notation for describing how tensors should be manipulated and reduced.
How it works
The library uses a string-based notation that describes the desired output based on an analogy to loop notation. Users specify an elementary operation (like sum, mean, or a custom function) and an expression that defines how that operation is vectorized.
Internally, einx does not use slow Python for-loops; instead, it compiles these expressions into optimized Python code snippets that call the native operations of the underlying tensor framework (such as NumPy, PyTorch, JAX, TensorFlow, or MLX).
Who it’s for
It is designed for researchers and developers working with tensors in AI and machine learning who want a framework-agnostic way to handle complex tensor transformations and reductions.
Highlights
- Universal Interface: Works seamlessly across NumPy, PyTorch, JAX, TensorFlow, and MLX.
- Flexible Notation: Supports permuting, splitting, flattening, and gathering values using a concise string syntax.
- Custom Operations: Allows users to adapt their own Python functions to the einx notation using adapters.
- Transparent Compilation: Users can inspect the generated backend code by passing
graph=Trueto an operation.
Related
- Project
- Project
- Project
- Project