Skip to content

Proc-macro based einsum implementation for rust-ndarray

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

termoshtt/einsum-derive

Repository files navigation

einsum-derive

Proc-macro based einsum implementation for ndarray crate

use ndarray::array;
use einsum_derive::einsum;

let a = array![
  [1.0, 2.0],
  [3.0, 4.0]
];
let b = array![
  [1.0, 2.0],
  [3.0, 4.0]
];
let c = einsum!("ij,jk->ik", a, b);
assert_eq!(c, array![
  [6.0, 8.0],
  [12.0, 16.0]
]);

This proc-macro wil compile the input subscripts "ij,jk->ik" to generate Rust code executing corresponding operation.

Status / Roadmap

Architecture

crates.io docs.rs GitHub Pages Description
einsum-derive crate docs.rs Pages proc-macro crate to provide einsum! macro
einsum-codegen crate docs.rs Pages Implements parser for the einsum subscripts and generates Rust code

Benchmark

bench

Benchmark with criterion.rs is running on GitHub Action on every commit on the main branch. The code is placed at einsum-derive/benches/einsum.rs, and you can run it on your environment by

cargo bench

and you will find its result on target/criterion/report/index.html.

License

© 2022 Toshiki Teramura (@termoshtt)

This project is licensed under either of

at your option.

Links

  • numpy.einsum is well-known einsum implementation in Python.
  • opt_einsum is an implementation for optimizing einsum computation for NumPy and other linear algebra packages.
  • oracleofnj/einsum is a runtime-based implementation of einsum for rust-ndarray

About

Proc-macro based einsum implementation for rust-ndarray

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages