Tensory is a fast, minimal, and extensible tensor network computation library written in Rust.
- High performance: Built with Rust's zero-cost abstractions and efficient memory management.
- Modular design: Easy to extend with custom tensor structures and backends.
- Rust idioms: Follows Rust best practices for safety and concurrency.
- Cross-platform: Supports Linux, macOS, and Windows.
Add Tensory to your Cargo.toml:
[dependencies]
tensory-core = { git = "https://github.com/todo-group/tensory.git" }
tensory-basic = { git = "https://github.com/todo-group/tensory.git" }
tensory-linalg = { git = "https://github.com/todo-group/tensory.git" }
tensory-ndarray = { git = "https://github.com/todo-group/tensory.git" }
anyhow = "1.0.100"
openblas-src = { version = "0.10.13", features = ["system"] }
blas-src = { version = "0.14.0", features = ["openblas"] }Then, use it in your code:
use tensory_basic::mapper::VecMapper;
use tensory_core::prelude::*;
use tensory_linalg::prelude::*;
use tensory_ndarray::{NdDenseTensor, NdDenseTensorExt};
extern crate blas_src;
type Tensor<'a, E> = NdDenseTensor<E, VecMapper<&'a str>>;
fn main() -> anyhow::Result<()> {
let t = Tensor::<f64>::random(lm!["a"=>10, "b"=>15, "c"=>20, "d"=>25])?;
let (u, s, v) = (&t).svd(ls![&"a", &"b"], "us", "sv")?.with(((),))?;
Ok(())
}Read Examples for sample codes, or see API Docs to know details.
- High-Dimentional-Diagonal Tensor
- Normalized tensor (for TRG)
- Sparse Tensor
- Lazy Contraction Tensor
- Allocation-aware interface
- GPU backend (CUDA, ROCm, ...)
- Grassmann Tensor
- Symbolic Function Tensor
This project is licensed under the UNDEFIND! License.
Inspired by:
- ITensor (C++)
- ndarray (Rust)
- grassmanntn (python)