OMEinsum.jl

This package provides

  • The einsum notation, which is similar to the einsum function in numpy, although some details are different.
  • Highly optimized algorithms to optimize the contraction of tensors.

The source code is available at OMEinsum.jl.

Quick start

You can find a set up guide in the README. To get started, open a Julia REPL and type the following code.

julia> using OMEinsum
julia> code = ein"ij,jk,kl,lm->im" # define the einsum operationij, jk, kl, lm -> im
julia> optcode = optimize_code(code, uniformsize(code, 100), TreeSA()) # optimize the contraction orderki, mk -> im ├─ jk, ij -> ki │ ├─ jk │ └─ ij └─ lm, kl -> mk ├─ lm └─ kl
julia> optcode(randn(100, 100), randn(100, 100), randn(100, 100), randn(100, 100)) # compute the result100×100 Matrix{Float64}: -6.12125 -525.686 -2286.76 … 146.241 -26.4623 -762.849 1063.56 930.139 689.342 943.279 47.5721 173.718 -1657.45 1690.49 -1044.98 -764.243 932.333 1259.96 463.346 1619.63 -1493.31 -1728.53 2208.31 -806.461 989.323 -1951.2 -505.067 -447.405 -716.807 1064.86 -497.002 -20.2953 -1178.23 … 243.524 555.58 -960.441 -1980.8 -1187.67 357.042 503.557 698.557 -1095.35 -506.512 770.852 319.192 -434.015 1541.9 2495.87 -684.9 3500.08 1349.35 995.611 706.008 -66.8325 -754.877 3204.44 -1012.24 1160.67 981.198 -242.511 ⋮ ⋱ -79.5721 -119.495 1855.57 601.924 -19.8216 -472.667 -1996.99 121.316 432.117 1312.41 1313.94 -496.394 690.789 -11.4183 151.871 730.008 54.0171 711.313 -8.78545 -1173.33 -266.005 338.171 -100.816 -1049.33 -1194.03 611.395 -2417.73 … 660.685 -876.977 -549.798 -520.547 -1703.17 873.316 804.774 -1015.9 -1600.47 -66.4216 1835.61 785.689 -211.848 2108.11 -258.689 540.475 2837.18 324.604 -1052.65 738.322 -454.541 -1215.74 799.773 -548.443 -731.715 419.708 -696.118