| Crates.io | tropical-gemm |
| lib.rs | tropical-gemm |
| version | 0.1.0 |
| created_at | 2026-01-13 13:23:34.01397+00 |
| updated_at | 2026-01-13 13:23:34.01397+00 |
| description | High-performance tropical matrix multiplication with SIMD and CUDA backends |
| homepage | |
| repository | https://github.com/TensorBFS/tropical-gemm |
| max_upload_size | |
| id | 2040154 |
| size | 311,998 |
High-performance tropical matrix multiplication in Rust with SIMD and CUDA backends.
[dependencies]
tropical-gemm = "0.1"
tropical-gemm-cuda = "0.1" # Optional GPU support
use tropical_gemm::{Mat, MaxPlus};
let a = Mat::<MaxPlus<f32>>::from_row_major(&[1.0, 2.0, 3.0, 4.0, 5.0, 6.0], 2, 3);
let b = Mat::<MaxPlus<f32>>::from_row_major(&[1.0, 2.0, 3.0, 4.0, 5.0, 6.0], 3, 2);
// C[i,j] = max_k(A[i,k] + B[k,j])
let c = a.matmul(&b);
assert_eq!(c.get_value(0, 0), 8.0); // max(1+1, 2+3, 3+5) = 8
import numpy as np
import tropical_gemm
a = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32)
b = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32)
c = tropical_gemm.maxplus_matmul(a, b)
📖 User Guide - Installation, tutorials, examples
📚 API Reference - Rust API documentation
| Type | ⊕ | ⊗ | Use Case |
|---|---|---|---|
MaxPlus<T> |
max | + | Longest path, Viterbi |
MinPlus<T> |
min | + | Shortest path |
MaxMul<T> |
max | × | Max probability |
| Size | CPU (ms) | GPU (ms) | Speedup |
|---|---|---|---|
| 256 | 4.1 | 0.03 | 128x |
| 1024 | 262 | 0.36 | 728x |
| 2048 | 2092 | 2.5 | 837x |
MIT