# Is there a library that allows einstein summation on dense, sparse, and LinearOperator type tensors

Numpy's einsum only works with dense tensors.

Is there an alternative that also works with sparse tensors and linear operators?

For example, I might have a function f that computes matrix vector multiplications of the form $$A^{-1}x$$ for some matrix $$A$$. Numpy's einsum doesn't even allow

np.einsum('ij,j',A,x)


let alone

np.einsum('ijkl,mj->imkl',X,A)


The same operations also don't work when $$A$$ is a sparse matrix (let alone a general sparse tensor).

While the LinearOperator support is more of a convenience question, the support for sparse tensors is crucial to me.