The Hayashi et al. way to write a convolutional layer in a NN is,
einsum('c h w, h h2 i, w w2 j, c i j c2 -> c2 h2 w2', X, C, C, T), where C is a sparse tensor defined by C_{i,j,k} = [i=j+k]. (See also the image below.)
Obviously, directly materializing C this way would be very inefficient. It would turn an O(n^2) operation into n^3.
It would be cool if cotengra could optimize it though, and contract it using an efficient algorithm. Besides allowing simple notation for CNNs, it would make it easier to do research like Felix Dangel's paper Convolutions and More as Einsum exploring new architectures.

The Hayashi et al. way to write a convolutional layer in a NN is,
einsum('c h w, h h2 i, w w2 j, c i j c2 -> c2 h2 w2', X, C, C, T), whereCis a sparse tensor defined byC_{i,j,k} = [i=j+k]. (See also the image below.)Obviously, directly materializing
Cthis way would be very inefficient. It would turn an O(n^2) operation into n^3.It would be cool if cotengra could optimize it though, and contract it using an efficient algorithm. Besides allowing simple notation for CNNs, it would make it easier to do research like Felix Dangel's paper Convolutions and More as Einsum exploring new architectures.