Expand description
§OMEinsum-rs
High-performance Einstein summation with support for both tropical and standard algebras.
§Features
- Algebra-agnostic: Works with standard arithmetic
(+, ×)and tropical semirings(max, +),(min, +) - Optimized contraction: Integration with omeco for contraction order optimization
- Backpropagation: Gradient computation for both tropical and standard operations
- Zero-copy views: Stride-based tensor with efficient permute/reshape
- CPU + CUDA: Support for both backends (CUDA optional)
§Quick Start
use omeinsum::{Tensor, Einsum, einsum, Cpu};
use omeinsum::algebra::{Standard, MaxPlus};
// Standard matrix multiplication
let a = Tensor::<f32, Cpu>::from_data(&[1.0, 2.0, 3.0, 4.0], &[2, 2]);
let b = Tensor::<f32, Cpu>::from_data(&[1.0, 2.0, 3.0, 4.0], &[2, 2]);
// C[i,k] = Σ_j A[i,j] × B[j,k]
let c = einsum::<Standard<f32>, _, _>(&[&a, &b], &[&[0, 1], &[1, 2]], &[0, 2]);
// Tropical (max-plus) matrix multiplication
// C[i,k] = max_j (A[i,j] + B[j,k])
let c_tropical = einsum::<MaxPlus<f32>, _, _>(&[&a, &b], &[&[0, 1], &[1, 2]], &[0, 2]);§Architecture
┌─────────────────────────────────────────────────────────────┐
│ User API │
│ einsum(tensors, ixs, iy) → Tensor │
│ Einsum::new(ixs, iy).optimize().execute(tensors) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Einsum Engine │
│ omeco::optimize_code() → NestedEinsum (contraction tree) │
│ Execute tree via binary contractions │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Algebra<T> dispatch │
│ Standard<T>: (+, ×) → BLAS/loops │
│ MaxPlus<T>: (max, +) → tropical-gemm │
│ MinPlus<T>: (min, +) → tropical-gemm │
└─────────────────────────────────────────────────────────────┘Re-exports§
pub use algebra::Algebra;pub use algebra::Semiring;pub use algebra::Standard;pub use backend::Backend;pub use backend::BackendScalar;pub use backend::Cpu;pub use backend::Storage;pub use einsum::einsum;pub use einsum::einsum_with_grad;pub use einsum::EinBuilder;pub use einsum::Einsum;pub use tensor::Tensor;pub use tensor::TensorView;
Modules§
- algebra
- Algebraic structures for tensor operations.
- backend
- Backend abstractions for CPU and GPU execution.
- einsum
- Einstein summation engine with contraction order optimization.
- tensor
- Stride-based tensor type with zero-copy views.
Macros§
- ein
- Convenience macro for creating einsum specifications.
Type Aliases§
- Complex32
- Alias for a
Complex<f32> - Complex64
- Alias for a
Complex<f64>