OMSparseEinsum is a Julia package for efficient sparse tensor network computations. It extends the OMEinsum package with sparse tensor support.
You can install OMSparseEinsum using Julia's package manager:
] dev https://github.com/TensorBFS/OMSparseEinsum.jl.git
using OMSparseEinsum, OMEinsum
# construct the tensor network
code = EinCode([[1, 2], [2, 3], [3, 4]], [1, 4])
tensors = [SparseTensor([1 1; 1 0]) for _ in 1:3]
# optimize the contraction order
size_dict = OMEinsum.get_size_dict(code.ixs, tensors)
optcode = optimize_code(code, size_dict, TreeSA())
# compute the result
res = optcode(tensors...)
# output:
# 2×2 SparseTensor{Int64, Int64, 2} with 4 stored entries:
# (2, 2) => 1
# (2, 1) => 2
# (1, 2) => 2
# (1, 1) => 3
Please refer to the examples for more usage examples.