I\'m trying to achieve the same behaviour as np.matmul parallel matrix multiplication using just tensordot,dot and reshaping etc.
The library I am translating this t
We need to keep one aligned and keep that also at the output. So, tensordot/dot
won't work here. More info on tensordot might explain it somehow on why it won't. But, we can use np.einsum, which in most cases (in my experience) is seen to be marginally faster than np.matmul
.
The implementation would look something like this -
np.einsum('ijk,ik->ij',rotations, vectors)
Also, it seems the desired output has one trailing singleton dim. So, append a new axis there with None/np.newaxis
, like so -
np.einsum('ijk,ik->ij',rotations, vectors)[...,None]