Output permutation in einsum fails
matthiasneuner opened this issue · comments
Hello Roman,
your snippet regarding OIndex
in einsum
from the Wiki does not compile for me:
enum {I,J,K,L,M,N};
Tensor<double,2,3,5> A; Tensor<double,3,5,2,4> B;
// fill A and B
A.random(); B.random();
// Order as I,K,L,M,N - same as default
auto C = einsum<Index<I,J,K>,Index<J,L,M,N>,OIndex<I,K,L,M,N>>(A,B); // works
// Order as I,L,K,N,M - resulting tensor [Tensor<double,2,5,5,4,2>]
auto D = einsum<Index<I,J,K>,Index<J,L,M,N>,OIndex<I,M,K,N,M>>(A,B); // fails
Although using OIndex
works in many places, occasionally it fails to compile, like in the example above.
Thank you in advance :-) !
The Wiki entry is incorrect. In the second example, there are duplicate entries in the output Index (in OIndex<I,M,K,N,M>
, M
is repeated twice).
There is some discussion on how to support this feature, see #91. In the above example however, even if the duplicate entries were taken care of the output tensor cannot be reshaped like that. That typo makes the whole example incorrect. I will correct the Wiki. If you have other cases where einsum
with OIndex
fails, report it.