yhtang/FunFact

Update documentation update for >>

Closed this issue · 2 comments

The user guide documentation on tensor expressions only describes the use of >> for index transposition. We have to update this to reflect the non-reduction functionality of this operator in the context of Einstein notations.

https://funfact.readthedocs.io/en/latest/pages/user-guide/tsrex/#index-transposition

How about we go with this approach:

Rename the Index transposition subsection to Explicit output indices, which examines the two related usages of the >> operator:

  1. If >> [indices...] immediately follows an indexed binary (i.e. einop) operation, then the output indices will be used in the NumPy convention to specify not only the order of the output dimensions but also to force/disable reduction over specified indices. In this case, the indices in [] must be a subset of the union of live indices of the left-hand side and the right-hand side.
  2. If >> [indices...] follows an indexed expression that is, however, not an einop, then it will specify an axes permutation, the order of which will be deduced by the indices in [] as well as the live indices of the indexed expression. The two sets of indices here must have the same elements.

That's a nice summary!

One subtlety that we might want to address in this section of the documentation is when an indexed expression is not an einop. For example:

tsrex = a[i, k] * b[j, k]
tsrex >> [j, i]

Is tsrex on the second line still considered an einop or not?