ocannl icon indicating copy to clipboard operation
ocannl copied to clipboard

Concatenate along a new or an existing axis: `einsum` extension

Open lukstafi opened this issue 2 years ago • 5 comments

Needs to be fully integrated with shape inference. The core functionality would be around an extension of the einsum notation, this allows to align and permute axes arbitrarily (on top of doing outer and inner products of selected axes). This introduces ^ into the einsum syntax. For example, a|b->c;a|c->d=>a|c->b^d would alias axes a, c (same-named) and b^d, and concatenate along the b resp. d axis. Eventually it would also support producing block-diagonal tensors with multiple-uses of ^, e.g. a->b;c->d=>a^c->b^d would produce a matrix with the original matrices as submatrices, a->b in the upper-left corner, c->d in the lower-right corner, and zero-valued matrices a->d and c->b in the other corners correspondingly. The syntax ^ would naturally bind tighter than label separator, for example ba;dc=>b^da^c is the same as b,a;d,c=>b^d,a^c (and has the same layout as a->b;c->d=>a^c->b^d).

lukstafi avatar Feb 16 '23 10:02 lukstafi

Bumping this to high priority.

lukstafi avatar Apr 03 '24 19:04 lukstafi

Or maybe not, for the simplest "k+1 dimensional" cases there's a workaround using fixed indexing.

lukstafi avatar Apr 03 '24 20:04 lukstafi