Does Julia have an equivalent of TensorFlow `matmul`

? I need matrix multiplication using two given (or pre-defined) dimensions of the tensors, preserving other dimensions.

Tensorflow `matmul`

uses the two innermost tensor dimensions for matrix multiplication, and preserves the remaining dimensions. In pseudocode, `A_ijkmn=sum_x(B_ijkmx * C_ijkxn)`

, summing across dimension `x`

, which is the last dim of `B`

and second last dim of `C`

. So, the innermost dims must agree for multiplication, and the preserved dims must be the same between the two tensors. The actual indices do not matter.

I need this to play nicely with `CuArrays`

and `Zygote`

. The ultimate goal is to use it for a deep learning model.

I am aware of TensorOperations, and might end up using that. The drawbacks are:

- I would not want to pull in a new dependency if there is similar functionality in packages that come with Julia Distro
- Dimensions need to be specified explicitly